Freigeben über


How to get list of all installed input locales?

In the last post we spoke about how to find what locale is currently selected as active. Now it's time to find how many and what input locales are installed on a PC.

Here are two overloaded functions: one returns locale IDs as integer values (e.g. 1049) and the second – as two characters ISO strings (e.g. "en"):

 /// <summary>
 /// Returns list of installed locales
 /// </summary>
 /// <param name="LangList">Contains integer values of installed locales</param>
 public void GetInstalledLanguages(out IList<int> LangList)
 {
    LangList = new List<int>(InputLanguage.InstalledInputLanguages.Count);
 
    foreach (InputLanguage lng in InputLanguage.InstalledInputLanguages)
    {
        LangList.Add(lng.Culture.KeyboardLayoutId);
    }
 }
 
 /// <summary>
 /// Returns list of installed locales
 /// </summary>
 /// <param name="LangList">Contains string values of installed locales</param>
 public void GetInstalledLanguages(out IList<string> LangList)
 {
    LangList = new List<string>(InputLanguage.InstalledInputLanguages.Count);
 
    foreach (InputLanguage lng in InputLanguage.InstalledInputLanguages)
    {
        LangList.Add(lng.Culture.TwoLetterISOLanguageName);
    }
 }