Пример #1
0
        private void getFunctionalEquivalentTestCases(String path, Assembly cl, String resName, String keyword,
                                                      bool truncate, String[] testCases)
        {
            //String F_STR = "f";
            String T_STR = "t";

            bool[] isAvail = new bool[1];

            Logln("Testing functional equivalents...");
            for (int i = 0; i < testCases.Length; i += 3)
            {
                bool         expectAvail  = T_STR.Equals(testCases[i + 0]);
                UCultureInfo inLocale     = new UCultureInfo(testCases[i + 1]);
                UCultureInfo expectLocale = new UCultureInfo(testCases[i + 2]);

                Logln(((int)(i / 3)).ToString(CultureInfo.InvariantCulture) + ": " + expectAvail.ToString() + "\t\t" +
                      inLocale.ToString() + "\t\t" + expectLocale.ToString());

                UCultureInfo equivLocale = ICUResourceBundle.GetFunctionalEquivalent(path, cl, resName, keyword, inLocale, isAvail, truncate);
                bool         gotAvail    = isAvail[0];

                if ((gotAvail != expectAvail) || !equivLocale.Equals(expectLocale))
                {
                    Errln(((int)(i / 3)).ToString(CultureInfo.InvariantCulture) + ":  Error, expected  Equiv=" + expectAvail.ToString() + "\t\t" +
                          inLocale.ToString() + "\t\t--> " + expectLocale.ToString() + ",  but got " + gotAvail.ToString() + " " +
                          equivLocale.ToString());
                }
            }
        }
Пример #2
0
        public void TestSeparateTrees()
        {
            var kw = Collator.Keywords.ToArray();

            if (!assertTrue("getKeywords != null", kw != null))
            {
                return;
            }
            CheckArray("getKeywords", kw, KW);

            String[] kwval = Collator.GetKeywordValues(KW[0]);
            if (!assertTrue("getKeywordValues != null", kwval != null))
            {
                return;
            }
            CheckArray("getKeywordValues", kwval, KWVAL);

            bool[]       isAvailable = new bool[1];
            UCultureInfo equiv       = Collator.GetFunctionalEquivalent(KW[0],
                                                                        new UCultureInfo("de"),
                                                                        isAvailable);

            if (assertTrue("getFunctionalEquivalent(de)!=null", equiv != null))
            {
                assertEquals("getFunctionalEquivalent(de)", "root", equiv.ToString());
            }
            assertTrue("getFunctionalEquivalent(de).isAvailable==true",
                       isAvailable[0] == true);

            equiv = Collator.GetFunctionalEquivalent(KW[0],
                                                     new UCultureInfo("de_DE"),
                                                     isAvailable);
            if (assertTrue("getFunctionalEquivalent(de_DE)!=null", equiv != null))
            {
                assertEquals("getFunctionalEquivalent(de_DE)", "root", equiv.ToString());
            }
            assertTrue("getFunctionalEquivalent(de_DE).isAvailable==false",
                       isAvailable[0] == false);

            equiv = Collator.GetFunctionalEquivalent(KW[0], new UCultureInfo("zh_Hans"));
            if (assertTrue("getFunctionalEquivalent(zh_Hans)!=null", equiv != null))
            {
                assertEquals("getFunctionalEquivalent(zh_Hans)", "zh", equiv.ToString());
            }
        }
Пример #3
0
            public override string GetDisplayName(string id, UCultureInfo locale)
            {
                string prefix = "";
                string suffix = "";
                string ls     = locale.ToString();

                if (LocaleUtility.IsFallbackOf(californio, ls))
                {
                    if (ls.Equals(valley, StringComparison.OrdinalIgnoreCase))
                    {
                        prefix = "Like, you know, it's so totally ";
                    }
                    else if (ls.Equals(surfer, StringComparison.OrdinalIgnoreCase))
                    {
                        prefix = "Dude, its ";
                    }
                    else if (ls.Equals(geek, StringComparison.OrdinalIgnoreCase))
                    {
                        prefix = "I'd estimate it's approximately ";
                    }
                    else
                    {
                        prefix = "Huh?  Maybe ";
                    }
                }
                if (LocaleUtility.IsFallbackOf(californio, id))
                {
                    if (id.Equals(valley, StringComparison.OrdinalIgnoreCase))
                    {
                        suffix = "like the Valley, you know?  Let's go to the mall!";
                    }
                    else if (id.Equals(surfer, StringComparison.OrdinalIgnoreCase))
                    {
                        suffix = "time to hit those gnarly waves, Dude!!!";
                    }
                    else if (id.Equals(geek, StringComparison.OrdinalIgnoreCase))
                    {
                        suffix = "all systems go.  T-Minus 9, 8, 7...";
                    }
                    else
                    {
                        suffix = "No Habla Englais";
                    }
                }
                else
                {
                    suffix = base.GetDisplayName(id, locale);
                }

                return(prefix + suffix);
            }
Пример #4
0
 public override ICollection <string> GetSupportedLocaleIDs()
 {
     if (ids == null)
     {
         HashSet <string> set = new HashSet <string>();
         using (var iter = map.Keys.GetEnumerator())
         {
             while (iter.MoveNext())
             {
                 UCultureInfo locale = (UCultureInfo)iter.Current;
                 String       id     = locale.ToString();
                 set.Add(id);
             }
             ids = (set).AsReadOnly();
         }
     }
     return(ids);
 }
Пример #5
0
 protected override object HandleCreate(UCultureInfo loc, int kind, ICUService service)
 {
     return(factoryID + loc.ToString());
 }
Пример #6
0
 public override string GetDisplayName(string idForDisplay, UCultureInfo locale)
 {
     return((visible && idForDisplay.Equals(this.id)) ? "(" + locale.ToString() + ") " + idForDisplay : null);
 }