Skip to content

feat(tenant_config): accept i18n-keyed labels for nav_links#87

Open
BimaPangestu28 wants to merge 1 commit into
mainfrom
feat/i18n-aware-nav-link-labels
Open

feat(tenant_config): accept i18n-keyed labels for nav_links#87
BimaPangestu28 wants to merge 1 commit into
mainfrom
feat/i18n-aware-nav-link-labels

Conversation

@BimaPangestu28
Copy link
Copy Markdown
Member

Summary

  • Operators can now ship per-locale labels for nav_links entries in the webchat-gui setup wizard, matching the i18n pattern used for flow-rendered Adaptive Cards.
  • Each entry's label may be either a plain string (single-language, unchanged) or a JSON object keyed by locale code (e.g. {"en": "Help", "id": "Bantuan", "de": "Hilfe"}).
  • A new sanitize_nav_label helper trims whitespace, strips non-string locale entries, and rejects label objects with no usable values. Plain-string labels keep the existing validation.
  • The webchat-gui SPA's renderTopbarNav reads the resolved label via the corresponding change in greenticai/greentic-messaging-providers#149 (resolution order: exact selectedLocale → base language → en → first non-empty value).

Test plan

  • cargo test --lib tenant_config — 24/24 ok (added sync_nav_links_accepts_locale_keyed_label_object and sync_nav_links_drops_label_object_with_only_empty_values)
  • cargo clippy --workspace --all-targets -- -D warnings — clean for this change
  • Manual end-to-end on `deep-research-demo-bundle`: pick Indonesian in locale picker, confirm topbar nav links show Indonesian text and switch back to English on theme/locale change

Operators can now ship per-locale labels for `nav_links` entries via the
webchat-gui setup wizard, keeping parity with flow-card i18n so demos
like deep-research can fully localize the topbar nav. Pairs with the
matching `renderTopbarNav` change in greentic-messaging-providers.

The `label` field of each `nav_links_json` entry now accepts either a
plain string (single-language, unchanged behaviour) or a JSON object
keyed by locale code:

```json
{
  "label": { "en": "Help", "id": "Bantuan", "de": "Hilfe" },
  "url": "/help"
}
```

A new `sanitize_nav_label` helper trims whitespace, drops non-string
values, and rejects entries whose object would end up empty. Plain
string labels are still validated as before. The runtime resolves the
displayed label via selectedLocale → base language → `en` → first
non-empty value.

Tests cover both forms, plus the malformed-object case (drops empty
strings, strips non-string values, rejects entries with no usable
label).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant