예제 #1
0
파일: Loc.cs 프로젝트: Alriac/STL_Showcase
        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
파일: Loc.cs 프로젝트: Alriac/STL_Showcase
        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;
            }
        }