Bloom.Collection.CollectionSettingsDialog.ChangeLanguage C# (CSharp) Method

ChangeLanguage() private method

private ChangeLanguage ( string iso639Code, string potentiallyCustomName = null ) : LanguageInfo
iso639Code string
potentiallyCustomName string
return LanguageInfo
        private LanguageInfo ChangeLanguage(string iso639Code, string potentiallyCustomName=null)
        {
            using (var dlg = new LanguageLookupDialog())
            {
                //at this point, we don't let them customize the national languages
                dlg.IsDesiredLanguageNameFieldVisible = potentiallyCustomName != null;

                var language = new LanguageInfo() { LanguageTag = iso639Code};
                if (!string.IsNullOrEmpty(potentiallyCustomName))
                {
                    language.DesiredName = potentiallyCustomName; // to be noticed, must set before dlg.SelectedLanguage
                }
                dlg.SelectedLanguage = language;
                dlg.SearchText = iso639Code;

                if (DialogResult.OK != dlg.ShowDialog())
                {
                    return null;
                }
                return  dlg.SelectedLanguage;
            }
        }