Internationalization (i18n)
TokenFlight includes built-in translations for five locales. Locale packs are lazy-loaded, so only the active language is fetched when needed.
Supported Locales
Section titled “Supported Locales”| Code | Language |
|---|---|
en-US | English (default) |
zh-CN | Simplified Chinese (简体中文) |
zh-TW | Traditional Chinese (繁體中文) |
ja-JP | Japanese (日本語) |
ko-KR | Korean (한국어) |
Setting the Locale
Section titled “Setting the Locale”Declarative
Section titled “Declarative”<tokenflight-widget locale="zh-CN" theme="dark" to-token="eip155:8453:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" trade-type="EXACT_OUTPUT" amount="100"></tokenflight-widget>Imperative
Section titled “Imperative”import { TokenFlightWidget } from '@tokenflight/swap';
const widget = new TokenFlightWidget({ container: '#widget', config: { toToken: { chainId: 8453, address: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' }, tradeType: 'EXACT_OUTPUT', amount: '100', locale: 'ja-JP', theme: 'dark', },});widget.initialize();Runtime Locale Changes
Section titled “Runtime Locale Changes”Locale is read during initialization. To switch languages after mount, destroy and recreate the widget:
widget.destroy();
const nextWidget = new TokenFlightWidget({ container: '#widget', config: { toToken: { chainId: 8453, address: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' }, tradeType: 'EXACT_OUTPUT', amount: '100', theme: 'dark', locale: 'zh-CN', },});
nextWidget.initialize();What Gets Translated
Section titled “What Gets Translated”- Swap UI labels and actions
- Receive and card checkout copy
- Token selector text
- Error messages and status text
- Locale-aware number formatting
Custom translation overrides are not currently supported.