Template:TranslationDef: Difference between revisions

From Heroes of Might and Magic: Olden Era Official Wiki
obelisk-bot: uploading initial Cargo templates
obelisk-bot: uploading initial Cargo templates
Line 89: Line 89:
== Field notes ==
== Field notes ==
* '''Primary key is <code>(type, target_id)</code>''' as a tuple. Joins from parent entities include the type discriminator: e.g. <code>Unit.id = Translation.target_id WHERE Translation.type='unit'</code>.
* '''Primary key is <code>(type, target_id)</code>''' as a tuple. Joins from parent entities include the type discriminator: e.g. <code>Unit.id = Translation.target_id WHERE Translation.type='unit'</code>.
'' ''*English defaults are ''not'' here.** They live on each parent entity's row (<code>Unit.name</code>, <code>Faction.name</code>, <code>HeroClass.name</code>, etc.) so the most common query — "give me the English label for this unit" — needs only a single-table read. Translations are the i18n payload only.
* '''English defaults are ''not'' here.''' They live on each parent entity's row (<code>Unit.name</code>, <code>Faction.name</code>, <code>HeroClass.name</code>, etc.) so the most common query — "give me the English label for this unit" — needs only a single-table read. Translations are the i18n payload only.
* '''Language-code mapping''' (game directory → two-letter code):
* '''Language-code mapping''' (game directory → two-letter code):
** <code>BRportugese</code> → <code>pt_br</code>
** <code>BRportugese</code> → <code>pt_br</code>
Line 117: Line 117:
<code>(type, target_id)</code> discriminator means Cargo can store many rows in
<code>(type, target_id)</code> discriminator means Cargo can store many rows in
a single table without page-naming collisions.
a single table without page-naming collisions.
== Wiki template notes ==
<syntaxhighlight lang="mediawiki">
<noinclude>
Per-entity i18n payload, shared across all categories. Invoked from each parent entity's data page (Data:Unit/<id>, Data:Faction/<id>, etc.) — there is no Data:Translation/… page namespace.
</noinclude><includeonly>{{#cargo_store:_table=TranslationDef
| type={{{type|}}}
| target_id={{{target_id|}}}
| name_sid={{{name_sid|}}}
| desc_sid={{{desc_sid|}}}
| pt_br_name={{{pt_br_name|}}}
| pt_br_description={{{pt_br_description|}}}
| cs_name={{{cs_name|}}}
| cs_description={{{cs_description|}}}
| fr_name={{{fr_name|}}}
| fr_description={{{fr_description|}}}
| de_name={{{de_name|}}}
| de_description={{{de_description|}}}
| hu_name={{{hu_name|}}}
| hu_description={{{hu_description|}}}
| it_name={{{it_name|}}}
| it_description={{{it_description|}}}
| ja_name={{{ja_name|}}}
| ja_description={{{ja_description|}}}
| ko_name={{{ko_name|}}}
| ko_description={{{ko_description|}}}
| pl_name={{{pl_name|}}}
| pl_description={{{pl_description|}}}
| ru_name={{{ru_name|}}}
| ru_description={{{ru_description|}}}
| es_name={{{es_name|}}}
| es_description={{{es_description|}}}
| tr_name={{{tr_name|}}}
| tr_description={{{tr_description|}}}
| uk_name={{{uk_name|}}}
| uk_description={{{uk_description|}}}
| zh_cn_name={{{zh_cn_name|}}}
| zh_cn_description={{{zh_cn_description|}}}
| zh_tw_name={{{zh_tw_name|}}}
| zh_tw_description={{{zh_tw_description|}}}
}}</includeonly>
</syntaxhighlight>
== Notes ==


[[Category:Cargo Definitions]]
[[Category:Cargo Definitions]]

Revision as of 00:42, 13 May 2026

A single shared table for all per-entity i18n payloads. Replaces the parallel UnitTranslation, FactionTranslation, AttackPassiveTranslation, … tables we used to ship — same shape, one row per (entity-type, entity-id) pair, discriminated by type. See D-026.

The bot never extracts TranslationDef rows on their own; each parent entity's emit function appends a {{TranslationDef | type=… | …}} call to its own page, right after the entity's structural row. The {{TranslationDef}} MediaWiki template's job is to call #cargo_store on this table.

Schema

This template defines the table "Translation". View table.

{{TranslationDef
| type = String              <!-- e.g. unit, faction, hero, hero_class, attack_passive -->
| target_id = String         <!-- the parent entity's id (Unit.id, Faction.id, etc.) -->
| name_sid = String
| desc_sid = String

<!-- Per-language pairs. Each language gets a name + desc column. -->
| pt_br_name = String
| pt_br_description = Wikitext
| cs_name = String
| cs_description = Wikitext
| fr_name = String
| fr_description = Wikitext
| de_name = String
| de_description = Wikitext
| hu_name = String
| hu_description = Wikitext
| it_name = String
| it_description = Wikitext
| ja_name = String
| ja_description = Wikitext
| ko_name = String
| ko_description = Wikitext
| pl_name = String
| pl_description = Wikitext
| ru_name = String
| ru_description = Wikitext
| es_name = String
| es_description = Wikitext
| tr_name = String
| tr_description = Wikitext
| uk_name = String
| uk_description = Wikitext
| zh_cn_name = String
| zh_cn_description = Wikitext
| zh_tw_name = String
| zh_tw_description = Wikitext
}}

Field notes

  • Primary key is (type, target_id) as a tuple. Joins from parent entities include the type discriminator: e.g. Unit.id = Translation.target_id WHERE Translation.type='unit'.
  • English defaults are not here. They live on each parent entity's row (Unit.name, Faction.name, HeroClass.name, etc.) so the most common query — "give me the English label for this unit" — needs only a single-table read. Translations are the i18n payload only.
  • Language-code mapping (game directory → two-letter code):
    • BRportugesept_br
    • czechcs, frenchfr, germande, hungarianhu, italianit, japaneseja, koreanko, polishpl, russianru, spanishes, turkishtr, ukrainianuk
    • zhCNzh_cn, zhTWzh_tw
  • Sparse output: any per-language slot the bot couldn't resolve is omitted. Some entities (e.g. faction-shared magic_desc / might_desc for HeroClass) deliberately reuse a single SID across many parents — those parents will all carry the same per-language text on their own Translation row.
  • The desc field is Wikitext' because translations may include HTML-bold and HTML-italic tags from the L10n corpus, which the bot's resolver converts to wiki markup ( and ) before storing.

Entity types currently emitted

type Parent entity target_id Emit site
unit [[../Unit|UnitDef]] Unit.id emit_unit_page
unit_ability [[../UnitAbility|UnitAbilityDef]] UnitAbility.ability_id (composite) emit_unit_page
attack_passive AttackPassiveDef AttackPassive.attack_passive_id emit_attack_passive_page
faction [[../Faction|FactionDef]] Faction.id emit_faction_page

(Hero-side entries: hero, hero_class, hero_specialization, hero_sub_class — added as those entities come online.)

Page layout

Translation rows do not live on their own wiki pages. Each row is emitted as a {{TranslationDef | …}} invocation on the parent entity's data page, immediately after the entity's structural row. The (type, target_id) discriminator means Cargo can store many rows in a single table without page-naming collisions.