diff --git a/i18n/NotepadNext_cs_CZ.ts b/i18n/NotepadNext_cs.ts similarity index 99% rename from i18n/NotepadNext_cs_CZ.ts rename to i18n/NotepadNext_cs.ts index 4481c2c2a..0f7d8fac6 100644 --- a/i18n/NotepadNext_cs_CZ.ts +++ b/i18n/NotepadNext_cs.ts @@ -1,6 +1,6 @@ - + AuthenticateDialog diff --git a/i18n/NotepadNext_es_NI.ts b/i18n/NotepadNext_es.ts similarity index 99% rename from i18n/NotepadNext_es_NI.ts rename to i18n/NotepadNext_es.ts index 99bbe22a0..8bc90bed7 100644 --- a/i18n/NotepadNext_es_NI.ts +++ b/i18n/NotepadNext_es.ts @@ -1,6 +1,6 @@ - + AuthenticateDialog diff --git a/i18n/NotepadNext_pl_PL.ts b/i18n/NotepadNext_pl.ts similarity index 99% rename from i18n/NotepadNext_pl_PL.ts rename to i18n/NotepadNext_pl.ts index 8ce09d8cb..ee8f6d1c0 100644 --- a/i18n/NotepadNext_pl_PL.ts +++ b/i18n/NotepadNext_pl.ts @@ -1,6 +1,6 @@ - + AuthenticateDialog diff --git a/i18n/NotepadNext_ru_RU.ts b/i18n/NotepadNext_ru.ts similarity index 99% rename from i18n/NotepadNext_ru_RU.ts rename to i18n/NotepadNext_ru.ts index ffaddcea0..afbeeac7a 100644 --- a/i18n/NotepadNext_ru_RU.ts +++ b/i18n/NotepadNext_ru.ts @@ -1,6 +1,6 @@ - + AuthenticateDialog diff --git a/i18n/NotepadNext_sv_SE.ts b/i18n/NotepadNext_sv.ts similarity index 99% rename from i18n/NotepadNext_sv_SE.ts rename to i18n/NotepadNext_sv.ts index 2f713e8b6..a7a28e52a 100644 --- a/i18n/NotepadNext_sv_SE.ts +++ b/i18n/NotepadNext_sv.ts @@ -1,6 +1,6 @@ - + AuthenticateDialog diff --git a/i18n/NotepadNext_tr_TR.ts b/i18n/NotepadNext_tr.ts similarity index 99% rename from i18n/NotepadNext_tr_TR.ts rename to i18n/NotepadNext_tr.ts index 17a8432bf..d3a78a367 100644 --- a/i18n/NotepadNext_tr_TR.ts +++ b/i18n/NotepadNext_tr.ts @@ -1,6 +1,6 @@ - + AuthenticateDialog diff --git a/i18n/NotepadNext_uk_UA.ts b/i18n/NotepadNext_uk.ts similarity index 99% rename from i18n/NotepadNext_uk_UA.ts rename to i18n/NotepadNext_uk.ts index 5accbb628..5b73b5ec1 100644 --- a/i18n/NotepadNext_uk_UA.ts +++ b/i18n/NotepadNext_uk.ts @@ -1,6 +1,6 @@ - + AuthenticateDialog diff --git a/src/NotepadNext/TranslationManager.cpp b/src/NotepadNext/TranslationManager.cpp index fc6303955..17125f4c2 100644 --- a/src/NotepadNext/TranslationManager.cpp +++ b/src/NotepadNext/TranslationManager.cpp @@ -62,7 +62,7 @@ QString TranslationManager::FormatLocaleTerritoryAndLanguage(QLocale &locale) const QString territory = QLocale::territoryToString(locale.territory()); #endif const QString language = QLocale::languageToString(locale.language()); - return QStringLiteral("%1 / %2").arg(language, territory); + return QStringLiteral("%1 (%2)").arg(language, territory); } void TranslationManager::loadSystemDefaultTranslation() diff --git a/src/NotepadNext/dialogs/PreferencesDialog.cpp b/src/NotepadNext/dialogs/PreferencesDialog.cpp index 46663b10e..4df72f4df 100644 --- a/src/NotepadNext/dialogs/PreferencesDialog.cpp +++ b/src/NotepadNext/dialogs/PreferencesDialog.cpp @@ -136,14 +136,14 @@ void PreferencesDialog::populateTranslationComboBox() NotepadNextApplication *app = qobject_cast(qApp); // Add the system default at the top - ui->comboBoxTranslation->addItem(QStringLiteral("%1 (%2)").arg(tr(""), QLocale::system().name()), QStringLiteral("")); + ui->comboBoxTranslation->addItem(tr(""), QStringLiteral("")); // TODO: sort this list and keep the system default at the top for (const auto &localeName : app->getTranslationManager()->availableTranslations()) { QLocale locale(localeName); const QString localeDisplay = TranslationManager::FormatLocaleTerritoryAndLanguage(locale); - ui->comboBoxTranslation->addItem(QStringLiteral("%1 (%2)").arg(localeDisplay, localeName), localeName); + ui->comboBoxTranslation->addItem(localeDisplay, localeName); } // Select the current one diff --git a/src/i18n.pri b/src/i18n.pri index 647d6e0dc..ab498d7c7 100644 --- a/src/i18n.pri +++ b/src/i18n.pri @@ -23,15 +23,21 @@ for(TS_FILE, TS_FILES) { # Add the application translation file TRANSLATIONS += $$TS_FILE + FILE_NAME = $$basename(TS_FILE) + # Extract the locale from the file name (e.g. NotepadNext_pl_PL.ts to pl_PL) - LOCALE = $$str_member($$TS_FILE, -8, -4) + LOCALE = $$replace(FILE_NAME, "NotepadNext_(..)(\\_..)?\\.ts", "\\1\\2") - # Extra translation files that include both the language and translation + # Extra Qt translation files EXTRA_TRANSLATIONS += $$files($$[QT_INSTALL_TRANSLATIONS]/qt_$${LOCALE}.qm) EXTRA_TRANSLATIONS += $$files($$[QT_INSTALL_TRANSLATIONS]/qtbase_$${LOCALE}.qm) # Check for files without the territory specified (e.g. pl) - LANGUAGE = $$replace(LOCALE, "(..).*", "\\1") - EXTRA_TRANSLATIONS += $$files($$[QT_INSTALL_TRANSLATIONS]/qt_$${LANGUAGE}.qm) - EXTRA_TRANSLATIONS += $$files($$[QT_INSTALL_TRANSLATIONS]/qtbase_$${LANGUAGE}.qm) + greaterThan($$str_size(LOCALE), 2) { + LANGUAGE = $$replace(LOCALE, "(..).*", "\\1") + EXTRA_TRANSLATIONS += $$files($$[QT_INSTALL_TRANSLATIONS]/qt_$${LANGUAGE}.qm) + EXTRA_TRANSLATIONS += $$files($$[QT_INSTALL_TRANSLATIONS]/qtbase_$${LANGUAGE}.qm) + } } + +message("EXTRA_TRANSLATIONS: $$EXTRA_TRANSLATIONS")