From 36f88ae1eb3422eff6344664234fe744d98c7f2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Mon, 31 Jul 2023 20:22:26 +0200 Subject: [PATCH] Compute language name when missing for translations. --- src/extension.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/extension.cpp b/src/extension.cpp index f610fc60..bf0db9a9 100644 --- a/src/extension.cpp +++ b/src/extension.cpp @@ -308,16 +308,26 @@ TranslationExtension::parseTranslation(std::filesystem::path const& extensionFol const QString& identifier, const QJsonObject& jsonTranslation) { - const auto name = jsonTranslation["name"].toString(); const auto jsonGlobFiles = jsonTranslation["files"].toVariant().toStringList(); std::vector qm_files = globExtensionFiles(extensionFolder, jsonGlobFiles); - if (name.isEmpty() || qm_files.empty()) { + if (qm_files.empty()) { return nullptr; } + const auto jsonName = jsonTranslation["name"]; + QString name; + if (jsonName.isString()) { + name = jsonName.toString(); + } else { + QLocale locale(identifier); + name = QString("%1 (%2)") + .arg(locale.nativeLanguageName()) + .arg(locale.nativeCountryName()); + } + return std::make_shared(identifier.toStdString(), name.toStdString(), std::move(qm_files)); }