/*============================================================== * 设置默认语言 *==============================================================*/ internal static void change_language_to_default() { int idx = -1; for (int i = 0; i < m_s_LanguagesList.Count; ++i) { c_Language lang = m_s_LanguagesList[i]; if (lang.m_codepage == Encoding.Default.CodePage) { idx = i; break; } } // for if (idx < 0) { idx = 2; } change_language(idx); }
/*============================================================== * 读取语言列表 *==============================================================*/ internal static void read_languages_list() { if (!Directory.Exists(c_Path_.m_k_LANGUAGE_DIR)) { return; } string[] files = Directory.GetFiles(c_Path_.m_k_LANGUAGE_DIR, "*.txt", SearchOption.TopDirectoryOnly); m_s_LanguagesList.Clear(); foreach (string file in files) { c_Language language = new c_Language(); language.m_filename = file; m_s_LanguagesList.Add(language); string[] lines = File.ReadAllLines(file, Encoding.UTF8); foreach (string line in lines) { if (line.Length < 2) { continue; } if (line[0] == '/' && line[1] == '/') { continue; } int idx = line.IndexOf(":"); if (idx < 0) { continue; } string w1 = line.Substring(0, idx).Trim().ToLower(); string w2 = line.Substring(idx + 1).Trim(); if (w1 == "codepage") { int.TryParse(w2, out language.m_codepage); continue; } if (w1 == "name") { language.m_name = w2; continue; } int num; if (int.TryParse(w1, out num)) { language.m_txt[num] = w2.Trim(); } } // for } // for // 更新 UI c_Mainform.m_s_mainform.toolStripSplitButton_Languages.DropDownItems.Clear(); for (int i = 0; i < m_s_LanguagesList.Count; ++i) { c_Language lang = m_s_LanguagesList[i]; ToolStripMenuItem item = new ToolStripMenuItem(lang.m_name); item.Tag = i; item.Click += Language_Click; c_Mainform.m_s_mainform.toolStripSplitButton_Languages.DropDownItems.Add(item); } // for }