Ejemplo n.º 1
0
    static string[] getRowData(LocaleIdentifier locId)
    {
        var locStr = locId.ToString();
        var loc    = new Locale(locId);
        var values = new string[count];

        Func <string, string> normalize = (string str) => {
            // wrong i
            if (locStr == "be-Cyrl-BY")
            {
                str = str.Replace('i', 'і');
            }
            // convert \u00FF part of CLDR string to char
            return(decodeUnicodeLiteral(str));
        };

        // **** CALENDAR
        XPathNavigator gregorian;

        gregorian = loc.FindOrDefault("//calendar[@type=\"gregorian\"]//monthContext[@type=\"stand-alone\"]/monthWidth[@type=\"wide\"]");
        if (gregorian != null)
        {
            gregorian.Select("./*/text()").Cast <object>().Select(o => normalize(o.ToString())).ToArray(values, monthsIdx);
        }

        gregorian = loc.FindOrDefault("//calendar[@type=\"gregorian\"]//monthContext[@type=\"format\"]/monthWidth[@type=\"wide\"]");
        if (gregorian != null)
        {
            gregorian.Select("./*/text()").Cast <object>().Select(o => normalize(o.ToString())).ToArray(values, smonthsIdx);
        }

        gregorian = loc.FindOrDefault("//calendar[@type=\"gregorian\"]//dayContext[@type=\"stand-alone\"]/dayWidth[@type=\"wide\"]");
        if (gregorian != null && loc.ToString() != "lrc-Arab-IQ" && loc.ToString() != "lrc-Arab-IR" && loc.ToString() != "mzn-Arab-IR")
        {
            gregorian.Select("./*/text()").Cast <object>().Select(o => normalize(o.ToString())).ToArray(values, daysIdx);
        }

        gregorian = loc.FindOrDefault("//calendar[@type=\"gregorian\"]//dayContext[@type=\"format\"]/dayWidth[@type=\"wide\"]");
        if (gregorian != null && loc.ToString() != "lrc-Arab-IQ" && loc.ToString() != "lrc-Arab-IR" && loc.ToString() != "mzn-Arab-IR")
        {
            gregorian.Select("./*/text()").Cast <object>().Select(o => normalize(o.ToString())).ToArray(values, sdaysIdx);
        }


        // **** SPELL NUMBERS
        try {
            var spell = SpellingFormatter.Create(loc, new SpellingOptions {
                Style = SpellingStyle.Cardinal
            });
            numsSource.Select(n => normalize(spell.Format(n))).ToArray(values, numsIdx);
        } catch { }
        try {
            var spell = SpellingFormatter.Create(loc, new SpellingOptions {
                Style = SpellingStyle.Ordinal
            });
            numsSource.Select(n => normalize(spell.Format(n))).ToArray(values, snumsIdx);
        } catch { }

        return(values);
    }
Ejemplo n.º 2
0
 public override void PushHeader(StringTableCollection collection, out string header, out string headerNote)
 {
     header     = $"{LocaleIdentifier.ToString()} Comments";
     headerNote = null;
 }
Ejemplo n.º 3
0
        public void OnEnable()
        {
            m_root = rootVisualElement;

            // Import UXML
            var asset = Resources.GetTemplateAsset(nameof(CustomLocaleUIWindow));

            asset.CloneTree(m_root);

            var localeName       = m_root.Q <TextField>("customLocaleUI_localeName");
            var localeIdentifier = m_root.Q <TextField>("customLocaleUI_localeIdentifier");

            localeIdentifier.RegisterValueChangedCallback(evt =>
            {
                var enableCreateBTN = true;
                var cultures        = CultureInfo.GetCultures(CultureTypes.AllCultures);
                var locales         = LocalizationEditorSettings.GetLocales();
                var localeIDName    = localeIdentifier.value;
                foreach (var culture in cultures)
                {
                    if (culture.Name == localeIdentifier.value && localeIdentifier.value.Length > 1)
                    {
                        enableCreateBTN = false;
                        localeIDName    = culture.ToString();
                    }
                }

                for (int i = 0; i < (int)SystemLanguage.Unknown; ++i)
                {
                    var localeID = new LocaleIdentifier((SystemLanguage)i);
                    if (localeID.Code == localeIdentifier.value && localeIdentifier.value.Length > 1)
                    {
                        enableCreateBTN = false;
                        localeIDName    = localeID.ToString();
                    }
                }

                foreach (var availableLocale in locales)
                {
                    if (availableLocale.Identifier.Code == localeIdentifier.value && localeIdentifier.value.Length > 1)
                    {
                        enableCreateBTN = false;
                        localeIDName    = availableLocale.name;
                    }
                }

                m_createButton.SetEnabled(enableCreateBTN);
                if (!enableCreateBTN)
                {
                    if (m_helpBox == null)
                    {
                        AddHelpInfo(localeIDName);
                    }
                }
                else
                {
                    if (m_helpBox != null)
                    {
                        m_root.Remove(m_helpBox);
                        m_helpBox = null;
                    }
                }
            });
            m_createButton = m_root.Q <Button>("customLocaleUI_CreateBTN");
            m_createButton.clickable.clicked += () =>
            {
                CreateCustomLocale(localeName.value, localeIdentifier.value);
            };
        }