-
Notifications
You must be signed in to change notification settings - Fork 180
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
feat: i18n for Iceworks-component-builder #301
Conversation
存在一个缺陷:当一开始不能连接到物料库时,会在国际化之前进行一轮报错,所以会出现两轮报错,一轮中文 一轮英文,其余良好。 |
关于提到的缺陷: 示例:错误产生条件:
错误输出与期待输出
错误推断
|
补充,为什么说上面的解决方案不优雅因为实际上存在着多个类似的检验函数,所以需要为每一个类似的组件分配一个 flag ,看起来就像: let defaultFlag1 = true;
let defaultFlag2 = true ;
async function getSources() {
if(defaultFlag1){
defaultFlag1 = false;
return;
}
...
async function getData(source: string) {
if(defaultFlag2){
defaultFlag2 = false;
return;
}
... |
进一步的思考能不能利用一种东西来进行状态判别呢?一个想法是 intl.message 中添加一个 status 属性,但是这显然有些混淆了,我希望每个功能是分开的。 那么 我尝试利用 locale 进行传值: i8n.tsx: // 初始化时 locale 为 default, 这会使得它自动转换为 en 模式, 并且保留 local 属性为 default
export const defaultIntl = createIntl({locale:'default',messages:localeMessages['zh-cn'].messages})
//判别函数:判断是否国际化进程结束
export function checkI18nReady(intl: IntlShape){
return intl.locale !== 'default'
} 使用: async function getSources() {
if(!checkI18nReady(intl)){
return;
}
... 这在运行的时候是比较良好的,但是麻烦在于,你必须找到所有这种类型的函数,并给他加一个判断。也许存在一种方法可以直接影响所有这类的函数而不是冲进去给他加个判断,如果找不到理想状态下的方法,我倾向于使用这种方法。 |
9b921ae
to
0fd22be
Compare
extensions/iceworks-component-builder/web/src/pages/Home/index.tsx
Outdated
Show resolved
Hide resolved
reviewed |
* feat: apply repo * feat: convert ts2js * fix: fix type name * chore: remove console * chore: version * chore: remove code * refactor: remove iceworks-cli * feat: support transform ts to js * chore: version * refactor: rename Iceworks Material Helper to React Component Helper * docs: update logo * chore: lint * feat: i18n 功能包 * feat: extension 示例 iceworks-app 国际化 * docs: typo * chore: remove material-import package.json * feat: add package transform-ts-to-js to tsconfig.json * feat: 改变了编译顺序,将 i18n package 导出的实体变为导出类。 * feat: web 示例 iceworks-app 设置页面 * refactor: 根据 i8n 的新导出方式进行更新,删除无用行,更改模板及引用方式 * feat: 使用 useEffect 函数进行异步加载 * feat: 改变了编译顺序,将 i18n package 导出的实体变为导出类。 * refactor: move export to bottom * feat: i18n for packages/block-service * refactor: format codes and delete useless file `util/i18n.ts` * feat: replace injectIntl with `useIntl` hook and format codes * feat: addLocalProvider To Pages/*/index for i18n * refactor: add `[]` param to useEffect, update en-US JSON and app.tsx * feat: add ui * feat: support ejs options * fix: error styles * fix: lint * feat: i18n for packages/project-service * refactor: uv/pv logic * refactor: pv|uv * style: camel case * chore: add comments * chore: version & change log * Hotfix: rax scaffolds title app type icon disappear (#296) * fix: rax scaffolds title app type icon disappear * chore: version * refactor: do not export recordPV and recordUV, using record * fix: add i18n dep to package.json * feat: types * feat: i18n for packages/page-service * feat: i18n for packages/material-service * fix: ejs options * fix: useState name * feat: i18n for packages/component-service * chore: generate-project version * feat: i18n for project-creator * feat: i18n for page-builder * feat: i18n for material-helper * feat: i18n for Iceworks-component-builder (#301) * feat: i18n for Iceworks-component-generater * fix: fix double alerts bug and add iceworks/i18n to dep * fix: web i18n * style: remove empty line * fix: ignore i18n error * chore: remove unnecessary code * chore: remove unnecessary note * feat: support next locale * style: indent * fix: delete redundant codes Co-authored-by: alvinhui <alvin.hui@qq.com> * refactor: update i18n in extension and i18n.tsx in web * fix: default locale * chore: version * chore: types * refactor: 0.1.0 should be first version * chore: url extraction as constant (#318) * chore: url extraction as constant * style: indent * fix: en-US errors * feat: support webapp and assets def project (#299) * docs: update gifs for en-US (#325) * fix: update i18n translations * docs: update i18n doc gifs (#324) * docs: update i18n doc gifs * docs: update component builder gifs * docs: update material-helper and page-bulder doc gifs * fix: fail to debug extension in development env (#326) * fix: fail to debug extension in development * fix: fail-to-debug-extension-in-development * docs: change slogan for en-US (#327) * docs: add markdownlint to ci and update docs (#328) * fix: update i18n translations * docs: update i18n doc gifs (#324) * docs: update i18n doc gifs * docs: update component builder gifs * docs: update material-helper and page-bulder doc gifs * feat: add docslInt in ci * docs: update docs due to markdownlint * fix: update material helper demo * fix: fix URl to URL * fix: fail to install deps when import materials (#329) * fix: create a new terminal to install deps * chore: remove repeated bulkDownload code * chore: version * refactor: update code due to code style (#331) * chore: record locale (#332) * docs: change slogan for en-US * chore: record locale * fix: fail get material detail in unknown project (#333) * fix: fail to get material detail in unknown project * fix: change specifiedType in getSources method * chore: version * feat: get user info through def client login (#323) * feat: def login client * feat: get user info in web * fix: eslint * feat: get def-login-client zip * feat: add install def-login-client-deps * style: change IIFE * fix: style * chore: accesskey * fix: access key not found in ci setup * fix: ci * fix: fix by the comment * fix: lint * feat: not run the script when key unexist * fix: lint * refactor: encode alibaba-inc (#335) * refactor: encode constants with 'alibaba-Inc' * fix: add js-base dep to package.json * fix: eslint err * fix: use namespace to make test work * feat: add docs check to CI (#338) * chore: change version add CHANGLOG * fix: package publishConfig * fix: extension build size is too bulky (#340) * fix: en-US translation (#339) * fix: change material-import to material-helper (#341) * fix: beta and prod publish env (#343) * chore: title typo (#342) * chore: title typo * chore: settings * fix: gitlab url (#345) * chore: typo Co-authored-by: yangfan <18767120422@163.com> Co-authored-by: alvinhui <alvin.hui@qq.com> Co-authored-by: sspku-yqLiu <liuyongqi@pku.edu.cn> Co-authored-by: sspku-yqLiu <56879942+sspku-yqLiu@users.noreply.github.com>
No description provided.