From 975ec13e71f8e303226e0263ab84038c49a7deca Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sun, 14 Feb 2016 16:19:43 +0100 Subject: [PATCH] Locale prefs: skip script-specific entries Avoids showing the same language multiple times in the list, for example when there are cyrillic and latin variants. It is still possible to pick one of the variants, as they are also added as country-specific entries. Fixes #9144. --- src/preferences/locale/LocaleWindow.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/preferences/locale/LocaleWindow.cpp b/src/preferences/locale/LocaleWindow.cpp index d66d41020e..6d501517cb 100644 --- a/src/preferences/locale/LocaleWindow.cpp +++ b/src/preferences/locale/LocaleWindow.cpp @@ -113,9 +113,10 @@ LocaleWindow::LocaleWindow() // TODO: the following block fails to detect a couple of language // names as containing glyphs we can't render. Why's that? - bool hasGlyphs[name.CountChars()]; - font.GetHasGlyphs(name.String(), name.CountChars(), hasGlyphs); - for (int32 i = 0; i < name.CountChars(); ++i) { + int nameLength = name.CountChars(); + bool hasGlyphs[nameLength]; + font.GetHasGlyphs(name.String(), nameLength, hasGlyphs); + for (int32 i = 0; i < nameLength; ++i) { if (!hasGlyphs[i]) { // replace by name translated to current language currentLanguage.GetName(name); @@ -131,10 +132,17 @@ LocaleWindow::LocaleWindow() item = new LanguageListItem(name, currentID.String(), currentLanguage.Code()); } + if (currentLanguage.IsCountrySpecific() && currentToplevelItem != NULL && currentToplevelItem->Code() == item->Code()) { fLanguageListView->AddUnder(item, currentToplevelItem); + } else if (currentLanguage.ScriptCode() != NULL + && currentToplevelItem != NULL + && currentToplevelItem->Code() == item->Code()) { + // This is a script for some language, skip it and add the + // country-specific variants to the parent directly + delete item; } else { // This is a generic language, add it at top-level fLanguageListView->AddItem(item);