private string GetCountryCodeSuffixForPropertiesFile(SystemLanguage langauge) { if (language != SystemLanguage.English) { return("_" + LanguageHelper.Get2LetterIsoCodeFromSystemLanguage(language).ToLower()); } else { return(""); } }
private void Start() { Text uiText = GetComponent <Text>(); if (TranslationManager.Instance == null) { uiText.text = "No TranslationManager"; return; } List <string> translatedLanguages = TranslationManager.Instance.GetTranslatedLanguages() .Select(systemLanguage => LanguageHelper.Get2LetterIsoCodeFromSystemLanguage(systemLanguage)) .ToList(); uiText.text = "Translated languages: " + string.Join(", ", translatedLanguages); }
private static void OnPostprocessAllAssets( string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { TranslationManager translationManager = TranslationManager.Instance; if (translationManager == null) { return; } string currentLanguagePropertiesFileNameSuffix = translationManager.currentLanguage != translationManager.defaultPropertiesFileLanguage ? "_" + LanguageHelper.Get2LetterIsoCodeFromSystemLanguage(translationManager.currentLanguage, "en").ToLowerInvariant() : ""; string currentLanguagePropertiesFileName = translationManager.propertiesFileName + currentLanguagePropertiesFileNameSuffix + ".properties"; string fallbackLanguagePropertiesFileName = translationManager.propertiesFileName + ".properties"; bool currentTranslationsUpdated = false; bool fallbackTranslationsUpdated = false; string[][] pathArrays = { importedAssets, deletedAssets, movedAssets }; foreach (string[] pathArray in pathArrays) { foreach (string path in pathArray) { if (path.EndsWith(fallbackLanguagePropertiesFileName)) { if (translationManager.LogInfoNow) { Debug.Log("Reloading default language translations because of changed file: " + path); } translationManager.ClearFallbackLanguageTranslations(); fallbackTranslationsUpdated = true; } else if (path.EndsWith(currentLanguagePropertiesFileName)) { if (translationManager.LogInfoNow) { Debug.Log("Reloading current language translations because of changed file: " + path); } translationManager.ClearCurrentLanguageTranslations(); currentTranslationsUpdated = true; } if (currentTranslationsUpdated && fallbackTranslationsUpdated) { // All languages have been updated already. break; } } } if (currentTranslationsUpdated || fallbackTranslationsUpdated) { translationManager.UpdateTranslatorsInScene(); } if (translationManager.generateConstantsOnResourceChange && fallbackTranslationsUpdated) { CreateTranslationConstantsMenuItems.CreateTranslationConstants(); } }