GetLanguages() public static method

Get all language strings on a given key.
public static GetLanguages ( string key, List supportedLanguages = null ) : List
key string
supportedLanguages List
return List
示例#1
0
        public static bool KeyExist(string key)
        {
            var languages = LocalizationImporter.GetLanguages(key);
            var selected  = (int)Instance.selectedLanguage;

            return(languages.Count > 0 && Instance.selectedLanguage >= 0 && selected < languages.Count);
        }
示例#2
0
        public static string Get(string key, Language language)
        {
            var languages = LocalizationImporter.GetLanguages(key);
            var selected  = (int)language;

            if (languages.Count > 0 && selected >= 0 && selected < languages.Count)
            {
                var currentString = languages[selected];
                if (string.IsNullOrEmpty(currentString) || LocalizationImporter.IsLineBreak(currentString))
                {
                    Debug.LogWarning("Could not find key " + key + " for current language " + language + ". Falling back to " + Instance.fallbackLanguage + " with " + languages[(int)Instance.fallbackLanguage]);
                    selected      = (int)Instance.fallbackLanguage;
                    currentString = languages[selected];
                }

    #if ARABSUPPORT_ENABLED
                if (selected == (int)Language.Arabic)
                {
                    return(ArabicSupport.ArabicFixer.Fix(currentString));
                }
    #endif

                return(currentString);
            }

            return(string.Format(KeyNotFound, key));
        }
示例#3
0
        public static string Get(string key, Language language)
        {
            var languages = LocalizationImporter.GetLanguages(key);
            var selected  = (int)language;

            if (languages.Count > 0 && selected >= 0 && selected < languages.Count)
            {
                var currentString = languages[selected];
                if (string.IsNullOrEmpty(currentString) || LocalizationImporter.IsLineBreak(currentString))
                {
                    Debug.LogWarning("Could not find key " + key + " for current language " + language + ". Falling back to " + Instance.fallbackLanguage + " with " + languages[(int)Instance.fallbackLanguage]);
                    // EDIT: Cytoid
                    // Default Fujaoese to Simplified Chinese
                    selected      = language == Language.Fujaoese ? (int)Language.Simplified_Chinese : (int)Instance.fallbackLanguage;
                    currentString = languages[selected];
                }

    #if ARABSUPPORT_ENABLED
                if (selected == (int)Language.Arabic)
                {
                    return(ArabicSupport.ArabicFixer.Fix(currentString, instance.showTashkeel, instance.useHinduNumbers));
                }
    #endif

                return(currentString);
            }

            return(string.Format(KeyNotFound, key));
        }
示例#4
0
        /// <summary>
        /// Retreives the correct language string by key.
        /// </summary>
        /// <param name="key">The key string</param>
        /// <returns>A localized string</returns>
        public static string Get(string key)
        {
            var languages = LocalizationImporter.GetLanguages(key);
            var selected  = (int)Instance.selectedLanguage;

            if (languages.Count > 0 && Instance.selectedLanguage >= 0 && selected < languages.Count)
            {
                var currentString = languages[selected];
                if (string.IsNullOrEmpty(currentString) || LocalizationImporter.IsLineBreak(currentString))
                {
                    Debug.LogWarning("Could not find key " + key + " for current language " + Instance.selectedLanguage + ". Falling back to " + Instance.fallbackLanguage + " with " + languages[(int)Instance.fallbackLanguage]);
                    currentString = languages[(int)Instance.fallbackLanguage];
                }
                return(currentString);
            }

            return(string.Format(KeyNotFound, key));
        }