Language Module
The Language module reads the current language environment in one shot, so the integrating generator app can switch its own in-app translations accordingly. It only reads — it does not listen for changes or switch the host language.
API List
| Method | Return Value | Description |
|---|---|---|
sdk.language.getCurrentLocale() | SupportedLanguageCode | Returns the current language short code (one of 17), resolved by the priority chain below |
sdk.language.getSupportedLocales() | SupportedLocale[] | Returns all 17 supported languages as { code, name } objects (a fresh copy) |
Resolution Priority
getCurrentLocale() resolves once and returns the first hit. Every source is guarded; in a non-browser / restricted environment it falls through to the env default:
- URL query
?lang= - URL path prefix
/de/…(first segment that is in the supported list) - Cookie
i18n_redirected localStoragekeyLANG_KEY- Env default:
prod_cn → zh, otherwiseen
All values are normalized to a supported short code (zh-CN → zh, case-insensitive). Unsupported values are skipped, and resolution continues to the next source.
Supported Locales (17)
getSupportedLocales() returns the full list below, typed as SupportedLocale[] ({ code, name }):
| Code | Name |
|---|---|
zh | 简体中文 |
en | English |
zh-hant | 繁體中文 |
de | Deutsch |
es | Español |
fr | Français |
it | Italiano |
ja | 日本語 |
ko | 한국어 |
ru | Русский |
uk | Українська |
sl | Slovenščina |
th | ไทย |
pl | Polski |
cs | Čeština |
id | Bahasa Indonesia |
vi | Tiếng Việt |
Typical Usage
ts
const locale = sdk.language.getCurrentLocale(); // 'de' | 'zh' | 'en' ...
// Switch the generator app's own translations based on the locale
i18n.setLocale(locale);
// List all supported languages, e.g. to render a language picker
const locales = sdk.language.getSupportedLocales();
// [{ code: 'zh', name: '简体中文' }, { code: 'en', name: 'English' }, ...]Notes
- The China region (
prod_cn) web page runs in single-language mode (no URL prefix, no browser detection), so resolution naturally falls back tozh. - The module is read-only and does not subscribe to language changes; if the host navigates and you need the latest value, simply call
getCurrentLocale()again. - Designed for same-origin embedding under
*.atomm.com(Web Component / micro-frontend), where the cookie / URL /localStorageare accessible. SupportedLanguageCode(the short-code union) andSupportedLocale({ code, name }) are both exported from the package for TypeScript users.