コード例 #1
0
ファイル: FactoryTests.cs プロジェクト: jslachta/LocaleNames
        public void LocaleNames_Factory_ForCultureInfo_Existing_Culture_Test()
        {
            var translations = LocaleTranslations.ForCultureInfo(new System.Globalization.CultureInfo("en-US"));

            Assert.AreEqual(new System.Globalization.CultureInfo("en-US"), translations.CultureInfo);
            Assert.IsFalse(translations.AreCountryNameTranslationsEmpty);
            Assert.IsFalse(translations.AreLanguageTranslationsEmpty);
        }
コード例 #2
0
        public void Find_all_variants_of_country_name_by_code()
        {
            var localeNames = LocaleTranslations.ForLanguageCode("en-US");
            var result      = localeNames.FindCountryNames("CZ");

            Assert.IsTrue(result.Count == 2, "CZ country name has only two variants");
            Assert.IsTrue(result[Enumerations.AltVariant.Common] == "Czechia");
            Assert.IsTrue(result[Enumerations.AltVariant.Alternative] == "Czech Republic");
        }
コード例 #3
0
        public void Find_country_name_by_code()
        {
            var localeNames = LocaleTranslations.ForLanguageCode("en-US");

            Assert.AreEqual("Germany", localeNames.FindCountryName("DE"));
            Assert.AreEqual("Czechia", localeNames.FindCountryName("CZ"));
            Assert.AreEqual("United Kingdom", localeNames.FindCountryName("GB"));
            Assert.AreEqual(null, localeNames.FindCountryName("unknown code"));
        }
コード例 #4
0
        public void LocaleNames_Find_language_name_for_current_culture()
        {
            var localeNames = LocaleTranslations.ForCurrentCulture();

            Assert.AreEqual("angličtina (USA)", localeNames.FindLanguageName("en-US"));

            Assert.AreEqual("němčina (walser)", localeNames.FindLanguageName("wae"));

            Assert.AreEqual("čínština (tradiční)", localeNames.FindLanguageName("zh-Hant"));
        }
コード例 #5
0
ファイル: FactoryTests.cs プロジェクト: jslachta/LocaleNames
        public void LocaleNames_Factory_ForLanguageCode_InvalidLanguageCode_Test()
        {
            /*
             * if a not valid language code is given, the LocaleTranslations will not have any translations.
             */
            var translations = LocaleTranslations.ForLanguageCode("non-existing-code");

            Assert.IsTrue(translations.AreCountryNameTranslationsEmpty);
            Assert.IsTrue(translations.AreLanguageTranslationsEmpty);
        }
コード例 #6
0
        public void LocaleNames_Is_loading_from_cache()
        {
            LocaleTranslations.ClearCache();
            var localeName = LocaleTranslations.ForCultureInfo(new CultureInfo("cs-CZ"));

            Assert.IsFalse(localeName.IsFromCache);

            localeName = LocaleTranslations.ForCultureInfo(new CultureInfo("cs-CZ"));

            Assert.IsTrue(localeName.IsFromCache);
        }
コード例 #7
0
ファイル: FactoryTests.cs プロジェクト: jslachta/LocaleNames
        public void LocaleNames_Factory_ForLanguageCode_Test()
        {
            /*
             * if a valid language code is given, the cultureinfo name should match.
             */
            var translations = LocaleTranslations.ForLanguageCode("cs-CZ");

            Assert.AreEqual(new System.Globalization.CultureInfo("cs-CZ"), translations.CultureInfo);
            Assert.IsFalse(translations.AreCountryNameTranslationsEmpty);
            Assert.IsFalse(translations.AreLanguageTranslationsEmpty);
        }
コード例 #8
0
        public void LocaleNames_Find_country_code_by_name()
        {
            var localeNames = LocaleTranslations.ForLanguageCode("en-US");

            Assert.AreEqual("DE", localeNames.FindCountryCode("Germany"));

            Assert.AreEqual("CZ", localeNames.FindCountryCode("Czech Republic"));

            Assert.AreEqual("CZ", localeNames.FindCountryCode("Czechia"));

            Assert.AreEqual("GB", localeNames.FindCountryCode("United Kingdom"));
        }
コード例 #9
0
        public void LocaleNames_Find_language_name_for_language_code()
        {
            var localeNames = LocaleTranslations.ForLanguageCode("en-US");

            Assert.AreEqual("German", localeNames.FindLanguageName("de"));

            Assert.AreEqual("Czech", localeNames.FindLanguageName("cs"));

            Assert.AreEqual("Czech", localeNames.FindLanguageName("cs-CZ"));

            Assert.AreEqual("American English", localeNames.FindLanguageName("en-US"));

            Assert.AreEqual("Chinese, Cantonese", localeNames.FindLanguageName("yue", Enumerations.AltVariant.Menu));
        }
コード例 #10
0
        public void LocaleNames_Find_language_code_by_name()
        {
            var localeNames = LocaleTranslations.ForLanguageCode("en-US");

            Assert.AreEqual("de", localeNames.FindLanguageCode("German"));

            Assert.AreEqual("cs", localeNames.FindLanguageCode("Czech"));

            Assert.AreEqual("en-US", localeNames.FindLanguageCode("American English"));

            Assert.AreEqual("und", localeNames.FindLanguageCode("Unknown language"));

            //TODO: Shouldn't we expect 'und'?
            Assert.AreEqual(null, localeNames.FindLanguageCode("Value not in dictionary"));
        }
コード例 #11
0
        public void LocaleNames_Find_language_name_for_given_culture()
        {
            var localeNames = LocaleTranslations.ForCultureInfo(new CultureInfo("cs-CZ"));

            Assert.AreEqual("angličtina (USA)", localeNames.FindLanguageName("en-US"));

            Assert.AreEqual("němčina (walser)", localeNames.FindLanguageName("wae"));

            Assert.AreEqual("čínština (tradiční)", localeNames.FindLanguageName("zh-Hant"));

            Assert.AreEqual(null, localeNames.FindLanguageName("unknown code"));

            localeNames = LocaleTranslations.ForCultureInfo(new CultureInfo("yue"));

            Assert.AreEqual("德文", localeNames.FindLanguageName("de"));

            Assert.AreEqual("捷克文", localeNames.FindLanguageName("cs"));

            Assert.AreEqual("英文 (美國)", localeNames.FindLanguageName("en-US"));
        }
コード例 #12
0
        public void LocaleNames_Find_language_name_for_unknown_language_code()
        {
            var localeNames = LocaleTranslations.ForLanguageCode("unknown-CODE");

            Assert.AreEqual(null, localeNames.FindLanguageName("de"));
        }