public string Get(string lang, string key)
        {
#if DEBUG
            if (!AllLanguages.ContainsKey(lang))
            {
                Log.Error($"Translation: Unknown language {lang}");
                return(key);
            }
#endif

            // Try find translation in the current language first
            if (AllLanguages[lang].TryGetValue(key, out string ret))
            {
                return(ret);
            }

            // If not found, try also get translation in the default English
            // Untranslated keys are prefixed with ¶ in TEST & DEBUG builds;
            // in STABLE builds prefix (upto and including `:`) is trimmed.
            return(AllLanguages[Translation.DEFAULT_LANGUAGE_CODE]
                   .TryGetValue(key, out string ret2)
                       ? ret2
                       : (VersionUtil.BRANCH != "STABLE")
                            ? "¶" + key
                            : key.IndexOf(":") > 0
                                ? key.Substring(key.IndexOf(":") + 1)
                                : key);
        }
예제 #2
0
파일: LookupTable.cs 프로젝트: me22/TMPE
        public string Get(string lang, string key)
        {
#if DEBUG
            if (!AllLanguages.ContainsKey(lang))
            {
                Log.Error($"Translation: Unknown language {lang}");
                return(key);
            }
#endif

            // Try find translation in the current language first
            if (AllLanguages[lang].TryGetValue(key, out string ret))
            {
                return(ret);
            }

            // If not found, try also get translation in the default English
            // Untranslated keys are prefixed with ¶
            return(AllLanguages[Translation.DEFAULT_LANGUAGE_CODE]
                   .TryGetValue(key, out string ret2)
                       ? ret2
                       : "¶" + key);
        }