コンテンツにスキップ

Cards Translation

Adaptive Cards are JSON assets, so Greentic translates them by replacing user-facing strings with i18n references and shipping locale catalogs next to the cards.

Current demos use this shape:

assets/cards/main_menu.json
{
"type": "TextBlock",
"text": "{{i18n:card.main_menu.body_0.text}}"
}
assets/i18n/en.json
{
"card.main_menu.body_0.text": "Welcome"
}
  1. Create cards

    assets/cards/welcome.json
    {
    "type": "AdaptiveCard",
    "version": "1.5",
    "body": [
    {
    "type": "TextBlock",
    "text": "{{i18n:card.welcome.body_0.text}}",
    "size": "Large"
    },
    {
    "type": "TextBlock",
    "text": "{{i18n:card.welcome.body_1.text}}"
    }
    ],
    "actions": [
    {
    "type": "Action.Submit",
    "title": "{{i18n:card.welcome.actions_0.title}}",
    "data": { "action": "start" }
    }
    ]
    }
  2. Create the English source catalog

    assets/i18n/en.json
    {
    "card.welcome.body_0.text": "Welcome!",
    "card.welcome.body_1.text": "How can I help you today?",
    "card.welcome.actions_0.title": "Get Started"
    }
  3. Translate the source catalog

    Terminal window
    greentic-i18n-translator translate \
    --langs fr,de,ja \
    --en assets/i18n/en.json

    This writes or updates locale files next to the English source map.

  4. Validate translated files

    Terminal window
    greentic-i18n-translator validate \
    --langs fr,de,ja \
    --en assets/i18n/en.json
  5. Package the assets

    Keep cards and locale JSON files under the pack or bundle asset tree:

    assets/
    ├── cards/
    │ └── welcome.json
    └── i18n/
    ├── en.json
    ├── fr.json
    ├── de.json
    └── ja.json

The current installed greentic-cards2pack CLI exposes generate; it does not currently expose extract-i18n or --auto-translate. If you need automated extraction, use a project helper script or a custom extraction workflow that:

  • scans Adaptive Card JSON files
  • extracts fields such as text, title, label, placeholder, errorMessage, altText, and fallbackText
  • skips empty strings and pure template expressions
  • rewrites the card fields to {{i18n:key}}
  • writes assets/i18n/en.json

The Greentic demo repository includes tools/i18n_extract_cards.py, which follows this pattern for demo packs.

Common extracted keys follow this pattern:

{prefix}.{cardId}.{json_path}.{field}
PartSourceExample
prefixUsually card or app-specific prefixcard
cardIdCard id or filenamewelcome
json_pathPosition in card structurebody_0, actions_1
fieldField nametext, title, label

Examples:

  • card.welcome.body_0.text
  • card.welcome.actions_0.title
  • card.form.body_1.placeholder
  • card.form.body_0_choices_2.title
FieldSource element
textTextBlock and rich text content
titleActions, toggles, fact titles, and choice titles
labelInput labels
placeholderInput placeholders
errorMessageValidation messages
altTextImage alt text
fallbackTextFallback content
Fact valueFactSet values when the value is user-facing static text

Skip:

  • empty strings
  • action data
  • ids and route names
  • URLs
  • pure template expressions such as {{user_name}}
  • strings that already reference i18n, such as {{i18n:card.welcome.body_0.text}}

Preserve placeholders exactly across translations:

{
"card.welcome.body_0.text": "Hello, {{name}}!"
}
{
"card.welcome.body_0.text": "Bonjour, {{name}} !"
}

Do not translate placeholder names:

{
"card.welcome.body_0.text": "Bonjour, {{nom}} !"
}

Install or make the translator available on PATH:

Terminal window
cargo install greentic-i18n-translator

Check that:

  • the target locale file exists in assets/i18n/
  • the key exists in that file
  • the card uses the same key
  • the active session, team, tenant, or bundle locale is set as expected

Run:

Terminal window
greentic-i18n-translator validate \
--langs fr,de,ja \
--en assets/i18n/en.json

Then fix missing keys or placeholder mismatches before publishing.