# Language support: website, SDK, workflows and agents

## Built-in interface coverage

The shipped website/SDK phrase catalogs cover **English, French, Spanish, German,
Portuguese, Italian, Russian, Chinese, Japanese, Korean, Hindi and Arabic**. Every
registered English source phrase must have a nonempty translation with identical
interpolation markers in every built-in catalog. Hindi is no longer exempt.

`/sdk/locales/status.json` reports the generated source count, per-language coverage
and cache version. Coverage validation detects missing entries and malformed
placeholders; it is not a claim that every translation has native-speaker review
or that every possible language/browser/model is issue-free. New catalogs and
additional language QA remain necessary for languages outside the built-in set.

## Selecting and changing language

The website language selector updates its React interface, owned validation,
accessible attributes and document direction. Its stored preference is used when
available; otherwise it considers browser preferences. Storage denial does not
prevent selection in the current page. Catalog failures are disclosed and can be
retried rather than silently treated as a translated interface.

The SDK reads `data-language`/JavaScript `language`, then the host document language.
It follows host `lang` changes and the shared `smart365:languagechange` event.

```js
document.documentElement.lang = "ar";
document.documentElement.dir = "rtl";
await Smart365Guide.setLanguage("ar");
```

Switching does not restart the conversation, fill a field, authorize an action or
submit a transaction. Regional speech preferences such as `fr-CA` are retained.
Browser preference quality weights are honored; `q=0` preferences are excluded.
Unsupported/invalid interface locales fall back to English, and the SDK discloses
an unsupported language rather than claiming a complete translation.

## Additional languages with an owner-provided SDK dictionary

Any valid BCP-47 locale can have a dictionary supplied by the host. Load the bundle
without auto-init and initialize in its browser load callback:

```js
const guide = Smart365Guide.init({
  licenseKey: "YOUR_APPLICATION_SDK_LICENSE",
  endpoint: "https://www.smart365guide.com",
  language: "ne-NP",
  translations: {
    ne: {
      "How can I help? Ask a question, find a page, follow a workflow or request an action on this page. It all stays in this conversation.":
        "म कसरी मद्दत गर्न सक्छु? प्रश्न सोध्नुहोस् वा यस पृष्ठमा कार्यका लागि मार्गदर्शन माग्नुहोस्।",
      "Ask, navigate, or request an action...": "सोध्नुहोस्, पृष्ठ खोज्नुहोस् वा कार्य अनुरोध गर्नुहोस्..."
    }
  }
});
```

Use canonical locale keys such as `ne`, `ne-NP` or `ur-PK`. Exact locale matching is
tried before the base language. This is a deliberately small example, not a complete
Nepali pack. Use the keys from `/sdk/locales/en.json` to prepare a complete owner
dictionary, preserve every `{placeholder}`, and review it with a fluent speaker.
Invalid packs are rejected; missing phrases use English and an owner-pack notice
is shown. Dictionaries localize widget UI only and are not uploaded for translation.
Do not put private data in a dictionary.

RTL direction follows language/script information, including owner locales such
as Urdu and script-specific tags. Host layout is still the host's responsibility.

## What stays unchanged

The widget localizes its own shadow UI. It does not rewrite the customer's page,
entered values, user messages, passwords, account records, code blocks, selectors,
routes, option values, JSON protocol keys or permission rules. Owner-enabled host-site translation is now available for explicitly marked public
UI text; see [live site guidance](live-site-guide.md). It is separate from widget
localization and does not translate arbitrary host/customer data. Owner-defined
workflow text must be reviewed/translated separately; it is not silently changed
into an alternate executable contract.

## Workflow translations and generated responses

The company/admin workflow translation screen can generate supported workflow
translations using its configured AI provider. Access is owner/tenant scoped;
failed generation does not save a pretend translation. The SDK can use available
workflow narrative translations while retaining original step identifiers and
action/field data. Drafting a workflow and translating it are separate operations.

Static explanations/validation use shipped catalogs without a model call. Model
responses need the configured provider. Reply-language hints accept valid BCP-47
locales, including languages outside the built-in UI set; this is a request to the
model, not a guarantee of that model's language quality. The hint explicitly keeps
selectors, values, protocol fields and authorization unchanged.

MCP instructions ask agents to explain in the user's requested language while
preserving the original workflow contract. `Accept-Language` can provide a default;
the user's explicit language request remains important. The stdio bridge accepts
`S365_LANGUAGE` for the default header. Model vendor/version does not change access.

## Voice and accessibility

Speech recognition needs browser support and microphone consent. Speech synthesis
needs an available matching voice or provider support. Regional tags are passed
where possible; unsupported speech must fall back to typing rather than claiming
every browser speaks every language. Code examples remain LTR even inside RTL UI.
Translated wording does not override application-specific custom validation.

## Maintaining coverage

```sh
node scripts/collect-locale-sources.mjs --write
# Translate newly added English keys in every built-in source catalog.
npm run i18n:check
```

The collector includes explicit `LocalizedText`/`T` source literals and registered
UI metadata in the new landing/ASDK surfaces. Runtime customer data and protocol
strings are not harvested. Keep new UI text registered rather than adding raw
English text nodes. Use interpolation templates for dynamic counts and never
translate user-entered literal values as interface text.

Build validation also checks registration of static translation sources, so a new
screen cannot silently pass with absent catalog entries. Generated public locale
files and status are derived from the checked source catalogs. No customer content
or model credentials are sent by the runtime catalog loader.
