Opened 18 months ago

Last modified 16 months ago

#6648 closed defect

%(resource)s are not translated in AI private messages — at Version 2

Reported by: Gurken Khan Owned by:
Priority: Should Have Milestone: Alpha 27
Component: Internationalization & Localization Keywords: translation UI resources
Cc: Gurken, Khan Patch:

Description (last modified by Langbart)

When AIs make demands in private messages the resources are not translated but use the English terms like "food".

PetraAI bot doesn't recognize defeat of competitor, it's trading with (11/Oct/22)

possible solution ?

  • binaries/data/mods/public/simulation/ai/petra/chatHelper.js

    a b PETRA.chatAnswerRequestDiplomacy = function(gameState, player, requestType, resp  
    225225        "message": "/msg " + gameState.sharedScript.playersData[player].name + " " +
    226226            pickRandom(this.answerDiplomacyRequestMessages[requestType][response]),
    227227        "translateMessage": true,
    228         "translateParameters": requiredTribute ? ["_amount_", "_resource_", "_player_"] : ["_player_"],
     228        "translateParameters": { "_resource_": "withinSentence" } ,
    229229        "parameters": requiredTribute ?
    230             { "_amount_": requiredTribute.wanted, "_resource_": requiredTribute.type, "_player_": player } :
     230            { "_amount_": requiredTribute.wanted, "_resource_": Resources.GetNames()[requiredTribute.type], "_player_": player } :
    231231            { "_player_": player }
    232232    });
    233233};
  • the Resources.GetNames()[requiredTribute.type] transforms wood into Wood
  • the { "_resource_": "withinSentence" } for finding the correctly translated word with the translateObjectKeys function in ChatMessageFormatPlayer.js.

l10n/nl.public-gui-other.po

Line 
7285#. Translation: Word as used at the beginning of a sentence or as a single-
7286#. word sentence.
7287#: simulation/data/resources/wood.jsonname
7288msgctxt "firstWord"
7289msgid "Wood"
7290msgstr "Hout"
7291
7292#. Translation: Word as used in the middle of a sentence (which may require
7293#. using lowercase
7294#. for your language).
7295#: simulation/data/resources/wood.jsonname
7296msgctxt "withinSentence"
7297msgid "Wood"
7298msgstr "Hout"
7299
7300#. Translation: Word as used at the beginning of a sentence or as a single-
7301#. word sentence.
7302#: simulation/data/resources/wood.jsonsubtypes.tree
7303msgctxt "firstWord"
7304msgid "Tree"
7305msgstr "Boom"

note

the missing space in the dutch text, which can be seen in the image above, is a problem of the translator and is not caused by this patch

l10n/nl.public-simulation-other.po

Line 
245#: simulation/ai/petra/chatHelper.js:81
246#, javascript-format
247msgid ""
248"%(_player_)s, you must send me a tribute of %(_amount_)s %(_resource_)s "
249"before I accept an alliance with you."
250msgstr "%(_player_)s, u moet eerst %(_amount_)s%(_resource_)s als geschenk sturen voordat ik een bondgenootschap met u accepteer."

Change History (3)

comment:1 by Silier, 18 months ago

Component: UI – In-gameInternationalization & Localization

comment:2 by Langbart, 16 months ago

Description: modified (diff)

possible solution

by Langbart, 16 months ago

Attachment: old_new.png added
Note: See TracTickets for help on using tickets.