示例#1
0
        /// <summary>
        /// Set any translation from 'Translations' property
        /// </summary>
        /// <param name="translation"></param>
        public static void SetCulture(TranslationInfo translation)
        {
            if (!isInit)
            {
                throw new NotInitializedException(typeof(LocalizationManager));
            }

            if (!Translations.Contains(translation))
            {
                throw new CultureNotFoundException($"Invalid translation: '{translation.TranslationName}', with culture: '{translation.CultureInfo.Name}'");
            }

            if (CurrentTranslation == translation)
            {
                Debug.LogWarning("You are trying to switch to the current culture.");
                return;
            }

            CurrentTranslation = translation;
            IsDefaultCulture   = false;

            PluralForm = PluralFormGenerator.CreateForm(CurrentTranslation.CultureInfo);

            var translationDictionary = translationDatabase.GetTranslationDictionary(CurrentTranslation);

            LocalizationCache.Init(translationDictionary);

            OnCultureChange?.Invoke();
        }
示例#2
0
        public static void SetDefaultCulture()
        {
            if (!isInit)
            {
                throw new NotInitializedException(typeof(LocalizationManager));
            }

            CurrentTranslation = null;
            IsDefaultCulture   = true;

            PluralForm = PluralFormGenerator.CreateForm(defaultCulture);

            OnCultureChange?.Invoke();
        }
示例#3
0
 private void NotifyCultureChanged() => OnCultureChange?.Invoke();