|
|
||
|---|---|---|
| .. | ||
| README.md | ||
| app.en.ts | ||
| app.zh-cn.ts | ||
| bots-sync.en.ts | ||
| bots-sync.zh-cn.ts | ||
| channels.en.ts | ||
| channels.zh-cn.ts | ||
| dashboard.en.ts | ||
| dashboard.zh-cn.ts | ||
| image-factory.en.ts | ||
| image-factory.zh-cn.ts | ||
| index.ts | ||
| legacy-deck.en.ts | ||
| legacy-deck.zh-cn.ts | ||
| management.en.ts | ||
| management.zh-cn.ts | ||
| wizard.en.ts | ||
| wizard.zh-cn.ts | ||
README.md
I18N Convention
Use this convention for every new page/module:
- Add two language packs in this folder:
<module>.zh-cn.ts<module>.en.ts
-
Export plain objects/functions from both files with the same key shape.
-
In component code, select pack via:
import { pickLocale } from '../i18n';
import { xxxZhCn } from '../i18n/xxx.zh-cn';
import { xxxEn } from '../i18n/xxx.en';
const t = pickLocale(locale, { 'zh-cn': xxxZhCn, en: xxxEn });
-
Do not add inline
isZh ? ... : ...strings in page code. -
Keep dynamic text in translation pack as small helper functions.