Skip to content
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

在使用kiwi --translate之后不能成功翻译 #114

Open
huchaolin opened this issue Sep 30, 2022 · 1 comment
Open

在使用kiwi --translate之后不能成功翻译 #114

huchaolin opened this issue Sep 30, 2022 · 1 comment

Comments

@huchaolin
Copy link

huchaolin commented Sep 30, 2022

如下报错信息所示,该如何解决呢, 文档实在太简洁了,不知道从何入手;
步骤: kiwi --init 的时候配置了文件目,然后kiwi -- extract 完成之后 执行 kiwi --translate 就报错了

1.最开始报错 是

(node:30313) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
(node:30313) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open '/.../.kiwi/en-US/CrossAnalysisModalContent.ts'
(node:30313) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 4)
(node:30313) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open '/.../.kiwi/en-US/CustomModal.ts'
(node:30313) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 5)``

然后我看了下en-US文件夹没有对应的映射文件;

2.再次执行 kiwi --translate 如下报错,然后我看了下en-US文件夹有对应的映射文件, 但是映射出来的是中文的
```> kiwi --translate

⠦ 使用 Baidu 翻译中...en-US 自动翻译完成
/..../node_modules/kiwi-clis/dist/import.js:27
            throw new Error(`Illegal message: ${value}`);
            ^

Error: Illegal message: Add "and" condition
    at /.../node_modules/kiwi-clis/src/import.ts:26:13
    at Object.parseRows [as tsvParseRows] (/.../node_modules/d3-dsv/dist/d3-dsv.js:122:23)
    at getMessagesToImport (/.../node_modules/kiwi-clis/src/import.ts:20:20)
    at Object.importMessages (/.../node_modules/kiwi-clis/src/import.ts:59:26)
    at /.../node_modules/kiwi-clis/src/translate.ts:158:9
    at /.../node_modules/graceful-fs/graceful-fs.js:61:14
    at FSReqCallback.oncomplete (fs.js:179:23)

第二点bug补充: 是因为 提取文本为 增加“且”条件 被翻译为了 "Add ""and"" condition" 导致调用tsvParseRows时报错,后面是手动修改中文双引号为ASCII码就好了, 然后批量处理还是会有一些比较复杂的字符串模板会转错, 特别是嵌套比较深的或者想echarts render自定义templete的这种,需要自己手动提取中文变量至最外层, 不过已经很好用了~

这是我的config.json配置

{
  "kiwiDir": "./.kiwi",
  "srcLang": "zh-CN",
  "distLangs": [
    "en-US"
  ],
  "googleApiKey": "",
  "baiduApiKey": {
    "appId": "xxxxx",
    "appKey": "xxxxx"
  },
  "baiduLangMap": {
    "en-US": "en"
  },
  "translateOptions": {
    "concurrentLimit": 10,
    "requestOptions": {}
  },
  "defaultTranslateKeyApi": "Pinyin",
  "importI18N": "import I18N from '@i18n';",
  "ignoreDir": ["./src/assets", "./src/server", "./src/mock", "./src/common", "./src/utils", "./node_modules"],
  "ignoreFile": ""
}
@dinglino1
Copy link

image
我也出现类似的问题,其他语种没问题,就这个西班牙翻译就报错。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants