Skip to content

Commit

Permalink
Compute language name when missing for translations.
Browse files Browse the repository at this point in the history
  • Loading branch information
Holt59 committed Jul 31, 2023
1 parent a66fc5e commit d2045fb
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/extension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::filesystem::path> 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<Translation>(identifier.toStdString(), name.toStdString(),
std::move(qm_files));
}
Expand Down

0 comments on commit d2045fb

Please sign in to comment.