コンテンツにスキップ

Translation Keys

Greentic translation catalogs are flat JSON key/value maps. Older docs referred to deterministic I18nId values, but the current demos and local tooling use readable stable keys such as:

card.main_menu.body_0.text
card.customer_form.body_2.label
qa.install.title
cli.root.about

The practical rule is simple: keys must be stable, unique within the catalog, and meaningful enough that translators and reviewers can understand their context.

Recommended key shape:

{domain}.{screen_or_component}.{path}.{field}

Examples:

KeyMeaning
card.main_menu.body_0.textFirst body text block in the main menu card.
card.main_menu.actions_0.titleFirst action title in the main menu card.
card.customer_form.body_2.placeholderPlaceholder text in a form input.
qa.install.titleComponent setup UI title.
qa.field.api_key.helpHelp text for a setup field.

Some existing packs use variants such as cards.about_card.body.i0.text. Keep existing keys stable once a pack is published; do not rename keys only for style.

Use the key from the locale catalog in the card:

{
"type": "TextBlock",
"text": "{{i18n:card.main_menu.body_0.text}}"
}

Then define the value in each locale:

assets/i18n/en.json
{
"card.main_menu.body_0.text": "Welcome"
}
assets/i18n/fr.json
{
"card.main_menu.body_0.text": "Bienvenue"
}

The local Greentic i18n runtime normalizes BCP 47-ish locale tags before lookup:

  • en_US.UTF-8 becomes en-US
  • ja-JP can fall back to ja
  • unknown locales fall back to en when an English catalog is available
  • missing keys fall back to the key or source text depending on the caller

This is locale fallback, not hash generation.

Card extraction helpers usually derive keys from:

  1. a prefix such as card
  2. the card id or filename
  3. the JSON path of the field
  4. the translated field name

Example:

card.welcome.body_0.text
card.welcome.actions_0.title
card.form.body_1.placeholder
card.form.body_0_choices_2.title
  1. Keep keys stable after release.
  2. Do not translate keys, only values.
  3. Keep placeholders intact, for example {{name}} or {tenant}.
  4. Use assets/i18n/en.json as the source catalog unless your source language is different.
  5. Add the same keys to every translated locale file.
  6. Run greentic-i18n-translator validate for translated files.
  7. Prefer readable keys over opaque hashes for pack assets and cards.