Skip to content

Commit

Permalink
Fix translation of AI names and tooltips
Browse files Browse the repository at this point in the history
* show translation of AI keys "name" and "tip" or warning messages if
  their values are missing

* if the game language is changed via "Options->Game Options->Language",
  reload the AI list to prevent wrong translations

Refs 509f6bc
Refs #281
Fixes #419
  • Loading branch information
Forgon2100 authored and KJeff01 committed Jul 4, 2019
1 parent 6b91d9e commit db1a216
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/frontend.cpp
Expand Up @@ -1697,6 +1697,9 @@ bool runGameOptionsMenu()
widgSetString(psWScreen, FRONTEND_DIFFICULTY, _("Campaign Difficulty"));
widgSetString(psWScreen, FRONTEND_CAMERASPEED, _("Camera Speed"));
widgSetString(psWScreen, FRONTEND_DIFFICULTY_R, gameOptionsDifficultyString());

// hack to update translations of AI names and tooltips
readAIs();
break;

case FRONTEND_DIFFICULTY:
Expand Down
21 changes: 19 additions & 2 deletions src/multiint.cpp
Expand Up @@ -773,11 +773,28 @@ void readAIs()
WzConfig aiconf(path, WzConfig::ReadOnly);
AIDATA ai;
aiconf.beginGroup("AI");
sstrcpy(ai.name, aiconf.value("name", "error").toWzString().toUtf8().c_str());

if (aiconf.contains("name"))
{
sstrcpy(ai.name, _(aiconf.value("name", "").toWzString().toUtf8().c_str()));
}
else
{
sstrcpy(ai.name, _("MISSING AI NAME"));
}

sstrcpy(ai.slo, aiconf.value("slo", "").toWzString().toUtf8().c_str());
sstrcpy(ai.vlo, aiconf.value("vlo", "").toWzString().toUtf8().c_str());
sstrcpy(ai.js, aiconf.value("js", "").toWzString().toUtf8().c_str());
sstrcpy(ai.tip, aiconf.value("tip", "Click to choose this AI").toWzString().toUtf8().c_str());

if (aiconf.contains("tip"))
{
sstrcpy(ai.tip, _(aiconf.value("tip", "").toWzString().toUtf8().c_str()));
}
else
{
sstrcpy(ai.tip, _("MISSING AI DESCRIPTION"));
}

if (strcmp(*i, "nb_generic.json") == 0)
{
Expand Down

0 comments on commit db1a216

Please sign in to comment.