private static void AddResource(string resInfo, LangType lang, string name, LangProperties lp) { Dictionary <string, Dictionary <string, LangProperties> > dictionary; Dictionary <string, LangProperties> dictionary2; LangProperties properties = null; if (m_Resources.TryGetValue(resInfo, out dictionary)) { if (dictionary.TryGetValue(lang.ToString(), out dictionary2)) { if (dictionary2.TryGetValue(name, out properties)) { dictionary2[name] = lp; } else { dictionary2.Add(name, lp); } } else { dictionary2 = new Dictionary <string, LangProperties>(); dictionary2.Add(name, lp); dictionary.Add(lang.ToString(), dictionary2); } } else { dictionary2 = new Dictionary <string, LangProperties>(); dictionary2.Add(name, lp); dictionary = new Dictionary <string, Dictionary <string, LangProperties> >(); dictionary.Add(lang.ToString(), dictionary2); m_Resources.Add(resInfo, dictionary); } }
public static void LangLoad() { string jsonString; #if UNITY_ANDROID && !UNITY_EDITOR string path = Path.Combine(Application.streamingAssetsPath, "Languages/" + LangType.ToString().ToLower() + ".json"); WWW reader = new WWW(path); while (!reader.isDone) { } jsonString = reader.text.Trim(); #else jsonString = File.ReadAllText(Application.streamingAssetsPath + "/Languages/" + LangType.ToString().ToLower() + ".json"); #endif try { Language = JsonUtility.FromJson <Language>(jsonString); } catch (System.Exception ex) { GameObject.Find("InfoText").GetComponent <UnityEngine.UI.Text>().text = ex.ToString(); } if (ChangeLanguage != null) { ChangeLanguage(); } }
public static void SwitchTo(Lang.LangType type) { _type = type; if (_type == LangType.English) { InitEnglish(); } if (_type == LangType.Russia) { InitRissian(); } PlayerPrefs.SetString("LangType", _type.ToString()); }
private static int GetCurrentCultureId() { int currentCultureId = 0; string culture = _currentLang.ToString().Replace("_", "-"); for (int i = 0; i < SupportedCultureNames.Length; i++) { if (SupportedCultureNames[i].ToLower() == culture.ToLower()) { currentCultureId = i; break; } } return(currentCultureId); }
private static ISnippetCompiler getCompilerForLanguage(LangType langType) { switch (langType) { case LangType.L_TEXT: case LangType.L_CS: return(new CSharpCompiler()); case LangType.L_VB: return(new VBCompiler()); default: throw new Exception("No compiler for language " + langType.ToString()); } }
public static string Translate(string text, LangType langType = LangType.zh) { lock (Lockobject) { if (langType == LangType.zh) { return(text); } var strArray = SplitStrings(text); string result = string.Empty; foreach (var str in strArray) { result += TransApi.GetTransResult(str, LangType.auto.ToString(), langType.ToString()); } return(string.IsNullOrWhiteSpace(result) ? text : result); } }
/// <summary> /// 得到用户基本信息 /// </summary> /// <param name="openid"></param> /// <param name="lang"></param> /// <param name="access_token"></param> /// <returns></returns> public static UserInfo GetUserInfo(string openid, LangType lang, string access_token) { string url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token="; url = url + access_token + "&openid=" + openid + "&lang=" + lang.ToString(); var json = Util.HttpGet2(url); if (json.IndexOf("errcode") > 0) { var ui = new UserInfo(); ui.openid = openid; ui.error = Util.JsonTo <ReturnCode>(json); return(ui); } else { return(Util.JsonTo <UserInfo>(json)); } }
public static string getTemplate(LangType language) { lock (templates.SyncRoot) { if (templates[language] == null) { string path = @"plugins/SnippetExecutor/templates/" + language.ToString() + ".txt"; string ret = loadTemplate(path); if (ret == null) { throw new Exception("No template for " + System.IO.Path.GetFullPath(path)); } templates[language] = ret; return(ret); } else { return((string)templates[language]); } } }
private static LangProperties GetLangProperties(string path, LangType lang) { LangProperties properties = null; int length = path.LastIndexOf('.'); if (length != -1) { Dictionary <string, Dictionary <string, LangProperties> > dictionary; Dictionary <string, LangProperties> dictionary2; string moduleName = path.Substring(0, length); string key = path.Remove(0, length + 1); string str3 = ResourceInfo(moduleName, Thread.CurrentThread.CurrentCulture.Name); LoadResources(); if ((m_Resources.TryGetValue(str3, out dictionary) && dictionary.TryGetValue(lang.ToString(), out dictionary2)) && !dictionary2.TryGetValue(key, out properties)) { LangProperties properties2 = null; if (dictionary2.TryGetValue(m_inheritName, out properties2)) { key = properties2.GetItem(PropertyType.Inherit, key); if (key.Length != 0) { dictionary2.TryGetValue(key, out properties); } } } } return(properties); }
private static bool FindResource(string resInfo, LangType lang, string name, ref LangProperties lp) { Dictionary <string, Dictionary <string, LangProperties> > dictionary; Dictionary <string, LangProperties> dictionary2; return((m_Resources.TryGetValue(resInfo, out dictionary) && dictionary.TryGetValue(lang.ToString(), out dictionary2)) && dictionary2.TryGetValue(name, out lp)); }
/// <summary> /// 得到网页授权用户信息 /// </summary> /// <param name="web_access_token">网页授权接口调用凭证,注意:此access_token与基础支持的access_token不同</param> /// <param name="openid">用户的唯一标识</param> /// <param name="lang">返回国家地区语言版本,zh_CN 简体,zh_TW 繁体,en 英语</param> /// <returns></returns> public static WebUserInfo GetWebUserInfo(string web_access_token, string openid, LangType lang) { string url = string.Format("https://api.weixin.qq.com/sns/userinfo?access_token={0}&openid={1}&lang={2}", web_access_token, openid, lang.ToString()); var json = Util.HttpGet2(url); if (json.IndexOf("errcode") > 0) { var ui = new WebUserInfo(); ui.error = Util.JsonTo <ReturnCode>(json); return(ui); } else { return(Util.JsonTo <WebUserInfo>(json)); } }
public static string getTemplate(LangType language) { lock (templates.SyncRoot) { if (templates[language] == null) { string path = @"plugins/SnippetExecutor/templates/" + language.ToString() + ".txt"; string ret = loadTemplate(path); if (ret == null) { throw new Exception("No template for " + System.IO.Path.GetFullPath(path)); } templates[language] = ret; return ret; } else { return (string) templates[language]; } } }
private static ISnippetCompiler getCompilerForLanguage(LangType langType) { switch (langType) { case LangType.L_TEXT: case LangType.L_CS: return new CSharpCompiler(); case LangType.L_VB: return new VBCompiler(); default: throw new Exception("No compiler for language " + langType.ToString()); } }
public static string GetLangExt(LangType langType) { return(GetLangExt(langType.ToString())); }
public static void SetLange(LangType langType) { HttpContext.Current.Session["lang"] = langType.ToString(); }