1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Show list of supported languages in mod info

This commit is contained in:
Ivan Savenko 2023-03-27 00:26:58 +03:00
parent a35aee6b52
commit 14f8348b9e

View File

@ -24,6 +24,7 @@
#include "../jsonutils.h"
#include "../../lib/CConfigHandler.h"
#include "../../lib/Languages.h"
void CModListView::setupModModel()
{
@ -221,7 +222,6 @@ QString CModListView::genModInfoText(CModEntry & mod)
QString textTemplate = prefix + "</p><p align=\"justify\">%2</p>";
QString listTemplate = "<p align=\"justify\">%1: %2</p>";
QString noteTemplate = "<p align=\"justify\">%1</p>";
QString compatibleString = prefix + tr("Mod is compatible") + "</p>";
QString incompatibleString = redPrefix + tr("Mod is incompatible") + "</p>";
QString supportedVersions = redPrefix + "%2 %3 %4</p>";
@ -242,9 +242,7 @@ QString CModListView::genModInfoText(CModEntry & mod)
result += urlTemplate.arg(tr("Contact")).arg(mod.getValue("contact").toString()).arg(mod.getValue("contact").toString());
//compatibility info
if(mod.isCompatible())
result += compatibleString.arg(tr("Compatibility"));
else
if(!mod.isCompatible())
{
auto compatibilityInfo = mod.getValue("compatibility").toMap();
auto minStr = compatibilityInfo.value("min").toString();
@ -267,6 +265,31 @@ QString CModListView::genModInfoText(CModEntry & mod)
}
}
QStringList supportedLanguages;
QVariant baseLanguageVariant = mod.getBaseValue("language");
QString baseLanguageID = baseLanguageVariant.isValid() ? baseLanguageVariant.toString() : "english";
bool needToShowSupportedLanguages = false;
for(const auto & language : Languages::getLanguageList())
{
if (!language.hasTranslation)
continue;
QString languageID = QString::fromStdString(language.identifier);
if (languageID != baseLanguageID && !mod.getValue(languageID).isValid())
continue;
if (languageID != baseLanguageID)
needToShowSupportedLanguages = true;
supportedLanguages += QApplication::translate("Language", language.nameEnglish.c_str());
}
if(needToShowSupportedLanguages)
result += replaceIfNotEmpty(supportedLanguages, lineTemplate.arg(tr("Languages")));
result += replaceIfNotEmpty(mod.getValue("depends"), lineTemplate.arg(tr("Required mods")));
result += replaceIfNotEmpty(mod.getValue("conflicts"), lineTemplate.arg(tr("Conflicting mods")));
result += replaceIfNotEmpty(mod.getValue("description"), textTemplate.arg(tr("Description")));