3 | | See https://wildfiregames.com/forum/topic/96576-petraai-bot-doesnt-recognize-defeat-of-competitor-its-trading-with/?do=getNewComment |
| 3 | [https://wildfiregames.com/forum/topic/96576-petraai-bot-doesnt-recognize-defeat-of-competitor-its-trading-with PetraAI bot doesn't recognize defeat of competitor, it's trading with] (11/Oct/22) |
| 4 | |
| 5 | === possible solution ? |
| 6 | |
| 7 | |
| 8 | {{{#!diff |
| 9 | --- a/binaries/data/mods/public/simulation/ai/petra/chatHelper.js |
| 10 | +++ b/binaries/data/mods/public/simulation/ai/petra/chatHelper.js |
| 11 | @@ -225,9 +225,9 @@ PETRA.chatAnswerRequestDiplomacy = function(gameState, player, requestType, resp |
| 12 | "message": "/msg " + gameState.sharedScript.playersData[player].name + " " + |
| 13 | pickRandom(this.answerDiplomacyRequestMessages[requestType][response]), |
| 14 | "translateMessage": true, |
| 15 | - "translateParameters": requiredTribute ? ["_amount_", "_resource_", "_player_"] : ["_player_"], |
| 16 | + "translateParameters": { "_resource_": "withinSentence" } , |
| 17 | "parameters": requiredTribute ? |
| 18 | - { "_amount_": requiredTribute.wanted, "_resource_": requiredTribute.type, "_player_": player } : |
| 19 | + { "_amount_": requiredTribute.wanted, "_resource_": Resources.GetNames()[requiredTribute.type], "_player_": player } : |
| 20 | { "_player_": player } |
| 21 | }); |
| 22 | }; |
| 23 | }}} |
| 24 | |
| 25 | - the `Resources.GetNames()[requiredTribute.type]` transforms `wood` into `Wood` |
| 26 | - the `{ "_resource_": "withinSentence" }` for finding the correctly translated word with the [[Implementation_of_Internationalization_and_Localization#ObjectTranslationHelperFunction|translateObjectKeys]] function in `ChatMessageFormatPlayer.js`. |
| 27 | |
| 28 | [https://code.wildfiregames.com/source/0ad/browse/ps/trunk/binaries/data/mods/public/l10n/nl.public-gui-other.po$7296 l10n/nl.public-gui-other.po] |
| 29 | |
| 30 | {{{#!po lineno=7285 marks=7296-7298 |
| 31 | #. Translation: Word as used at the beginning of a sentence or as a single- |
| 32 | #. word sentence. |
| 33 | #: simulation/data/resources/wood.jsonname |
| 34 | msgctxt "firstWord" |
| 35 | msgid "Wood" |
| 36 | msgstr "Hout" |
| 37 | |
| 38 | #. Translation: Word as used in the middle of a sentence (which may require |
| 39 | #. using lowercase |
| 40 | #. for your language). |
| 41 | #: simulation/data/resources/wood.jsonname |
| 42 | msgctxt "withinSentence" |
| 43 | msgid "Wood" |
| 44 | msgstr "Hout" |
| 45 | |
| 46 | #. Translation: Word as used at the beginning of a sentence or as a single- |
| 47 | #. word sentence. |
| 48 | #: simulation/data/resources/wood.jsonsubtypes.tree |
| 49 | msgctxt "firstWord" |
| 50 | msgid "Tree" |
| 51 | msgstr "Boom" |
| 52 | }}} |
| 53 | |
| 54 | [[Image(old_new.png, 800px, center)]] |
| 55 | |
| 56 | ===== note |
| 57 | 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 |
| 58 | |
| 59 | [https://code.wildfiregames.com/source/0ad/browse/ps/trunk/binaries/data/mods/public/l10n/nl.public-simulation-other.po$250 l10n/nl.public-simulation-other.po] |
| 60 | |
| 61 | {{{#!po lineno=245 marks=250 |
| 62 | #: simulation/ai/petra/chatHelper.js:81 |
| 63 | #, javascript-format |
| 64 | msgid "" |
| 65 | "%(_player_)s, you must send me a tribute of %(_amount_)s %(_resource_)s " |
| 66 | "before I accept an alliance with you." |
| 67 | msgstr "%(_player_)s, u moet eerst %(_amount_)s%(_resource_)s als geschenk sturen voordat ik een bondgenootschap met u accepteer." |
| 68 | }}} |