Skip to content

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

MethodReturn ValueDescription
sdk.language.getCurrentLocale()SupportedLanguageCodeReturns 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:

  1. URL query ?lang=
  2. URL path prefix /de/… (first segment that is in the supported list)
  3. Cookie i18n_redirected
  4. localStorage key LANG_KEY
  5. Env default: prod_cn → zh, otherwise en

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 }):

CodeName
zh简体中文
enEnglish
zh-hant繁體中文
deDeutsch
esEspañol
frFrançais
itItaliano
ja日本語
ko한국어
ruРусский
ukУкраїнська
slSlovenščina
thไทย
plPolski
csČeština
idBahasa Indonesia
viTiế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 to zh.
  • 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 / localStorage are accessible.
  • SupportedLanguageCode (the short-code union) and SupportedLocale ({ code, name }) are both exported from the package for TypeScript users.

MIT Licensed