Skip to content
TokenFlight SDK

Internationalization (i18n)

TokenFlight includes built-in translations for five locales. Locale packs are lazy-loaded, so only the active language is fetched when needed.

CodeLanguage
en-USEnglish (default)
zh-CNSimplified Chinese (简体中文)
zh-TWTraditional Chinese (繁體中文)
ja-JPJapanese (日本語)
ko-KRKorean (한국어)
index.html
<tokenflight-widget
locale="zh-CN"
theme="dark"
to-token="eip155:8453:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
trade-type="EXACT_OUTPUT"
amount="100"
></tokenflight-widget>
app.js
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();

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();
  • 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.