Пример #1
0
        /// <summary>
        /// initialise the resource manager with the given language
        /// </summary>
        public static void Init(string ALanguageCode, string ACultureCode)
        {
            if (ALanguageCode.ToLower() == "en-en")
            {
                ALanguageCode = "en-GB";
            }

            if (ACultureCode.ToLower() == "en-en")
            {
                ACultureCode = "en-GB";
            }

            // modify current locale for the given language
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(ALanguageCode);

            string ResourceDllFname = TAppSettingsManager.ApplicationDirectory +
                                      "\\" + Thread.CurrentThread.CurrentUICulture.IetfLanguageTag + "\\OpenPetra.resources.dll";

            if (File.Exists(ResourceDllFname))
            {
                catalog = new GettextResourceManager("OpenPetra");
            }
            else
            {
                TLogging.LogAtLevel(1, "cannot find " + ResourceDllFname);
            }

            Thread.CurrentThread.CurrentCulture = new CultureInfo(ACultureCode);
        }
Пример #2
0
        public MainController()
        {
            //Type t = typeof(MainCatalog_ru_RU);

            View = new UIView();
            View.Frame = new RectangleF(0f, 0f, 320f, 460f);
            View.BackgroundColor = UIColor.White;

            UILabel l = new UILabel();
            l.Frame = new RectangleF(0f, 0f, 320f, 200f);
            l.Lines = 0;
            l.LineBreakMode = UILineBreakMode.WordWrap;

            View.AddSubview(l);

            CultureInfo ci = new CultureInfo ("ru-RU");

            GettextResourceManager catalog = new GettextResourceManager ("MainCatalog", new DifferentNamesSingleFolderPathResolver());

            StringBuilder sb = new StringBuilder();
            sb.AppendLine(catalog.GetString (Text.MyNameIs, ci))
              .AppendLine(catalog.GetString (Text.MyAge, ci))
              .AppendLine(catalog.GetString (Text.ILove, ci));

            for (int i = 0; i < 6; i++)
            {
                sb.AppendLine(string.Format (catalog.GetPluralString(Text.PluralDay, Text.PluralDays, i, ci), i));
            }

            l.Text = sb.ToString();
        }
Пример #3
0
 public static void Main (String[] args) {
   GettextResourceManager catalog =
     new GettextResourceManager("hello-csharp");
   Console.WriteLine(catalog.GetString("Hello, world!"));
   Console.WriteLine(
       String.Format(
           catalog.GetString("This program is running as process number {0}."),
           Process.GetCurrentProcess().Id));
 }
Пример #4
0
        public static void Main(string[] args)
        {
            CultureInfo ci = new CultureInfo ("ru-RU");

            GettextResourceManager catalog = new GettextResourceManager ("MainCatalog");

            Console.WriteLine (catalog.GetString (Text.MyNameIs, ci));
            Console.WriteLine (catalog.GetString (Text.GoodFeet, ci));
            Console.WriteLine (catalog.GetString (Text.PerfectFeet, ci));

            for (int i = 0; i < 6; i++)
            {
                Console.WriteLine (catalog.GetPluralString(Text.PluralDay, Text.PluralDays, i, ci), i);
            }

            Console.ReadLine ();
        }
Пример #5
0
 public static void Main (String[] args) {
   #if __MonoCS__
   // Some systems don't set CurrentCulture and CurrentUICulture as specified
   // by LC_ALL. So set it by hand.
   String locale = System.Environment.GetEnvironmentVariable("LC_ALL");
   if (locale == null || locale == "")
     locale = System.Environment.GetEnvironmentVariable("LANG");
   if (!(locale == null || locale == "")) {
     if (locale.IndexOf('.') >= 0)
       locale = locale.Substring(0,locale.IndexOf('.'));
     System.Threading.Thread.CurrentThread.CurrentCulture =
     System.Threading.Thread.CurrentThread.CurrentUICulture =
       new System.Globalization.CultureInfo(locale.Replace('_','-'));
   }
   #endif
   GettextResourceManager catalog =
     new GettextResourceManager("hello-csharp");
   Console.WriteLine(catalog.GetString("Hello, world!"));
   Console.WriteLine(
       String.Format(
           catalog.GetString("This program is running as process number {0}."),
           Process.GetCurrentProcess().Id));
 }
Пример #6
0
        static void ShowMessages()
        {
            Console.WriteLine("Current culture {0}", System.Threading.Thread.CurrentThread.CurrentUICulture);
            GettextResourceManager catalog = new GettextResourceManager(PathResolver.Default);
            Console.WriteLine(catalog.GetString("Hello, world!"));
            // GetStringFmt is an Gettext.NET extension
            Console.WriteLine(catalog.GetStringFmt("This program is running as process number \"{0}\".",
                              Process.GetCurrentProcess().Id));
            Console.WriteLine(String.Format(
                catalog.GetPluralString("found {0} similar word", "found {0} similar words", 1),
                1));
            // GetPluralStringFmt is an Gettext.NET extension
            Console.WriteLine(catalog.GetPluralStringFmt("found {0} similar word", "found {0} similar words", 2));
            Console.WriteLine(String.Format(
                catalog.GetPluralString("found {0} similar word", "found {0} similar words", 5),
                5));

            Console.WriteLine("{0} ('computers')",  catalog.GetParticularString("Computers", "Text encoding"));
            Console.WriteLine("{0} ('military')",  catalog.GetParticularString("Military", "Text encoding"));
            Console.WriteLine("{0} (non cotextual)",  catalog.GetString("Text encoding"));

            Console.WriteLine(catalog.GetString(
                "Here is an example of how one might continue a very long string\nfor the common case the string represents multi-line output.\n"));
        }