Page MenuHomeWildfire Games

Properly internationalize attack names/Generlize to arbitrary names in the GUI
Needs ReviewPublic

Authored by bb on Sat, Sep 5, 12:43 AM.

Details

Reviewers
Nescio
wraitii
Freagarach
Trac Tickets
#252
Summary

Since rP22866 the attack types are not properly internationalized in the tooltips. This patch fixes that commit by providing names to every attacktype is the template (similar to statuseffects).

Not entirely sure whether I used the correct nomenclature for all entities (especially fauna, elephants, siege and ships), maybe @Nescio has some opinion on this?

This patch contains most of the template changes required for D368.

Test Plan

Open unit_demo to see the front doesn't fall
Break your head around whether it is actually translated, or hope the best
Check every template, whether the correct nomenclature is used

Event Timeline

bb created this revision.Sat, Sep 5, 12:43 AM
Owners added subscribers: Restricted Owners Package, Restricted Owners Package.Sat, Sep 5, 12:43 AM
bb updated this revision to Diff 13411.Sat, Sep 5, 12:48 AM
bb requested review of this revision.Sat, Sep 5, 12:57 AM
bb updated this revision to Diff 13413.Sat, Sep 5, 1:26 AM
bb edited the test plan for this revision. (Show Details)

Break your head around whether it is actually translated, or hope the best

Or verify experimentally by manually inserting an entry in a .po file ;) (Which I did, and it gets translated properly.)

Check every template, whether the correct nomenclature is used

Sometimes you use the projectile as a name (e.g. bolt, stone) sometimes you use the method of delivering that projectile (e.g. bow, machine guns). I am not sure what is the proper way of naming the attacks for obviously "Melee" and "Ranged" are too simple. But on the other hand, having "arrow" twice in a sentence is also weird.

Open unit_demo to see the front doesn't fall

Checkrefs passes also.

binaries/data/mods/public/simulation/components/Attack.js
443

Why return something when the entity does not have the type?

binaries/data/mods/public/simulation/templates/template_unit_fauna_hunt_aggressive.xml
5 ↗(On Diff #13413)

They usually also use their claws xD

Why not simply set a translate() in the gui/common/tooltips.js, as used to be the case, and is also done for resistance (e.g. line 198)? There are not that many possibilities (Capture, Melee, Ranged). Or just take and translate the node itself?
Introducing a new node means changing a lot of templates, and more importantly, the names are arbitrary. A tiger that mauls a target uses both claws and teeth, and jumps. Male elephants figthing each other lock their tusks and push forehead to forehead, to force the other to the ground; trained war elephants are able to strike humans with their trunks, stab or tear with their tusks, or crush heads under their feet. For ranged attacks, should the name be the weapon or the projectile (bow vs arrow, crossbow vs bolt, sling vs stone)? And if a certain name seems appropiate for a template (e.g. “Sword” for template_unit_infantry_swordsman.xml), it is not necessarily correct for all its children (e.g. kush_infantry_clubman_b.xml). Naming a <Melee> attack “Knife” but a <Slaughter> attack “Slaughter” seems inconsistent too. And so forth.

binaries/data/mods/public/simulation/templates/gaia/fauna_walrus.xml
5

If this is to be done at all, then why not simply name it <Name>? Or <Type> or <Weapon>?

binaries/data/mods/public/simulation/templates/skirmish/units/default_infantry_melee_b.xml
3–7

Unnecessary, see parent.

binaries/data/mods/public/simulation/templates/skirmish/units/default_infantry_ranged_b.xml
3–7

Idem.

binaries/data/mods/public/simulation/templates/template_structure_civic_civil_centre.xml
11

And what if it's actually a crossbow bolt, sling bullet, stone, or javelin?

binaries/data/mods/public/simulation/templates/units/plane.xml
5

Don't pluralize (cf. Arrow).

bb updated this revision to Diff 13417.Sat, Sep 5, 1:53 PM
bb marked an inline comment as done.

AttackName => Weapon
Use name of the weapons everywhere, no more projectile names (k, javelin, but that is a weapon too)
Improve elephant and animal names

bb added a comment.Sat, Sep 5, 1:54 PM

Why not simply set a translate() in the gui/common/tooltips.js, as used to be the case, and is also done for resistance (e.g. line 198)?

It is not as simple as that: the strings that need to be translated need to be extracted from the scripts, so "just setting a translate call" won't do anything, since the english strings won't be uploaded to transifex.

There are not that many possibilities (Capture, Melee, Ranged). Or just take and translate the node itself?

After D368 the nodes are arbitrary, so many more possibilities. Translating nodes themselves isn't possible either, since they can't be extracted. Moreover, nodes can't contain spaces, while names can (see my Machine gun creation).

Introducing a new node means changing a lot of templates, and more importantly, the names are arbitrary.

Changing templates needs to happen anyways and names will become arbitrary too. This patch is exactly designed for changing all the templates, such that we don't need to do it when changing the code.

A tiger that mauls a target uses both claws and teeth, and jumps. Male elephants figthing each other lock their tusks and push forehead to forehead, to force the other to the ground; trained war elephants are able to strike humans with their trunks, stab or tear with their tusks, or crush heads under their feet. For ranged attacks, should the name be the weapon or the projectile (bow vs arrow, crossbow vs bolt, sling vs stone)? And if a certain name seems appropiate for a template (e.g. “Sword” for template_unit_infantry_swordsman.xml), it is not necessarily correct for all its children (e.g. kush_infantry_clubman_b.xml). Naming a <Melee> attack “Knife” but a <Slaughter> attack “Slaughter” seems inconsistent too. And so forth.

This is exactly the reason I put this patch up here, so that we can fix most of these inconsistencies. E.g. I wasn't sure how elephants even attacked anything, so had no clue how to name it, judging from the current animation we should probably call it tusk but you bring up an extremely valid point: elephant have several ways to attack, which will be allowed after D368.

binaries/data/mods/public/simulation/components/Attack.js
443

Well we have to return something, so we can ofc return "", but even type makes more sense that that imho

binaries/data/mods/public/simulation/templates/gaia/fauna_walrus.xml
5

We have to consider the messages.json file, that will extract all data from the template in the given node. So a general thing like "Name" or "Type" won't work since it is highly likely they will be reused for other components (maybe not in vanilla, but other mods). In that case we can't add the translation context which imo should be there.

Regarding weapon had some initial doubts how that would work with capture and animals, but can agree on it.

binaries/data/mods/public/simulation/templates/skirmish/units/default_infantry_melee_b.xml
3–7

Actually I don't see it in the parent. Neither I think it should be in the parent, since every child but this one will change it and this name is just a placeholder to be replaced by the correct template.

binaries/data/mods/public/simulation/templates/skirmish/units/default_infantry_ranged_b.xml
3–7

^

binaries/data/mods/public/simulation/templates/template_structure_civic_civil_centre.xml
11

Then we can rename it to the correct one, right?

Freagarach added inline comments.Thu, Sep 10, 5:10 PM
binaries/data/mods/public/globalscripts/Templates.js
210

Perhaps weaponName/WeaponName? To avoid confusion with something that affects simulation or visuals?
(Also in templates.)

binaries/data/mods/public/simulation/templates/units/plane.xml
5

(Though this is about the weapon, which could be plural.)

bb updated this revision to Diff 13487.Sun, Sep 13, 2:03 PM

Weapon => WeaponName

Successful build - Chance fights ever on the side of the prudent.

builderr-release-macos.txt
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/liblobby.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libengine.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libatlas.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libgui.a(precompiled.o) has no symbols

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/1547/display/redirect

I think the approach of having a template-configurable i18n is good, I'm wondering if it shouldn't be an attribute of the attack:

<Attack>
    <Ranged name="Boiling Oil">
    </Ranged
</Attack>

This would avoid having to think of a name for the tag.

"WeaponName" is kinda OK, but what if you want two different attack techniques using the same weapon? Such as e.g. a "sniper shot" and "360 no scope" attack with a rifle? Technically the weapon is the same.

The primary concern I have is the names are essentially arbitrary: functionally, it's irrelevant whether something is labelled axe, spear, or sword. The names are based on visuals (the props used by the actors' animations). Moreover, one can't really expect template editors to view the attack animations of each individual entity, nor artists to check and correct the relevant simulation templates whenever they make art changes.

Then there is the problem of translating. For instance, whilst ‘sword’ can refer to both single- and double-edged blades in English, this is not true for all languages. In Chinese, jiàn is the word for double-edged swords and dāo the term for single-edged swords (and knives). Thus in those languages “sword” would be wrong in about half of the cases.

<WeaponName>Teeth</WeaponName>

Boars, elephants, hippopotamuses, narwhals, walruses have tusks, and snakes, cats, dogs, etc. have fangs.

binaries/data/mods/public/simulation/templates/gaia/fauna_walrus.xml
5

Sorry, I don't quite understand. Both <Identity> and <Upgrade> have a <Tooltip> node; both are properly translated and displayed. So why won't <Name> work?

<AttackName>, though far from perfect, might actually be better than <WeaponName>.

binaries/data/mods/public/simulation/templates/skirmish/units/default_infantry_melee_b.xml
3–7

These skirmish/ templates are placeholders that are replaced during map generation. They don't contain any strings. Inserting an attack name here serves no function and is stricly speaking incorrect.

binaries/data/mods/public/simulation/templates/template_structure_defensive_tower_artillery.xml
5

?

binaries/data/mods/public/simulation/templates/template_structure_defensive_tower_bolt.xml
5

?

binaries/data/mods/public/simulation/templates/template_unit_cavalry.xml
12

Sword

binaries/data/mods/public/simulation/templates/template_unit_champion_elephant_melee.xml
5

When playing the elephant actor animation, the trunk is probably the most visible. Some also have a soldier on top attacking with a pike.
Furthermore, in reality not all elephants have tusks.

binaries/data/mods/public/simulation/templates/template_unit_champion_infantry_swordsman.xml
5

mace_champion_infantry_swordsman.xml, merc_black_cloak.xml, and sele_infantry_swordsman_merc_b.xml use a rhomphaia, which is not a sword; possibly others too.

binaries/data/mods/public/simulation/templates/template_unit_infantry.xml
12

Dagger

binaries/data/mods/public/simulation/templates/template_unit_ship_bireme.xml
5

?

binaries/data/mods/public/simulation/templates/template_unit_ship_fire.xml
5

Log → Wood

binaries/data/mods/public/simulation/templates/template_unit_support_female_citizen.xml
16

Dagger

binaries/data/mods/public/simulation/templates/units/theb_siege_fireraiser.xml
5

The idea of a flamethrower is to set fire to something, so you probably meant burning, not boiling oil.
However, the relevant source, Thucydides 4.100, states it had a cauldron containing coals, sulphur, and pitch.

The main reason for this differentiation above just Melee and Ranged is secondary attacks (which _will_ come and thus should be counted with). Then one can have a longer ranged melee attack, e.g. using a sarissa and one for close combat, e.g. a sword and Melee wouldn't suffice anymore.
We may just use AttackName and use the weapon there when possible (i.e. the above mentioned case) and revert to Melee and Ranged when it is either not possible (e.g. animals) or undesirable (e.g. structures).

binaries/data/mods/public/simulation/templates/template_unit_infantry.xml
5

Kinda weird ^^

For simplicity and consistency it might be best if the name node takes exactly the name of its parent, i.e. Capture, Melee, Ranged, or Slaughter. If and when multiple attacks are enabled and can have any name, then the translatable string can be renamed too.

bb updated this revision to Diff 13514.Mon, Sep 21, 6:33 PM
bb marked 2 inline comments as done.

Back to attackName
add context support
add context for swords
improve some names

bb added a comment.Mon, Sep 21, 6:35 PM

Then there is the problem of translating. For instance, whilst ‘sword’ can refer to both single- and double-edged blades in English, this is not true for all languages. In Chinese, jiàn is the word for double-edged swords and dāo the term for single-edged swords (and knives). Thus in those languages “sword” would be wrong in about half of the cases.

This is actually easy to fix, we can add a context tag in the template, which will be extracted already. So I just added the code to pipe the context through and use it for translations. In example: one can put <AttackName context="Double-edged">Sword</AttackName> in the template. On this specific topic: I also added context for all sword wielding units.

binaries/data/mods/public/simulation/templates/gaia/fauna_walrus.xml
5

Hmm right, I would call that a bug in rP18467. Anyway to give the proper context, we do need different nodes.

binaries/data/mods/public/simulation/templates/skirmish/units/default_infantry_melee_b.xml
3–7

The skirmish templates, while being replaced, still need to be a valid template, hence need some string here.

binaries/data/mods/public/simulation/templates/template_structure_defensive_tower_artillery.xml
5

Not sure what you mean here?

binaries/data/mods/public/simulation/templates/units/theb_siege_fireraiser.xml
5

Actually I meant boiling, since oil doesn't burn that easily in high volumes (oxygen can't get to the oil that easily), so if I were to handle such a thing, I would boil the oil and throw that onto something, so the other material will burn, not the oil. Obviously the oil will burn a bit after it is out of the pot.

Anyway history tells otherwise...

The point is the values and names are defined in the generic template_* parent templates, but the props and animations in the actor files, which are set in the specific units/* templates. If you use the actor viewer in Atlas, you'll see e.g. cart_cavalry_swordsman_gaul_b.xml uses a double-edged sword, but cart_cavalry_swordsman_iber_b.xml a single-edged sword.

This is actually easy to fix, we can add a context tag in the template, which will be extracted already. So I just added the code to pipe the context through and use it for translations. In example: one can put <AttackName context="Double-edged">Sword</AttackName> in the template.

How does this work, i.e. what's the result on transifex?

On this specific topic: I also added context for all sword wielding units.

No you didn't: you set it for the generic template_unit_*_swordsman.xml shared parents, which is wrong for about half their children.

Then another concern: if I understand correctly, the attack name is taken from the template and translated separately. However, in some languages e.g. “spear” and “attack” will give a different translation than “spear-attack”.

Also I noticed for animal attacks you sometimes use the singular (e.g. tusk) and sometimes the plural (e.g. fangs), which is not really consistent.

binaries/data/mods/public/simulation/templates/gaia/fauna_crocodile.xml
5

Crocodiles have teeth.

binaries/data/mods/public/simulation/templates/gaia/fauna_walrus.xml
5

Why is it a bug?

binaries/data/mods/public/simulation/templates/skirmish/units/default_infantry_melee_b.xml
3–7

The string ought to be defined where the attack is defined, i.e. in the parent, not here.

binaries/data/mods/public/simulation/templates/template_structure_defensive_tower_artillery.xml
5

It surprises me, and I'm curious why you chose this particular string.