-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(i18n): new hook api #7273
Conversation
Your org has enabled the Graphite merge queue for merging into canaryAdd the label “merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix. You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link. |
This stack of pull requests is managed by Graphite. Learn more about stacking. |
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 7c0a686. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 6 targets
Sent with 💌 from NxCloud. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## canary #7273 +/- ##
==========================================
+ Coverage 58.12% 58.35% +0.23%
==========================================
Files 841 841
Lines 36531 36542 +11
Branches 3929 3931 +2
==========================================
+ Hits 21232 21325 +93
+ Misses 15006 14921 -85
- Partials 293 296 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
4851d2d
to
0e43f7b
Compare
Merge activity
|
# 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 }) ```
0e43f7b
to
d1f2167
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i18n for server errors can be configured now, it's time to use it
# 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 }) ```
d1f2167
to
7c0a686
Compare
NEW HOOK API
useI18n
: same asuseAFFiNEI18N
, with additional APIsNEW GLOBAL i18n Instance
I18n
: use i18n capabilities outside of ReactNEW TYPES
I18nKeys
-> all i18n keysI18nString
-> An i18n message (key&options)transfer and store i18n text outside of React
before:
after: