GetLocalizedMessage() public static method

public static GetLocalizedMessage ( string key ) : string
key string
return string
Ejemplo n.º 1
0
        public void TestNLSLoading()
        {
            String message = NLS
                             .GetLocalizedMessage(MessagesTestBundle.Q0004E_INVALID_SYNTAX_ESCAPE_UNICODE_TRUNCATION, new CultureInfo("en"));

            /*
             * if the default locale is ja, you get ja as a fallback:
             * see ResourceBundle.html#getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader)
             */
            if (!CultureInfo.CurrentUICulture.TwoLetterISOLanguageName.Equals("ja", StringComparison.OrdinalIgnoreCase))
            {
                assertEquals("Truncated unicode escape sequence.", message);
            }

            message = NLS.GetLocalizedMessage(MessagesTestBundle.Q0001E_INVALID_SYNTAX, new CultureInfo("en"),
                                              "XXX");

            /*
             * if the default locale is ja, you get ja as a fallback:
             * see ResourceBundle.html#getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader)
             */
            if (!CultureInfo.CurrentUICulture.TwoLetterISOLanguageName.Equals("ja", StringComparison.OrdinalIgnoreCase))
            {
                assertEquals("Syntax Error: XXX", message);
            }
        }
Ejemplo n.º 2
0
        public void TestMissingMessage()
        {
            CultureInfo locale  = new CultureInfo("en");
            String      message = NLS.GetLocalizedMessage(
                MessagesTestBundle.Q0005E_MESSAGE_NOT_IN_BUNDLE, locale);

            assertEquals("Message with key:Q0005E_MESSAGE_NOT_IN_BUNDLE and locale: "
                         + locale.toString() + " not found.", message);
        }
Ejemplo n.º 3
0
        public void TestNLSLoading_ja()
        {
            String message = NLS.GetLocalizedMessage(
                MessagesTestBundle.Q0004E_INVALID_SYNTAX_ESCAPE_UNICODE_TRUNCATION,
                new CultureInfo("ja-JP"));

            assertEquals("切り捨てられたユニコード・エスケープ・シーケンス。", message);

            message = NLS.GetLocalizedMessage(MessagesTestBundle.Q0001E_INVALID_SYNTAX,
                                              new CultureInfo("ja-JP"), "XXX");
            assertEquals("構文エラー: XXX", message);
        }
Ejemplo n.º 4
0
        public void TestNLSLoading_xx_XX()
        {
            try
            {
                CultureInfo locale  = new CultureInfo("xx-XX");
                String      message = NLS.GetLocalizedMessage(
                    MessagesTestBundle.Q0004E_INVALID_SYNTAX_ESCAPE_UNICODE_TRUNCATION,
                    locale);

                /*
                 * if the default locale is ja, you get ja as a fallback:
                 * see ResourceBundle.html#getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader)
                 */
                if (!CultureInfo.CurrentUICulture.TwoLetterISOLanguageName.Equals("ja", StringComparison.OrdinalIgnoreCase))
                {
                    assertEquals("Truncated unicode escape sequence.", message);
                }

                message = NLS.GetLocalizedMessage(MessagesTestBundle.Q0001E_INVALID_SYNTAX,
                                                  locale, "XXX");

                /*
                 * if the default locale is ja, you get ja as a fallback:
                 * see ResourceBundle.html#getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader)
                 */
                if (!CultureInfo.CurrentUICulture.TwoLetterISOLanguageName.Equals("ja", StringComparison.OrdinalIgnoreCase))
                {
                    assertEquals("Syntax Error: XXX", message);
                }
            }
            catch (CultureNotFoundException)
            {
                // ignore

                // LUCENENET NOTE: .NET Core throws a CultureNotFoundException in this case.
                // There doesn't seem to be a reasonable way to test this as a result.
            }
        }
Ejemplo n.º 5
0
 public virtual string GetLocalizedMessage(CultureInfo locale)
 {
     return(NLS.GetLocalizedMessage(Key, locale, GetArguments()));
 }