/// <summary> /// Loads the previously stored language settings from the Windows registry. /// </summary> /// <remarks> /// <para>Currently, the only setting stored is the selected language of the application. /// </para> /// </remarks> private void LoadLanguageSettings() { string cultureName = null; // Attempt to find the application's registry key RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(Constants.RegistryKeyName); if (registryKey != null) { using (registryKey) { // Get the previously selected language's culture name cultureName = (string)registryKey.GetValue(Constants.LanguageValueName); } } // Attempt to set the selected language of the application to the previously selected // one, if it is supported _selectedLanguage = FindLanguage(cultureName) ?? _languages[0]; _selectedLanguage.IsSelected = true; LocalizeDictionary.Instance.Culture = _selectedLanguage.Culture; }
/// <summary> /// Changes the currently selected language to the language corresponding to the culture /// with the specified culture name. /// </summary> /// <param name="cultureName">The culture name of the culture associated with the newly /// selected language.</param> public void SelectLanguage(string cultureName) { LanguageItem language = FindLanguage(cultureName); if (language != null) SelectedLanguage = language; }