Пример #1
0
        /// <summary>
        /// Creates a <see cref="LocalizationPreference"/> for a tag.
        /// </summary>
        public static LocalizationPreference Tag(string value)
        {
            var pref = new LocalizationPreference();

            pref.Value = value;
            return(pref);
        }
Пример #2
0
        public LocalizerBuilder ForCulture(params string[] cultureNames)
        {
            for (int i = 0; i < cultureNames.Length; i++)
            {
                var cultureName = cultureNames[i];

                int dashIndex;
                if (cultureName == null || cultureName.Length == 0)
                {
                }
                else if (cultureName.Length == 5 && (dashIndex = cultureName.IndexOf('-')) == 2)
                {
                    var pref1 = LocalizationPreference.ForLanguage(cultureName.Substring(0, 2));
                    this.preferences.Add(pref1);
                    var pref2 = LocalizationPreference.ForRegion(cultureName.Substring(3, 2));
                    this.preferences.Add(pref2);
                }
                else if (cultureName.Length == 2)
                {
                    var pref1 = LocalizationPreference.ForLanguage(cultureName);
                    this.preferences.Add(pref1);
                }
                else
                {
                    // NOTE: should we tolerate invalid language codes?
                    var pref1 = LocalizationPreference.ForLanguage(cultureName);
                    this.preferences.Add(pref1);
                }
            }

            return(this);
        }
Пример #3
0
        /// <summary>
        /// Creates a <see cref="LocalizationPreference"/> for the specific dimension.
        /// </summary>
        public static LocalizationPreference ForDimension(string dimension, string value)
        {
            var pref = new LocalizationPreference();

            pref.Dimension = dimension;
            pref.Value     = value;
            return(pref);
        }
Пример #4
0
        /// <summary>
        /// Creates a <see cref="LocalizationPreference"/> for the region dimension.
        /// </summary>
        public static LocalizationPreference ForRegion(string value)
        {
            // NOTE: should we tolerate unknown region codes?
            var pref = new LocalizationPreference();

            pref.Dimension = Constants.RegionDimension;
            pref.Value     = value;
            return(pref);
        }
Пример #5
0
        /// <summary>
        /// Creates a <see cref="LocalizationPreference"/> for the language dimension.
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static LocalizationPreference ForLanguage(string value)
        {
            // NOTE: should we tolerate unknown language codes?
            var pref = new LocalizationPreference();

            pref.Dimension = Constants.LanguageDimension;
            pref.Value     = value;
            return(pref);
        }
Пример #6
0
        public LocalizerBuilder WithDimension(string dimension, params string[] values)
        {
            for (int i = 0; i < values.Length; i++)
            {
                var value = values[i];
                if (string.IsNullOrEmpty(value))
                {
                }
                else
                {
                    var pref1 = LocalizationPreference.ForDimension(dimension, value);
                    this.preferences.Add(pref1);
                }
            }

            return(this);
        }
Пример #7
0
        public LocalizerBuilder WithTag(params string[] tags)
        {
            for (int i = 0; i < tags.Length; i++)
            {
                var tag = tags[i];
                if (string.IsNullOrEmpty(tag))
                {
                }
                else
                {
                    var pref1 = LocalizationPreference.Tag(tag);
                    this.preferences.Add(pref1);
                }
            }

            return(this);
        }