/// <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(); }
public static void SetDefaultCulture() { if (!isInit) { throw new NotInitializedException(typeof(LocalizationManager)); } CurrentTranslation = null; IsDefaultCulture = true; PluralForm = PluralFormGenerator.CreateForm(defaultCulture); OnCultureChange?.Invoke(); }
private void NotifyCultureChanged() => OnCultureChange?.Invoke();