public static Dictionary <string, string> GetLanguages() { Dictionary <string, string> langs = new Dictionary <string, string>(); foreach (Code c in CodeTranslator.GetCodeType("LOC")) { string lang = ""; string description = ""; char[] splitters = { '_', '(' }; if (c.Alternate_Type != null && c.Alternate_Type.Length > 0) { string[] langsplit = c.Alternate_Type.Split(splitters); string[] descs = c.External_Description.Split(splitters); lang = langsplit[0]; description = descs[0].TrimEnd(); if (c.Alternate_Type == "en_ZW") { description = "English"; } if (langs.ContainsKey(lang) == false) { langs.Add(lang, description); } } } return(langs); }
public static SortedList <string, Code> GetLocales(string lang_mnemonic) { SortedList <string, Code> locales = new SortedList <string, Code>(); foreach (Code c in CodeTranslator.GetCodeType("LOC")) { string lang = ""; char[] splitters = { '_', '(', ')' }; if (c.Alternate_Type != null && c.Alternate_Type.Length > 0) { string[] langsplit = c.Alternate_Type.Split(splitters); string[] descs = c.External_Description.Split(splitters); string locale = ""; lang = langsplit[0]; if (lang == lang_mnemonic) { if (descs.Length > 1) { locale = descs[1]; } else { locale = descs[0].TrimEnd(); } if (locales.IndexOfKey(locale) >= 0) { locales.Add(c.External_Description + " [" + c.Code_Value + "]", c); } else { locales.Add(locale, c); } } } } return(locales); }