From 24162cb162369094537177ce68bdbbeda382cf0b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 7 Sep 2021 15:47:30 +0200 Subject: [PATCH] i18n: repair language names for Chinese Prompted by Linlinger, I've reconsidered the names of languages in the drop-down in the welcome page. We already have the infrastructure for assigning specific names / locales to "Calamares locale names" (which match Transifex names, not necessarily Qt names). Use that to put exactly two Chinese- language translations in the drop-down: - Simplified Chinese (code zh_CN) - Traditional Chinese (code zh_TW) Drop zh (which is a peculiar locale name anyway) and zh_HK (which is Traditional Chinese, but using the geographic boundary is a bit weird; we're going to ignore the minor orthographic differences with Traditional Chinese written elsewhere for now). Note that this makes the drop-down show "Chinese" in the English column, twice; the difference is visible only in the native-language representation. SEE #1741 --- CMakeLists.txt | 4 ++-- src/libcalamares/locale/Translation.cpp | 20 +++++++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 27fcda865..99ee4330e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,9 +138,9 @@ set( _tx_complete az az_AZ ca de fi_FI he hi hr ja ko lt pt_BR sq set( _tx_good as be ca@valencia cs_CZ da fr fur it_IT ml nl pt_PT ru sk tg tr_TR vi zh_CN ) set( _tx_ok ar ast bg bn el en_GB es es_MX es_PR et eu fa gl hu id - is mr nb pl ro si sl sr sr@latin th zh_HK ) + is mr nb pl ro si sl sr sr@latin th ) set( _tx_incomplete eo es_PE fr_CH gu id_ID ie kk kn ko_KR lo lv mk - ne ne_NP ru_RU te ur uz zh ) + ne ne_NP ru_RU te ur uz ) ### Required versions # diff --git a/src/libcalamares/locale/Translation.cpp b/src/libcalamares/locale/Translation.cpp index fb8890e87..d439f51b7 100644 --- a/src/libcalamares/locale/Translation.cpp +++ b/src/libcalamares/locale/Translation.cpp @@ -38,6 +38,18 @@ specialCase( const CalamaresUtils::Locale::Translation::Id& locale ) static QString name = QStringLiteral( "Català (València)" ); return { nullptr, &name }; } + if ( localeName == "zh_CN" ) + { + // Simplified Chinese, but drop the (China) from the name + static QString name = QStringLiteral( "简体中文" ); + return { nullptr, &name }; + } + if ( localeName == "zh_TW" ) + { + // Traditional Chinese, but drop (Taiwan) from the name + static QString name = QStringLiteral( "繁體中文" ); + return { nullptr, &name }; + } return { nullptr, nullptr }; } @@ -70,11 +82,9 @@ Translation::Translation( const Id& localeId, LabelFormat format, QObject* paren } bool needsCountryName = ( format == LabelFormat::AlwaysWithCountry ) - || ( localeId.name.contains( '_' ) && QLocale::countriesForLanguage( m_locale.language() ).count() > 1 ); - QString countryName = ( needsCountryName ? - - m_locale.nativeCountryName() - : QString() ); + || ( !name && localeId.name.contains( '_' ) + && QLocale::countriesForLanguage( m_locale.language() ).count() > 1 ); + QString countryName = needsCountryName ? m_locale.nativeCountryName() : QString(); m_label = needsCountryName ? longFormat.arg( languageName, countryName ) : languageName; m_englishLabel = needsCountryName ? longFormat.arg( englishName, QLocale::countryToString( m_locale.country() ) ) : englishName;