示例#1
0
        public void SetLanguage(string newLanguage)
        {
            CultureInfo ci = CultureInfo.CurrentUICulture;

            if (!LoadedLanguages.Contains(newLanguage))
            {
                return;
            }

            IUserSettings settings = DefaultFactory.GetDefaultUserSettings();

            settings.SetSettingString(Shared.Enums.UserSettingEnum.Language, newLanguage);

            CurrentLanguage = newLanguage;
            OnLanguageChanged?.Invoke(newLanguage);
        }
示例#2
0
 public override void LoadLanguage(string language = null)
 {
     if (language == null)
     {
         language = TranslationLoader.CurrentLanguage;
     }
     if (AvailableLanguages.Contains(language) && !LoadedLanguages.Contains(language))
     {
         foreach (var assembly in Files.Keys)
         {
             var files = Files[assembly].Where(f => f.Contains($".{language}.")).ToList();
             files.ForEach(f => LoadFile(f, assembly, language));
         }
     }
     _loaded.Add(language);
     Translate.AddLoaded(language);
 }
示例#3
0
        private Loc()
        {
            _Ins = this;
            CultureInfo ci = CultureInfo.CurrentUICulture;

            LoadTexts();

            IUserSettings settings = DefaultFactory.GetDefaultUserSettings();

            CurrentLanguage = settings.GetSettingString(Shared.Enums.UserSettingEnum.Language);

            if (string.IsNullOrEmpty(CurrentLanguage))
            {
                logger.Info("Localization: Missing saved language. Setting system language '{0}'", ci.TwoLetterISOLanguageName);
                CurrentLanguage = ci.TwoLetterISOLanguageName;
            }

            if (!LoadedLanguages.Contains(CurrentLanguage))
            {
                logger.Info("Localization: Missing current language '{0}'", CurrentLanguage);
                CurrentLanguage = DefaultLanguage;
            }
        }