Example #1
0
    public string ToLocalized(string strRef, BalloonLanguageCode languageCode, params object[] args)
    {
        var key   = "";
        var index = -1;
        var ret   = strRef;

        if (ParseStrRef(strRef, out key, out index))
        {
            switch (languageCode)
            {
            case BalloonLanguageCode.En:
                ret = LookupLocalizedDictionary(key, index, Data.dataSet.StrEnData, strRef, languageCode);
                break;

            case BalloonLanguageCode.Ko:
            default:
                ret = LookupLocalizedDictionary(key, index, Data.dataSet.StrKoData, strRef, languageCode);
                break;
            }
        }
        else
        {
            Debug.LogWarningFormat("Localized string ref cannot be parsed: {0}", strRef);
        }

        if (args != null && args.Length > 0)
        {
            return(string.Format(ret, args));
        }
        return(ret);
    }
Example #2
0
    void ChangeLanguageBySystemLanguage()
    {
        switch (Application.systemLanguage)
        {
        case SystemLanguage.Korean:     //korean
            CurrentLanguageCode = BalloonLanguageCode.Ko;
            break;

        default:
            CurrentLanguageCode = BalloonLanguageCode.En;
            break;
        }
    }
Example #3
0
    public Font GetLanguageFont(BalloonLanguageCode languageCode)
    {
        switch (languageCode)
        {
        case BalloonLanguageCode.Ko:
            return(koreanFont);

        case BalloonLanguageCode.Ja:
            return(japaneseFont);

        case BalloonLanguageCode.Ch:
            return(simplifiedChineseFont);

        case BalloonLanguageCode.Tw:
            return(traditionalChineseFont);

        default:
            return(koreanFont);
        }
    }
Example #4
0
    string LookupLocalizedDictionary <T>(string key, int index, Dictionary <ScString, T> strBaseData, string strRef,
                                         BalloonLanguageCode languageCode) where T : StrBaseData
    {
        T strData;

        if (strBaseData.TryGetValue(key, out strData))
        {
            if (index - 1 >= 0 && index - 1 < strData.str.Length)
            {
                return(((string)strData.str[index - 1]).Replace(@"\n", "\n"));
            }
            Debug.LogErrorFormat("Invalid localized string index: key:{0} index:{1} on language code {2}.", key, index,
                                 languageCode);
        }
        else
        {
            Debug.LogWarningFormat("Invalid localized string key: key:{0}/index:{1} on language code {2}", key, index,
                                   languageCode);
        }

        return(strRef);
    }