IFreeOvO / i18n-cli

支持将vue、react项目里的中文替换成 i18n 国际化标记,并支持自动翻译的命令行工具
MIT License
119 stars 36 forks source link

【bug反馈】@Component({})报错 #43

Closed seayao closed 1 year ago

seayao commented 1 year ago

代码中

.vue文件

@Component({})
class MyA extends Vue {
    ....
}

.tsx文件

@Component
export default class MyB extends Vue {
}

以上两种文件会报错:

v16.13.0\node_modules\@ifreeovo\i18n-extract-cli\node_modules\@babel\par
}, descriptor)), Object.assign(new constructor(), properties));
                               ^

SyntaxError: unknown: Leading decorators must be attached to a class dec

  4 |
  5 | @Component
> 6 |
    | ^
    at instantiate (C:\Users\lingfeng\AppData\Roaming\nvm\v16.13.0\node_t-cli\node_modules\@babel\parser\lib\index.js:64:32)
    at constructor (C:\Users\lingfeng\AppData\Roaming\nvm\v16.13.0\node_t-cli\node_modules\@babel\parser\lib\index.js:364:12)
    at TypeScriptParserMixin.raise (C:\Users\lingfeng\AppData\Roaming\nveovo\i18n-extract-cli\node_modules\@babel\parser\lib\index.js:3253:19)
    at TypeScriptParserMixin.parseDecorators (C:\Users\lingfeng\AppData\ules\@ifreeovo\i18n-extract-cli\node_modules\@babel\parser\lib\index.js:
    at TypeScriptParserMixin.parseStatementLike (C:\Users\lingfeng\AppDamodules\@ifreeovo\i18n-extract-cli\node_modules\@babel\parser\lib\index.
    at TypeScriptParserMixin.parseModuleItem (C:\Users\lingfeng\AppData\ules\@ifreeovo\i18n-extract-cli\node_modules\@babel\parser\lib\index.js:
    at TypeScriptParserMixin.parseBlockOrModuleBlockBody (C:\Users\lingf3.0\node_modules\@ifreeovo\i18n-extract-cli\node_modules\@babel\parser\l
    at TypeScriptParserMixin.parseBlockBody (C:\Users\lingfeng\AppData\Rles\@ifreeovo\i18n-extract-cli\node_modules\@babel\parser\lib\index.js:1
    at TypeScriptParserMixin.parseProgram (C:\Users\lingfeng\AppData\Roas\@ifreeovo\i18n-extract-cli\node_modules\@babel\parser\lib\index.js:124
    at TypeScriptParserMixin.parseTopLevel (C:\Users\lingfeng\AppData\Roes\@ifreeovo\i18n-extract-cli\node_modules\@babel\parser\lib\index.js:12
    at TypeScriptParserMixin.parse (C:\Users\lingfeng\AppData\Roaming\nveovo\i18n-extract-cli\node_modules\@babel\parser\lib\index.js:14250:10)
    at TypeScriptParserMixin.parse (C:\Users\lingfeng\AppData\Roaming\nveovo\i18n-extract-cli\node_modules\@babel\parser\lib\index.js:9993:18)
    at parse (C:\Users\lingfeng\AppData\Roaming\nvm\v16.13.0\node_modulenode_modules\@babel\parser\lib\index.js:14292:38)
    at parser (C:\Users\lingfeng\AppData\Roaming\nvm\v16.13.0\node_modul\node_modules\@babel\core\lib\parser\index.js:41:34)
    at parser.next (<anonymous>)
    at parse (C:\Users\lingfeng\AppData\Roaming\nvm\v16.13.0\node_modulenode_modules\@babel\core\lib\parse.js:25:37)
    at parse.next (<anonymous>)
    at evaluateSync (C:\Users\lingfeng\AppData\Roaming\nvm\v16.13.0\nodect-cli\node_modules\gensync\index.js:251:28)
    at sync (C:\Users\lingfeng\AppData\Roaming\nvm\v16.13.0\node_modulesode_modules\gensync\index.js:89:14)
    at stopHiding - secret - don't use this - v1 (C:\Users\lingfeng\AppD_modules\@ifreeovo\i18n-extract-cli\node_modules\@babel\core\lib\errors\    at Object.parseSync (C:\Users\lingfeng\AppData\Roaming\nvm\v16.13.0\xtract-cli\node_modules\@babel\core\lib\parse.js:41:72)
    at Object.parse (C:\Users\lingfeng\AppData\Roaming\nvm\v16.13.0\nodect-cli\dist\parse.js:17:22)
    at transformAST (C:\Users\lingfeng\AppData\Roaming\nvm\v16.13.0\nodect-cli\dist\transformJs.js:310:29)
    at transformJs (C:\Users\lingfeng\AppData\Roaming\nvm\v16.13.0\node_t-cli\dist\transformJs.js:314:17)
    at handleScript (C:\Users\lingfeng\AppData\Roaming\nvm\v16.13.0\nodect-cli\dist\transformVue.js:202:54)
    at generateSource (C:\Users\lingfeng\AppData\Roaming\nvm\v16.13.0\noract-cli\dist\transformVue.js:236:20)
    at transformVue (C:\Users\lingfeng\AppData\Roaming\nvm\v16.13.0\nodect-cli\dist\transformVue.js:278:22)
    at transform (C:\Users\lingfeng\AppData\Roaming\nvm\v16.13.0\node_mocli\dist\transform.js:28:47)
    at C:\Users\lingfeng\AppData\Roaming\nvm\v16.13.0\node_modules\@ifrere.js:201:58
    at Array.forEach (<anonymous>)
    at C:\Users\lingfeng\AppData\Roaming\nvm\v16.13.0\node_modules\@ifrere.js:196:29
    at Generator.next (<anonymous>)
    at C:\Users\lingfeng\AppData\Roaming\nvm\v16.13.0\node_modules\@ifrere.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (C:\Users\lingfeng\AppData\Roaming\nvm\v16.13.0\node_mocli\dist\core.js:4:12)
    at default_1 (C:\Users\lingfeng\AppData\Roaming\nvm\v16.13.0\node_mocli\dist\core.js:175:12)
    at Command.<anonymous> (C:\Users\lingfeng\AppData\Roaming\nvm\v16.13n-extract-cli\dist\index.js:27:24)
    at Command.listener [as _actionHandler] (C:\Users\lingfeng\AppData\Rles\@ifreeovo\i18n-extract-cli\node_modules\commander\lib\command.js:482
    at C:\Users\lingfeng\AppData\Roaming\nvm\v16.13.0\node_modules\@ifredules\commander\lib\command.js:1283:65
    at Command._chainOrCall (C:\Users\lingfeng\AppData\Roaming\nvm\v16.18n-extract-cli\node_modules\commander\lib\command.js:1177:12)
    at Command._parseCommand (C:\Users\lingfeng\AppData\Roaming\nvm\v16.18n-extract-cli\node_modules\commander\lib\command.js:1283:27)
    at Command.parse (C:\Users\lingfeng\AppData\Roaming\nvm\v16.13.0\nodact-cli\node_modules\commander\lib\command.js:909:10)
    at Object.<anonymous> (C:\Users\lingfeng\AppData\Roaming\nvm\v16.13.-extract-cli\dist\index.js:58:21)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)  
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (C:\Users\lingfeng\AppData\Roaming\nvm\v16.13.0\node_modules\@ifreeovo\i18n-extract-cli\bin\index.js:9:1) {
  code: 'BABEL_PARSE_ERROR',
  reasonCode: 'UnexpectedLeadingDecorator',
  loc: Position { line: 6, column: 0, index: 122 },
  pos: [Getter/Setter]
}
IFreeOvO commented 1 year ago

image

seayao commented 1 year ago

是否可以自动将源文件改写,再进行提取和替换,因为老项目中下述写法:

@Component
export default class MyB extends Vue {
}

太多了, 手动改写比较耗时。

seayao commented 1 year ago

但是我清晰地记得之前的版本(2.3.0)是可以替换成功的,2.3.1及以上版本就不行了。

Pasoul commented 1 year ago

但是我清晰地记得之前的版本(2.3.0)是可以替换成功的,2.3.1及以上版本就不行了。

同样遇到问题了,我试了之前几个版本,2.3.1之前是好的,今天升级到2.4.0就不行,我想问题可能出现在这次提交上:https://github.com/IFreeOvO/i18n-cli/commit/c75f7ce00f71b00e1b6a92c6fc13c58e9c6967ed

IFreeOvO commented 1 year ago

之前是

@Component
export default class MyB extends Vue {
}

解析成

export default
@Component
class MyB extends Vue {}

这样可以正常运行是么?

Pasoul commented 1 year ago

之前是

@Component
export default class MyB extends Vue {
}

解析成

export default
@Component
class MyB extends Vue {}

这样可以正常运行是么?

我写了个demo: https://github.com/Pasoul/vue2-tsx-app

demo里 home/index.tsx 的下发是可以正常提取中文的,但是hello/index.vue的写法不行,i18n-cli的版本是2.3.1

image
IFreeOvO commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

此 issue 已被自动锁定,因为关闭后没有任何近期活动。如果有相关 bug,请重新创建一个新 issue。

IFreeOvO commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

此 issue 已被自动锁定,因为关闭后没有任何近期活动。如果有相关 bug,请重新创建一个新 issue。

IFreeOvO commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

此 issue 已被自动锁定,因为关闭后没有任何近期活动。如果有相关 bug,请重新创建一个新 issue。

IFreeOvO commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

此 issue 已被自动锁定,因为关闭后没有任何近期活动。如果有相关 bug,请重新创建一个新 issue。

IFreeOvO commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

此 issue 已被自动锁定,因为关闭后没有任何近期活动。如果有相关 bug,请重新创建一个新 issue。

IFreeOvO commented 11 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

此 issue 已被自动锁定,因为关闭后没有任何近期活动。如果有相关 bug,请重新创建一个新 issue。

IFreeOvO commented 11 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

此 issue 已被自动锁定,因为关闭后没有任何近期活动。如果有相关 bug,请重新创建一个新 issue。

IFreeOvO commented 10 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

此 issue 已被自动锁定,因为关闭后没有任何近期活动。如果有相关 bug,请重新创建一个新 issue。

IFreeOvO commented 10 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

此 issue 已被自动锁定,因为关闭后没有任何近期活动。如果有相关 bug,请重新创建一个新 issue。

IFreeOvO commented 9 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

此 issue 已被自动锁定,因为关闭后没有任何近期活动。如果有相关 bug,请重新创建一个新 issue。

IFreeOvO commented 9 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

此 issue 已被自动锁定,因为关闭后没有任何近期活动。如果有相关 bug,请重新创建一个新 issue。

IFreeOvO commented 8 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

此 issue 已被自动锁定,因为关闭后没有任何近期活动。如果有相关 bug,请重新创建一个新 issue。

IFreeOvO commented 8 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

此 issue 已被自动锁定,因为关闭后没有任何近期活动。如果有相关 bug,请重新创建一个新 issue。

IFreeOvO commented 7 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

此 issue 已被自动锁定,因为关闭后没有任何近期活动。如果有相关 bug,请重新创建一个新 issue。

IFreeOvO commented 7 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

此 issue 已被自动锁定,因为关闭后没有任何近期活动。如果有相关 bug,请重新创建一个新 issue。

IFreeOvO commented 6 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

此 issue 已被自动锁定,因为关闭后没有任何近期活动。如果有相关 bug,请重新创建一个新 issue。

IFreeOvO commented 6 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

此 issue 已被自动锁定,因为关闭后没有任何近期活动。如果有相关 bug,请重新创建一个新 issue。

IFreeOvO commented 5 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

此 issue 已被自动锁定,因为关闭后没有任何近期活动。如果有相关 bug,请重新创建一个新 issue。

IFreeOvO commented 5 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

此 issue 已被自动锁定,因为关闭后没有任何近期活动。如果有相关 bug,请重新创建一个新 issue。

IFreeOvO commented 4 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

此 issue 已被自动锁定,因为关闭后没有任何近期活动。如果有相关 bug,请重新创建一个新 issue。

IFreeOvO commented 4 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

此 issue 已被自动锁定,因为关闭后没有任何近期活动。如果有相关 bug,请重新创建一个新 issue。

IFreeOvO commented 3 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

此 issue 已被自动锁定,因为关闭后没有任何近期活动。如果有相关 bug,请重新创建一个新 issue。

IFreeOvO commented 3 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

此 issue 已被自动锁定,因为关闭后没有任何近期活动。如果有相关 bug,请重新创建一个新 issue。

IFreeOvO commented 2 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

此 issue 已被自动锁定,因为关闭后没有任何近期活动。如果有相关 bug,请重新创建一个新 issue。

IFreeOvO commented 2 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

此 issue 已被自动锁定,因为关闭后没有任何近期活动。如果有相关 bug,请重新创建一个新 issue。

IFreeOvO commented 1 month ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

此 issue 已被自动锁定,因为关闭后没有任何近期活动。如果有相关 bug,请重新创建一个新 issue。

IFreeOvO commented 1 month ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

此 issue 已被自动锁定,因为关闭后没有任何近期活动。如果有相关 bug,请重新创建一个新 issue。

IFreeOvO commented 1 month ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

此 issue 已被自动锁定,因为关闭后没有任何近期活动。如果有相关 bug,请重新创建一个新 issue。

IFreeOvO commented 2 weeks ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

此 issue 已被自动锁定,因为关闭后没有任何近期活动。如果有相关 bug,请重新创建一个新 issue。

IFreeOvO commented 1 day ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

此 issue 已被自动锁定,因为关闭后没有任何近期活动。如果有相关 bug,请重新创建一个新 issue。