예제 #1
0
        /// <summary>
        /// Reset Builder's internal state with the given language tag
        /// </summary>
        public InternalLocaleBuilder SetLanguageTag(LanguageTag langtag)
        {
            Clear();
            if (langtag.GetExtlangs().Count > 0)
            {
                _language = langtag.GetExtlangs()[0];
            }
            else
            {
                string language = langtag.GetLanguage();
                if (!language.Equals(LanguageTag.UNDETERMINED))
                {
                    _language = language;
                }
            }
            _script = langtag.GetScript();
            _region = langtag.GetRegion();

            IList <string> bcpVariants = langtag.GetVariants();

            if (bcpVariants.Count > 0)
            {
                StringBuilder var = new StringBuilder(bcpVariants[0]);
                for (int i = 1; i < bcpVariants.Count; i++)
                {
                    var.Append(BaseLocale.SEP).Append(bcpVariants[i]);
                }
                _variant = var.ToString();
            }

            SetExtensions(langtag.GetExtensions(), langtag.GetPrivateuse());

            return(this);
        }