Пример #1
0
        private void SetTexts()
        {
            GettextResourceManager catalog = new GettextResourceManager(PathResolver.Default);

            // If satellite assemblies have another base name use GettextResourceManager("Examples.HelloForms.Messages") constructor
            // If you call from another assembly, use GettextResourceManager(anotherAssembly) constructor
            Localizer.Localize(this, catalog, store);
            // We need pass 'store' argument only to be able revert original text and switch languages on fly
            // Common use case doesn't required it: Localizer.Localize(this, catalog);

            // Manually formatted strings
            label2.Text = catalog.GetStringFmt("This program is running as process number \"{0}\".",
                                               System.Diagnostics.Process.GetCurrentProcess().Id);
            label3.Text = String.Format(
                catalog.GetPluralString("found {0} similar word", "found {0} similar words", 1),
                1);
            label4.Text = String.Format(
                catalog.GetPluralString("found {0} similar word", "found {0} similar words", 2),
                2);
            label5.Text = String.Format(
                catalog.GetPluralString("found {0} similar word", "found {0} similar words", 5),
                5);
            label6.Text = String.Format("{0} ('computers')", catalog.GetParticularString("Computers", "Text encoding"));
            label7.Text = String.Format("{0} ('military')", catalog.GetParticularString("Military", "Text encoding"));
            label8.Text = String.Format("{0} (non contextual)", catalog.GetString("Text encoding"));
        }
Пример #2
0
        static void ShowMessages()
        {
            Console.WriteLine("Current culture {0}", System.Threading.Thread.CurrentThread.CurrentUICulture);
            GettextResourceManager catalog = new GettextResourceManager();

            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"));
        }
 /// <inheritdoc />
 /// <seealso cref="GettextResourceManager.GetParticularString(string,string)"/>
 public string GetParticularString([NotNull] string context, string text)
 {
     if (text == null)
     {
         throw new ArgumentNullException(nameof(text));
     }
     if (context == null)
     {
         throw new ArgumentNullException(nameof(context));
     }
     return(resourceManager.GetParticularString(context, text));
 }
Пример #4
0
        private void SetTexts()
        {
            GettextResourceManager catalog = new GettextResourceManager(PathResolver.Default);
            // If satellite assemblies have another base name use GettextResourceManager("Examples.HelloForms.Messages") constructor
            // If you call from another assembly, use GettextResourceManager(anotherAssembly) constructor
            Localizer.Localize(this, catalog, store);
            // We need pass 'store' argument only to be able revert original text and switch languages on fly
            // Common use case doesn't required it: Localizer.Localize(this, catalog);

            // Manually formatted strings
            label2.Text = catalog.GetStringFmt("This program is running as process number \"{0}\".",
                                               System.Diagnostics.Process.GetCurrentProcess().Id);
            label3.Text = String.Format(
                catalog.GetPluralString("found {0} similar word", "found {0} similar words", 1),
                1);
            label4.Text = String.Format(
                catalog.GetPluralString("found {0} similar word", "found {0} similar words", 2),
                2);
            label5.Text = String.Format(
                catalog.GetPluralString("found {0} similar word", "found {0} similar words", 5),
                5);
            label6.Text = String.Format("{0} ('computers')",  catalog.GetParticularString("Computers", "Text encoding"));
            label7.Text = String.Format("{0} ('military')",  catalog.GetParticularString("Military", "Text encoding"));
            label8.Text = String.Format("{0} (non contextual)",  catalog.GetString("Text encoding"));
        }