wesnoth / wesnoth

An open source, turn-based strategy game with a high fantasy theme.
https://www.wesnoth.org/
GNU General Public License v2.0
5.45k stars 998 forks source link

Variables in campaign text are not translated #2833

Closed golimarrrr closed 6 years ago

golimarrrr commented 6 years ago

I'm playing Legend of Wesmere and the texts are translated to Spanish, however at times I found the English word "and". After checking the .po file I see that it came from variables like $left_behind_kalenz or $left_behind_landar Is there a way to translate also the text inside variables?

GregoryLundberg commented 6 years ago

I found

value= _ "$left_behind_{NAME} and $l3_store_{NAME}[$i].name" # wmllint: ignore

which is a translatable string. Most likely it simply was not translated.

I'm assigning this to @ivanovic for final disposition.

soliton- commented 6 years ago

The {NAME} part looks like a macro argument in the string there. That's not going to work.

stevecotton commented 6 years ago

Aside from the {NAME} macro, there's also character names going in to the string, the so desired result is something like "Amabrisal, Caewiith, Lasal and Fanemanar".

What it needs is an i18n version of the [set_variable][join] method, which localises not only the commas and the word "and", but also changes it to match the target languages' grammar rules. So if some language's grammar looks like "Amabrisal and Caewiith, Lasal, Fanemanar" then the function would do that. Maybe I'm searching for the wrong keywords, but I can't find any online discussion of an i18n join function.

For 1.14, I think there's an option to change it to "Amabrisal, Caewiith, Lasal, Fanemanar" in all languages. That means the English grammar isn't quite right, and the non-English grammar probably isn't quite right, but you don't get an English word in the middle of a non-English sentence.

Vultraz commented 6 years ago

Assigning @shikadiqueen since she's been dealing with localization stuff. Ivanovic isn't active anymore besides committing translations.

CelticMinstrel commented 6 years ago

We have an API function that does exactly what's needed here, but I think it probably can't be implemented in a string-freeze-safe way. Then again, most of the other suggestions also aren't string-freeze-safe?

For the record, the requisite function is wesnoth.format_conjunct_list in Lua (and of course is available in C++ too).

irydacea commented 6 years ago

It seems like these are the only two cases in mainline:

./campaigns/Legend_of_Wesmere/scenarios/chapter3/09_Bounty_Hunters.cfg:                                value= _ "$left_behind_{NAME} and $l3_store_{NAME}[$i].name" # wmllint: ignore
./campaigns/Legend_of_Wesmere/scenarios/chapter3/09_Bounty_Hunters.cfg:                                value= _ "$left_behind_{NAME}|, $l3_store_{NAME}[$i].name" # wmllint: ignore

They definitely can't be fixed during a string freeze, but the patches can be merged after 1.14.0 is tagged and announced.

CelticMinstrel commented 6 years ago

I believe that commit (which is PR #2834) should fix this issue, provided I didn't make a trivial syntax error.