mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-22 14:51:29 +03:00
7c0a686cd9
# NEW HOOK API `useI18n`: same as `useAFFiNEI18N`, with additional APIs ```ts import { useI18n } from '@affine/i18n' const i18n = useI18n() i18n['hello world']() -> 你好世界 ``` # NEW GLOBAL i18n Instance `I18n`: use i18n capabilities outside of React ```ts import { I18n } from '@affine/i18n' I18n['hello world']() -> 你好世界 ``` # NEW TYPES `I18nKeys` -> all i18n keys `I18nString` -> An i18n message (key&options) transfer and store i18n text outside of React ```ts const msg: I18nString = { key: 'helloworld', options: { arg1: '123' } } I18n.t(msg) -> 你好世界123 ``` before: ```ts registerCommand('open-page', { name: t('command.open-page') // ^- translation happens here, }) ``` after: ```ts registerCommand('open-page', { name: { key: 'command.open-page' } // ^- store I18nString here, translate when the command render to UI }) ```
38 lines
968 B
JSON
38 lines
968 B
JSON
{
|
|
"name": "@affine/i18n",
|
|
"description": "",
|
|
"type": "module",
|
|
"main": "src/index.ts",
|
|
"exports": {
|
|
".": "./src/index.ts"
|
|
},
|
|
"scripts": {
|
|
"build": "node build.mjs",
|
|
"dev": "node dev.mjs",
|
|
"sync-languages": "node --loader ts-node/esm/transpile-only src/scripts/sync.ts",
|
|
"sync-languages:check": "yarn run sync-languages --check",
|
|
"download-resources": "node --loader ts-node/esm/transpile-only src/scripts/download.ts"
|
|
},
|
|
"keywords": [],
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "git+https://github.com/toeverything/AFFiNE.git"
|
|
},
|
|
"dependencies": {
|
|
"@magic-works/i18n-codegen": "^0.6.0",
|
|
"dayjs": "^1.11.11",
|
|
"i18next": "^23.11.1",
|
|
"react": "^18.2.0",
|
|
"react-i18next": "^14.1.0",
|
|
"undici": "^6.12.0"
|
|
},
|
|
"devDependencies": {
|
|
"@types/prettier": "^3.0.0",
|
|
"prettier": "^3.2.5",
|
|
"ts-node": "^10.9.2",
|
|
"typescript": "^5.4.5",
|
|
"vitest": "1.6.0"
|
|
},
|
|
"version": "0.14.0"
|
|
}
|