public void TestLanguageLookupDialog_manualTest_FLExCornerCase()
        {
            const string testLangCode = "es-AR";

            using (var dlg = new LanguageLookupDialog())
            {
                dlg.IsDesiredLanguageNameFieldVisible     = true;
                dlg.IsShowRegionalDialectsCheckBoxVisible = true;
                dlg.IsScriptAndVariantLinkVisible         = false;

                var language = new LanguageInfo
                {
                    LanguageTag = testLangCode,
                    DesiredName = "Spanish"
                };
                dlg.SelectedLanguage = language;
                dlg.SearchText       = "es";
                dlg.UseSimplifiedChinese();

                dlg.ShowDialog();
                // FLEx needs to be able to come into the dialog with Script/Region/Variant settings on the LanguageTag,
                // and know that they will be preserved if the base language doesn't change.
                var msg =
                    $"Got LanguageTag='{dlg.SelectedLanguage.LanguageTag}' Desired Name is='{dlg.DesiredLanguageName}'.";
                MessageBox.Show(msg);
            }
        }
        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;

                // Following should be consistent with LanguageIdControl constructor.
                dlg.UseSimplifiedChinese();

                if (DialogResult.OK != dlg.ShowDialog())
                {
                    return(null);
                }
                return(dlg.SelectedLanguage);
            }
        }
        public void TestLanguageLookupDialog_manualTest_Ojicree()
        {
            const string testLangCode            = "ojs-Latn-CA";
            const string testLangThreeLetterCode = "ojs";
            const string testLangName            = "Ojibwa, Severn";

            using (var dlg = new LanguageLookupDialog())
            {
                dlg.IsDesiredLanguageNameFieldVisible     = true;
                dlg.IsShowRegionalDialectsCheckBoxVisible = true;
                dlg.IsScriptAndVariantLinkVisible         = true;

                var language = new LanguageInfo
                {
                    LanguageTag    = testLangCode,
                    ThreeLetterTag = testLangThreeLetterCode,
                    DesiredName    = testLangName
                };
                dlg.SelectedLanguage = language;
                dlg.SearchText       = testLangThreeLetterCode;
                dlg.UseSimplifiedChinese();

                dlg.ShowDialog();
                // I want to be able to change DesiredName, but keep the original Script tag.
                var msg =
                    $"Got LanguageTag='{dlg.SelectedLanguage.LanguageTag}' Desired Name is='{dlg.DesiredLanguageName}'.";
                MessageBox.Show(msg);
            }
        }
Example #4
0
        public void TestLanguageLookupDialog_manualTest()
        {
            const string testLangCode            = "sok-x-easy";
            const string testLangThreeLetterCode = "sok";
            const string testLangName            = "Sokoro";

            using (var dlg = new LanguageLookupDialog())
            {
                dlg.IsDesiredLanguageNameFieldVisible     = true;
                dlg.IsShowRegionalDialectsCheckBoxVisible = true;
                dlg.IsScriptAndVariantLinkVisible         = true;

                var language = new LanguageInfo()
                {
                    LanguageTag = testLangCode
                };
                language.DesiredName = testLangName;
                dlg.SelectedLanguage = language;
                dlg.SearchText       = testLangThreeLetterCode;
                dlg.UseSimplifiedChinese();

                dlg.ShowDialog();
                MessageBox.Show("Got LanguageTag='" + dlg.SelectedLanguage.LanguageTag + "'.");
            }
        }
Example #5
0
        public static LanguageInfo ChangeLanguage(string languageIdentifier, string potentiallyCustomName = null,
                                                  bool showScriptAndVariantLink = true)
        {
            using (var dlg = new LanguageLookupDialog())
            {
                //at this point, we don't let them customize the national languages
                dlg.IsDesiredLanguageNameFieldVisible     = potentiallyCustomName != null;
                dlg.IsShowRegionalDialectsCheckBoxVisible = true;
                dlg.IsScriptAndVariantLinkVisible         = showScriptAndVariantLink;

                var language = new LanguageInfo()
                {
                    LanguageTag = languageIdentifier
                };
                if (!string.IsNullOrEmpty(potentiallyCustomName))
                {
                    language.DesiredName = potentiallyCustomName;                     // to be noticed, must set before dlg.SelectedLanguage
                }
                dlg.SelectedLanguage = language;
                // if languageIdentifier includes Script/Region/Variant codes... which it might now...
                // limit the SearchText to the part before the first hyphen (the iso 639 code).
                dlg.SearchText = languageIdentifier.Split('-')[0];

                // Following should be consistent with LanguageIdControl constructor.
                dlg.UseSimplifiedChinese();

                // Avoid showing gratuitous script markers in language tags.
                // See https://issues.bloomlibrary.org/youtrack/issue/BL-7641.
                dlg.IncludeScriptMarkers = false;

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