コード例 #1
0
    static public string Translate(string key, string code)
    {
        VerifyLanguageCode(code);

        Dictionary <string, string> languageDict;

        if (!allLanguages.TryGetValue(code, out languageDict))
        {
            if (code.Equals("en"))
            {
                return(key);
            }
            return(Translate(key, "en"));
        }

        try{
            string value = languageDict[key];
            if (value == null)
            {
                if (code.Equals("en"))
                {
                    return(key);
                }
                return(Translate(key, "en"));
            }
            return(PlanetUnityOverride.appProcessString(value));
        }catch {
            //Debug.Log ("Language key " + key + " does not exist");
        }

        return(PlanetUnityOverride.appProcessString(key));
    }
コード例 #2
0
    public static string processString(object cur, object o, string s)
    {
        if (s == null)
        {
            return(null);
        }

                #if USE_LAURETTE
        s = s.Replace("@LANGUAGE", Localizations.GetLanguageCode());
                #endif
        s = s.Replace("\\n", "\n");

        if (s.Equals("nan"))
        {
            return("0");
        }

        if (s.StartsWith("@localization("))
        {
                        #if USE_LAURETTE
            string evalListString = s.Substring(14, s.Length - 15);
            s = Localizations.TranslateKey(evalListString);
                        #endif
        }
        else if (s.StartsWith("@eval("))
        {
            string evalListString = s.Substring(6, s.Length - 7);
            s = evaluateString(evalListString, o, 1.0f);

            PUGameObject current = cur as PUGameObject;
            if (current != null)
            {
                foreach (var token in mathParser.usedTokens)
                {
                    current.Canvas.GetVariable(token).AddListener(current);
                }
            }
        }
        else if (s.StartsWith("@dpi("))
        {
            string evalListString = s.Substring(5, s.Length - 6);
            s = evaluateString(evalListString, o, PlanetUnityOverride.screenDPI());
        }
        else if (s.StartsWith("@app1("))
        {
            string evalListString = s.Substring(6, s.Length - 7);
            s = evaluateString(evalListString, o, PlanetUnityOverride.screenDPI(), PlanetUnityOverride.app1);
        }

        return(PlanetUnityOverride.appProcessString(s));
    }
コード例 #3
0
    public static string processString(object o, string s)
    {
        if (s == null)
        {
            return(null);
        }

                #if USE_LAURETTE
        s = s.Replace("@LANGUAGE", Localizations.GetLanguageCode());
                #endif
        s = s.Replace("\\n", "\n");

        if (s.Equals("nan"))
        {
            return("0");
        }

        if (s.StartsWith("@localization("))
        {
                        #if USE_LAURETTE
            string evalListString = s.Substring(14, s.Length - 15);
            s = Localizations.TranslateKey(evalListString);
                        #endif
        }
        else if (s.StartsWith("@eval("))
        {
            string evalListString = s.Substring(6, s.Length - 7);
            s = evaluateString(evalListString, o, 1.0f);
        }
        else if (s.StartsWith("@dpi("))
        {
            string evalListString = s.Substring(5, s.Length - 6);
            s = evaluateString(evalListString, o, PlanetUnityOverride.screenDPI());
        }
        else if (s.StartsWith("@app1("))
        {
            string evalListString = s.Substring(6, s.Length - 7);
            s = evaluateString(evalListString, o, PlanetUnityOverride.screenDPI(), PlanetUnityOverride.app1);
        }

        return(PlanetUnityOverride.appProcessString(s));
    }
コード例 #4
0
    public static string processString(object o, string s)
    {
        if (s == null)
        {
            return(null);
        }

        s = s.Replace("@LANGUAGE", PlanetUnityLanguage.LanguageCode());
        s = s.Replace("\\n", "\n");

        if (s.Equals("nan"))
        {
            return("0");
        }

        if (s.StartsWith("@eval("))
        {
            string evalListString = s.Substring(6, s.Length - 7);
            s = evaluateString(evalListString, o, 1.0f);
        }
        else if (s.StartsWith("@dpi("))
        {
            string evalListString = s.Substring(5, s.Length - 6);
            s = evaluateString(evalListString, o, PlanetUnityOverride.screenDPI());
        }
        else if (s.StartsWith("@app1("))
        {
            string evalListString = s.Substring(6, s.Length - 7);
            s = evaluateString(evalListString, o, PlanetUnityOverride.screenDPI(), PlanetUnityOverride.app1);
        }
        else if (s.StartsWith("@"))
        {
            string localizedString = PlanetUnityLanguage.Translate(s);
            if (localizedString.Equals(s) == false)
            {
                return(PlanetUnityOverride.appProcessString(localizedString));
            }
        }

        return(PlanetUnityOverride.appProcessString(s));
    }