private string GetCulture(DialogContext dc)
        {
            if (!string.IsNullOrEmpty(dc.Context.Activity.Locale))
            {
                return(dc.Context.Activity.Locale);
            }

            return(DefaultLocale != null?DefaultLocale.GetValue(dc.State) : English);
        }
        private string DetermineCulture(DialogContext dc, FindChoicesOptions opt = null)
        {
            // Note: opt.Locale and Default locale will be considered for deprecation as part of 4.13.
            var candidateLocale = dc.GetLocale() ?? opt?.Locale ?? DefaultLocale?.GetValue(dc.State);
            var culture         = PromptCultureModels.MapToNearestLanguage(candidateLocale);

            if (string.IsNullOrEmpty(culture) || !DefaultChoiceOptions.ContainsKey(culture))
            {
                culture = English;
            }

            return(culture);
        }
Example #3
0
        private void InitializeLocales()
        {
            AvailableLocales  = new List <InstalledLocales.Locale>(InstalledLocales.Instance.Locales).AsReadOnly();
            AvailableCultures = CollectionUtils.Map <InstalledLocales.Locale, CultureInfo>(AvailableLocales, x => x.GetCultureInfo()).AsReadOnly();
            DefaultLocale     = InstalledLocales.Instance.Default;
            DefaultCulture    = DefaultLocale.GetCultureInfo();

            foreach (var locale in AvailableLocales)
            {
                _dropDown.Items.Add(locale);
            }
            _dropDown.SelectedItem = InstalledLocales.Instance.Selected;
        }
Example #4
0
        /// <summary>
        /// Loads all translations for the given locale from the folder
        /// with the name of the locale.
        /// </summary>
        private void LoadTranslations(Locale locale)
        {
            Translation <Locale, Key> translation = Translation <Locale, Key> .Load(this, locale);

            if (translation == null)
            {
                return;
            }
            translation.Localizer = this;
            Translations[locale.ToInt32(null)] = translation;
            if (BaseLocale.Equals(locale))
            {
                BaseTranslation = translation;
            }
            if (DefaultLocale.Equals(locale))
            {
                DefaultTranslation = translation;
            }
        }
 private string GetCulture(DialogContext dc)
 {
     // Note: Default locale will be considered for deprecation as part of 4.13.
     return(dc.GetLocale() ?? DefaultLocale?.GetValue(dc.State) ?? string.Empty);
 }
        private string DetermineCulture(DialogContext dc, FindChoicesOptions opt = null)
        {
            var culture = PromptCultureModels.MapToNearestLanguage(dc.Context.Activity.Locale ?? opt?.Locale ?? DefaultLocale?.GetValue(dc.State));

            if (string.IsNullOrEmpty(culture) || !DefaultChoiceOptions.ContainsKey(culture))
            {
                culture = English;
            }

            return(culture);
        }