Skip to content

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

CodeLanguage
en-USEnglish (default)
zh-CNSimplified Chinese (简体中文)
zh-TWTraditional Chinese (繁體中文)
ja-JPJapanese (日本語)
ko-KRKorean (한국어)

Setting the Locale

Declarative

html
<tokenflight-widget
  locale="zh-CN"
  theme="dark"
  to-token="eip155:8453:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
  trade-type="EXACT_OUTPUT"
  amount="100"
></tokenflight-widget>

Imperative

js

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

Locale is read during initialization. To switch languages after mount, destroy and recreate the widget:

js
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

  • 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.