#6648 closed defect (fixed)

%(resource)s are not translated in AI private messages

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

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."

Attachments (1)

old_new.png (239.7 KB ) - added by Langbart 15 months ago.

Download all attachments as: .zip

Change History (5)

comment:1 by Silier, 17 months ago

Component: UI – In-gameInternationalization & Localization

comment:2 by Langbart, 15 months ago

Description: modified (diff)

possible solution

by Langbart, 15 months ago

Attachment: old_new.png added

comment:3 by Freagarach, 15 months ago

Owner: set to Freagarach
Patch: Phab:D4897

comment:4 by Freagarach, 15 months ago

Resolution: fixed
Status: newclosed

In 27467:

Translate resources in PetraAI's tribute demands.

Reported by Gurken Khan at https://wildfiregames.com/forum/topic/96576-petraai-bot-doesnt-recognize-defeat-of-competitor-its-trading-with.

Based on a patch by: @Langbart
Differential revision: https://code.wildfiregames.com/D4897
Accepted by: @Langbart
Fixes #6648

Note: See TracTickets for help on using tickets.