public void SetThreadLocale(LocaleData locale)
        {
            if (locale == null)
                throw new ArgumentNullException("locale");

            RequestContext.SetValue(RequestContext.LocaleKey, locale);
            Thread.CurrentThread.CurrentUICulture = locale.Culture;
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(locale.Culture.Name);
        }
        public void Init(LocaleData[] supportedLocales, LocaleData defaultLocale)
        {
            if (supportedLocales == null)
                throw new ArgumentNullException("supportedLocales");

            if (defaultLocale == null)
                throw new ArgumentNullException("defaultLocale");

            foreach (var supportedLocale in supportedLocales)
                SupportedLocalesInternal.Add(supportedLocale);
            _defaultLocale = defaultLocale;
        }
Example #3
0
 private void SaveLocale(LocaleData data)
 {
     if (data != null)
     {
         if (data.Id > 0)
         {
             this.LocaleManager.Update(data);
         }
         else
         {
             this.LocaleManager.Add(data);
         }
     }
 }
Example #4
0
    private string GetFallbackLoc(List<LocaleData> locales, LocaleData data)
    {
        string fallbackLoc = string.Empty;
        if (0 == data.FallbackId)
        {
            if (this.defaultLangId == data.Id)
            {
                fallbackLoc = this.msgNone;
            }
            else
            {
                fallbackLoc = this.defaultLangLoc;
            }
        }
        else if (data.FallbackId == data.Id)
        {
            fallbackLoc = this.msgNone;
        }
        else
        {
            LocaleData fallbackData = this.LocaleManager.FindLocale(locales, data.FallbackId);
            fallbackLoc = (fallbackData != null ? fallbackData.Loc : data.FallbackId.ToString());
        }

        return fallbackLoc;
    }