AFFiNE/packages/frontend
EYHN 7c0a686cd9
refactor(i18n): new hook api (#7273)
# 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
})
```
2024-06-20 02:19:41 +00:00
..
admin feat(admin): init project (#7197) 2024-06-18 06:01:13 +00:00
component refactor(i18n): new hook api (#7273) 2024-06-20 02:19:41 +00:00
core refactor(i18n): new hook api (#7273) 2024-06-20 02:19:41 +00:00
electron fix(core): can't enter presentation again in share page (#7262) 2024-06-19 09:21:23 +00:00
electron-api fix(electron): downgrade electron version (#7215) 2024-06-13 09:19:37 +00:00
graphql feat(admin): init project (#7197) 2024-06-18 06:01:13 +00:00
i18n refactor(i18n): new hook api (#7273) 2024-06-20 02:19:41 +00:00
native chore: bump up uuid version to v10 (#7185) 2024-06-11 08:01:57 +00:00
templates fix(core): template image assets missing (#7171) 2024-06-08 17:28:24 +00:00
web fix(core): fix ui flashing (#7056) 2024-05-27 08:05:20 +00:00