Esempio n. 1
0
        public void Playground()
        {
            var en = Language.EN;           // English language
            var zh = Language.ZH;           // Chinese language

            var latn = Script.Latn;         // Latin script
            var hans = Script.Hans;         // Han (Simplified variant)

            var tw = Region.TW;             // Taiwan, Province of China

            // tag zh-Hans-TW
            var tag1 = new LanguageTag(zh, hans, tw);

            // tag zh-Latn-TW-Pinyin
            var tag2 = new LanguageTag(zh, latn, tw, new [] { Variant.Pinyin });

            // tag en-US-x-twain
            var tag3 = new LanguageTag(en, Region.US, ExtensionSubtag.ForPrivateUse("twain"));

            // tag de-DE-u-co-phonebk
            var tag4 = new LanguageTag(Language.DE, Region.DE, new [] { new ExtensionSubtag('u', "co", "phonebk") });

            var tag5 = LanguageTag.Parse("ru");
            var tag6 = LanguageTag.Parse("zh-Hans-TW");
            var tag7 = LanguageTag.Parse("en-GB-scotland");

            Assert.True(tag1 == tag6);

            // zh-Hans-TW -> zh-Hans
            var tag8 = tag6.Take(LanguageTag.Field.Language | LanguageTag.Field.Script);

            // zh-Hans is subset of zh-Hans-TW
            Assert.True(tag8.IsSubsetOf(tag6));
        }
Esempio n. 2
0
        public void Constructor_LangVarPr()
        {
            var tag1     = new LanguageTag(Language.RU, new [] { Variant.Petr1708 }, ExtensionSubtag.ForPrivateUse("aaa"));
            var tag2     = new LanguageTag(Language.RU, null, null, new [] { Variant.Petr1708 }, new ExtensionSubtag[] {}, ExtensionSubtag.ForPrivateUse("aaa"));
            var expected = LanguageTag.Parse("ru-Petr1708-x-aaa");

            Assert.That(tag1, Is.EqualTo(expected));
            Assert.That(tag2, Is.EqualTo(expected));
        }
Esempio n. 3
0
        public void Constructor_LangScrRegPr()
        {
            var tag1     = new LanguageTag(Language.RU, Script.Latn, Region.RU, ExtensionSubtag.ForPrivateUse("aaa"));
            var tag2     = new LanguageTag(Language.RU, Script.Latn, Region.RU, new Variant[] {}, new ExtensionSubtag[] {}, ExtensionSubtag.ForPrivateUse("aaa"));
            var expected = LanguageTag.Parse("ru-Latn-RU-x-aaa");

            Assert.That(tag1, Is.EqualTo(expected));
            Assert.That(tag2, Is.EqualTo(expected));
        }
Esempio n. 4
0
        public void PrivateUse()
        {
            var ext = ExtensionSubtag.ForPrivateUse("aaa");

            Assert.IsTrue(ext.PrivateUse);
        }
Esempio n. 5
0
        public void Constructor_LangExrPr()
        {
            var tag1     = new LanguageTag(Language.RU, new [] { new ExtensionSubtag('a', "aaa") }, ExtensionSubtag.ForPrivateUse("aaa"));
            var tag2     = new LanguageTag(Language.RU, null, null, new Variant[] {}, new [] { new ExtensionSubtag('a', "aaa") }, ExtensionSubtag.ForPrivateUse("aaa"));
            var expected = LanguageTag.Parse("ru-a-aaa-x-aaa");

            Assert.That(tag1, Is.EqualTo(expected));
            Assert.That(tag2, Is.EqualTo(expected));
        }
Esempio n. 6
0
        public void Constructor_LangScrRegVarExrPr()
        {
            var tag1     = new LanguageTag(Language.RU, Script.Latn, Region.RU, new [] { Variant.Petr1708 }, new [] { new ExtensionSubtag('a', "aaa") }, ExtensionSubtag.ForPrivateUse("aaa"));
            var tag2     = new LanguageTag(Language.RU, Script.Latn, Region.RU, new [] { Variant.Petr1708 }, new [] { new ExtensionSubtag('a', "aaa") }, ExtensionSubtag.ForPrivateUse("aaa"));
            var expected = LanguageTag.Parse("ru-Latn-RU-Petr1708-a-aaa-x-aaa");

            Assert.That(tag1, Is.EqualTo(expected));
            Assert.That(tag2, Is.EqualTo(expected));
        }