diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2022-04-25 17:02:12 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2022-05-03 14:50:13 +0200 |
commit | 97a63ed277504bdac0c8085c788521bdce01f65a (patch) | |
tree | 8367b97fa5fcf6eaf7a27b5de86aefaa553932fe | |
parent | 61039d4ba82a9a8c58d8c5b3876a2799f5665334 (diff) |
Skip endonym in linguist settings list when not available
The settings dialog iterates all members of the QLocale::Language
enum, producing an entry for each. It tried to add the endonym of each
language to its entry; however, QLocale(language) gets the default
locale if there is no CLDR data for the given language; and the
default locale's endonym is no use to us. So don't attempt to include
the endonym of a language unless the locale from which we get it
actually does use the requested language. Also mention why English
skips its endonym.
Fixes: QTBUG-102832
Change-Id: Ia4583727beb247e4775f443d98089db3f02a17d2
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
(cherry picked from commit b30768f7714141158b4fa7afd3ae2ad5ca68dceb)
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
-rw-r--r-- | src/linguist/linguist/translationsettingsdialog.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/linguist/linguist/translationsettingsdialog.cpp b/src/linguist/linguist/translationsettingsdialog.cpp index 7a1a53585..dc523f8f4 100644 --- a/src/linguist/linguist/translationsettingsdialog.cpp +++ b/src/linguist/linguist/translationsettingsdialog.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2021 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Linguist of the Qt Toolkit. @@ -41,14 +41,16 @@ TranslationSettingsDialog::TranslationSettingsDialog(QWidget *parent) m_ui.setupUi(this); for (int i = QLocale::C + 1; i < QLocale::LastLanguage; ++i) { - QString lang = QLocale::languageToString(QLocale::Language(i)); - auto loc = QLocale(QLocale::Language(i)); - if (loc.language() != QLocale::English) { - QString nln = loc.nativeLanguageName(); - if (!nln.isEmpty()) { - //: <english> (<endonym>) (language and country names) - lang = tr("%1 (%2)").arg(lang, nln); - } + const auto language = QLocale::Language(i); + QString lang = QLocale::languageToString(language); + const auto loc = QLocale(language); + // Languages for which we have no data get mapped to the default locale; + // its endonym is unrelated to the language requested. For English, the + // endonym is the name we already have; don't repeat it. + if (loc.language() == language && language != QLocale::English) { + const QString native = loc.nativeLanguageName(); + if (!native.isEmpty()) //: <english> (<endonym>) (language names) + lang = tr("%1 (%2)").arg(lang, native); } m_ui.srcCbLanguageList->addItem(lang, QVariant(i)); } |