flutter-i18n-generator 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Flutter I18n Generator
2
2
 
3
- 基于 `$t()` 显式标记的 Flutter 国际化自动化工具,将翻译流程整合为**扫描 → 替换 → 生成 ARB** 三步。
3
+ 基于 `$t()` 显式标记的 Flutter 国际化自动化工具,将翻译流程整合为**扫描 → 替换 → 生成 ARB → 翻译**四步。
4
4
 
5
5
  ## 功能清单
6
6
 
@@ -9,6 +9,7 @@
9
9
  | **扫描** | 正则匹配 `$t('...')` 和 `$t("...")` 调用,支持插值参数 |
10
10
  | **去重** | 相同模板文本生成同一个 key(`t` + MD5 前 12 位) |
11
11
  | **ARB** | 按 `-l` 参数生成多个 `intl_<locale>.arb` 文件 |
12
+ | **翻译** | 集成百度/有道/谷歌翻译 API,自动翻译非主语言条目 |
12
13
  | **替换** | 将 `$t('...')` 替换为 `S.current.xxx(...)` |
13
14
  | **Import** | 自动添加 `S` 类 import,移除旧的 `i18n_marker` import |
14
15
 
@@ -37,19 +38,19 @@ extractor -f lib/views/home.dart
37
38
  extractor -d lib/views/
38
39
 
39
40
  # 排除指定目录/文件
40
- extractor -e "lib/mock,lib/test"
41
+ extractor -e lib/mock lib/test
41
42
  ```
42
43
 
43
44
  ### 多语言 ARB 生成
44
45
 
45
- 通过 `-l` 参数指定要生成的语言代码,第一个为**主语言**(写入模板原文),其余为**翻译占位**(写入空字符串):
46
+ 通过 `-l` 参数指定要生成的语言代码,第一个为**主语言**(写入模板原文):
46
47
 
47
48
  ```bash
48
49
  # 生成中文(主语言)+ 英文 + 日文 ARB 文件
49
50
  extractor -l zh en ja
50
51
  ```
51
52
 
52
- 输出结果:
53
+ 输出:
53
54
 
54
55
  ```
55
56
  lib/l10n/intl_zh.arb → {"t5eb63bbb": "消息设置", "t3f2a1b2": "接收系统通知", ...}
@@ -57,12 +58,23 @@ lib/l10n/intl_en.arb → {"t5eb63bbb": "", "t3f2a1b2": "", ...}
57
58
  lib/l10n/intl_ja.arb → {"t5eb63bbb": "", "t3f2a1b2": "", ...}
58
59
  ```
59
60
 
60
- ### 指定输出目录
61
+ ### 自动翻译
62
+
63
+ 通过 `-t` 指定需要翻译的语言,配合 `-c` 选择翻译渠道及 API 密钥,工具会在生成 ARB 时自动调用翻译接口填充译文:
61
64
 
62
65
  ```bash
63
- extractor -o lib/l10n/ -l zh en ja
66
+ # 百度翻译
67
+ extractor -l zh en -t en -c baidu --appKey 你的appid --secretKey 你的密钥
68
+
69
+ # 有道翻译
70
+ extractor -l zh en ja -t en ja -c youdao --appKey 你的appKey --secretKey 你的密钥
71
+
72
+ # 谷歌翻译(仅需 API Key)
73
+ extractor -l zh en -t en -c google --appKey 你的apiKey
64
74
  ```
65
75
 
76
+ 翻译结果直接写入对应 ARB 文件,无需手动填写。
77
+
66
78
  ### 命令选项
67
79
 
68
80
  | 选项 | 说明 | 默认值 |
@@ -70,9 +82,13 @@ extractor -o lib/l10n/ -l zh en ja
70
82
  | `-d, --dir <dir>` | 扫描的目录路径 | `lib/` |
71
83
  | `-f, --file <path>` | 仅处理指定的单个 `.dart` 文件 | — |
72
84
  | `-o, --output <dir>` | ARB 文件输出目录 | `lib/l10n/` |
73
- | `-e, --exclude <patterns>` | 排除的文件/目录,逗号分隔 | — |
74
- | `-l, --locale <value...>` | 生成的语言代码 | `intl_en` |
75
- | `--dry-run` | 仅预览匹配结果,不实际修改文件 | `false` |
85
+ | `-e, --exclude <value...>` | 排除的文件/目录 | — |
86
+ | `-l, --locale <value...>` | 生成的语言代码,第一个为主语言 | `en` |
87
+ | `-t, --translate <value...>` | 需要机器翻译的语言代码 | |
88
+ | `-c, --channel <value>` | 翻译渠道:`baidu` / `youdao` / `google` | `baidu` |
89
+ | `--appKey <value>` | 翻译 API 应用 key(百度 appid / 有道 appKey / 谷歌 API Key) | — |
90
+ | `--secretKey <value>` | 翻译 API 密钥(百度/有道需要,谷歌不需要) | — |
91
+ | `--dry-run` | 仅预览匹配结果,不实际修改任何文件 | `false` |
76
92
  | `-v, --version` | 显示版本号 | — |
77
93
  | `-h, --help` | 显示帮助信息 | — |
78
94
 
@@ -86,7 +102,7 @@ extractor -o lib/l10n/ -l zh en ja
86
102
  // 简单文本
87
103
  Text($t('消息设置'))
88
104
 
89
- // 带插值参数
105
+ // 带插值参数(使用 ARB 的 {param} 占位语法)
90
106
  Text($t('共{count}条', {'count': total}))
91
107
  ```
92
108
 
@@ -109,37 +125,50 @@ Text(S.current.t5eb63bbb)
109
125
  ```
110
126
 
111
127
  同时自动管理 import 语句:
112
- - 移除 `import '...i18n_marker.dart'`
113
- - 添加 `import 'package:flutter_app_plus/generated/l10n.dart'`
128
+ - 移除 `import '...i18n_marker.dart'`(开发阶段标记工具的遗留 import)
129
+ - 添加 `import 'package:flutter_app_plus/generated/l10n.dart'`(S 类所在的包)
114
130
 
115
131
  ### 4. 生成 ARB 文件
116
132
 
117
- IDE 中右键 `lib/l10n/` → **Flutter Intl: Generate** 即可生成对应的 Dart 代码。
133
+ 工具为每个 locale 生成对应的 `.arb` 文件。在 IDE 中右键 `lib/l10n/` → **Flutter Intl: Generate** 即可生成对应的 Dart 代码。
118
134
 
119
135
  ### 5. 翻译
120
136
 
121
- 翻译人员只需在非主语言的 ARB 文件中填入对应翻译,例如:
137
+ 翻译支持两种方式:
138
+
139
+ **人工翻译** — 直接在非主语言的 ARB 文件中填入对应翻译:
122
140
 
123
141
  ```json
124
- // intl_en.arb
142
+ // intl_en.arb(手动填写)
125
143
  {
126
144
  "t5eb63bbb": "Message Settings",
127
145
  "t3f2a1b2": "Receive System Notifications"
128
146
  }
129
147
  ```
130
148
 
149
+ **自动翻译** — 通过 `-t` 参数指定目标语言,工具调用翻译 API 自动填充:
150
+
151
+ ```bash
152
+ extractor -l zh en ja -t en ja -c baidu --appKey xxx --secretKey xxx
153
+ ```
154
+
155
+ > 自动翻译仅处理**新增条目**,已有翻译不会被覆盖,人工修正的内容始终安全。
156
+
131
157
  ## 合并策略
132
158
 
133
159
  - 已有 ARB 文件中的条目**保留不动**(保护手动修改的翻译)
134
160
  - 新增条目**不会覆盖**已有同 key 条目
161
+ - 翻译 API 仅翻译空占位的新条目,已翻译内容不受影响
162
+ - 翻译失败不阻断其他语言文件的写入
135
163
  - 最终按 key 字母序排序输出,保持文件可读性
136
164
 
137
- ## 后续步骤
165
+ ## 翻译 API 申请
138
166
 
139
- ```
140
- 1. IDE 中右键 lib/l10n/ → Flutter Intl: Generate(或等待 IDE 自动触发)
141
- 2. fvm flutter analyze
142
- ```
167
+ | 渠道 | 申请地址 | 所需凭证 |
168
+ |------|---------|---------|
169
+ | 百度 | [fanyi-api.baidu.com](https://fanyi-api.baidu.com/) | appid + secretKey |
170
+ | 有道 | [ai.youdao.com](https://ai.youdao.com/) | appKey + secretKey |
171
+ | 谷歌 | [cloud.google.com/translate](https://cloud.google.com/translate) | API Key |
143
172
 
144
173
  ## 开发
145
174
 
@@ -0,0 +1,25 @@
1
+ export type Channel = 'baidu' | 'youdao' | 'google';
2
+ /**
3
+ * 全局配置翻译参数(channel、appKey、secretKey)
4
+ * 所有参数均可选,仅更新传入的字段
5
+ */
6
+ export declare function setTranslationConfig(config: {
7
+ channel?: Channel;
8
+ appKey?: string;
9
+ secretKey?: string;
10
+ }): void;
11
+ /**
12
+ * 批量翻译器:将多条中文用分隔符拼接后一次请求翻译接口,再从响应中拆分获得各条译文。
13
+ * 与 translator 的区别:
14
+ * - translator 对每条文本分别发起一次 API 请求(BATCH=1)
15
+ * - batchTranslator 将一批文本拼接后仅发起一次请求,大幅减少 API 调用次数
16
+ */
17
+ export declare function batchTranslator(obj: any, to: string, cb: Function): Promise<any>;
18
+ /**
19
+ * 单条翻译器:对每条文本分别发起一次翻译 API 请求(逐条模式)。
20
+ *
21
+ * 与 batchTranslator 的区别:
22
+ * - translator 对每条文本独立调用 API(BATCH=1),更稳定但调用次数多
23
+ * - batchTranslator 将多条文本拼接后一次请求,调用次数更少
24
+ */
25
+ export declare function translator(obj: any, to: string, cb: Function): Promise<any>;
@@ -0,0 +1 @@
1
+ 'use strict';const a0_0x5cb51a=a0_0x36fe;(function(_0x52b220,_0x5e87b9){const _0x2e6bc6=a0_0x36fe,_0x1c7787=_0x52b220();while(!![]){try{const _0x45636c=-parseInt(_0x2e6bc6(0x1c4))/0x1+parseInt(_0x2e6bc6(0x1cb))/0x2*(-parseInt(_0x2e6bc6(0x1fb))/0x3)+-parseInt(_0x2e6bc6(0x1ca))/0x4*(parseInt(_0x2e6bc6(0x1d6))/0x5)+parseInt(_0x2e6bc6(0x20c))/0x6*(-parseInt(_0x2e6bc6(0x210))/0x7)+-parseInt(_0x2e6bc6(0x208))/0x8+-parseInt(_0x2e6bc6(0x1c0))/0x9*(-parseInt(_0x2e6bc6(0x1c6))/0xa)+parseInt(_0x2e6bc6(0x1d1))/0xb;if(_0x45636c===_0x5e87b9)break;else _0x1c7787['push'](_0x1c7787['shift']());}catch(_0x42bc63){_0x1c7787['push'](_0x1c7787['shift']());}}}(a0_0x18b3,0xac245));var __importDefault=this&&this[a0_0x5cb51a(0x1e5)]||function(_0x133ac3){const _0x507371=a0_0x5cb51a;return _0x133ac3&&_0x133ac3[_0x507371(0x1cf)]?_0x133ac3:{'default':_0x133ac3};};function a0_0x36fe(_0x375372,_0x32541e){_0x375372=_0x375372-0x1c0;const _0x18b3b2=a0_0x18b3();let _0x36feac=_0x18b3b2[_0x375372];return _0x36feac;}Object[a0_0x5cb51a(0x20d)](exports,a0_0x5cb51a(0x1cf),{'value':!![]}),exports[a0_0x5cb51a(0x1f3)]=setTranslationConfig,exports['batchTranslator']=batchTranslator,exports[a0_0x5cb51a(0x205)]=translator;const axios_1=__importDefault(require('axios')),crypto_js_1=__importDefault(require(a0_0x5cb51a(0x1d2)));let channel=a0_0x5cb51a(0x20e),appKey='',secretKey='';function setTranslationConfig(_0x143f92){const _0x2416f8=a0_0x5cb51a;if(_0x143f92[_0x2416f8(0x1c9)]!==undefined)channel=_0x143f92[_0x2416f8(0x1c9)];if(_0x143f92[_0x2416f8(0x1ef)]!==undefined)appKey=_0x143f92[_0x2416f8(0x1ef)];if(_0x143f92[_0x2416f8(0x1ff)]!==undefined)secretKey=_0x143f92[_0x2416f8(0x1ff)];}function a0_0x18b3(){const _0x1cdca7=['952475SuzxKs','trans_result','now','map','join','enc','Hex','slice','data','error','round','\x20-\x20','-\x20翻译:------\x20','toFixed','翻译请求完成','__importDefault','assign','-\x20翻译:------\x20警告:拆分结果数量(','Cloud\x20翻译\x20API\x20返回格式异常','message','批量翻译请求发起(共\x20','有道翻译返回格式异常','reason','-\x20翻译:------\x20进度:','zh-CN','appKey','\x20条,每批\x20','entries','min','setTranslationConfig','length','zh-CHS','translations','allSettled',')与输入(','translation','SHA256','98799vQtNXa','zh-CHT','dst','catch','secretKey','translatedText','MD5','substring','error_code','then','translator','split','post','4174320IWLBxx','https://fanyi-api.baidu.com/api/trans/vip/translate?','批量翻译请求完成','getTime','1236nvkgKm','defineProperty','baidu','https://openapi.youdao.com/api?','6755XwyyFv','9RMLjqt','replace','get','errorCode','835102pwiyFF','response','8693350WnGesL','\x20条,拼接模式)','default','channel','8aNSGWi','38nfOQzH','value','random','toString','__esModule','翻译请求发起(共\x20','26379727oVsbvl','crypto-js','toLowerCase','log','-\x20翻译:------\x20批量翻译失败:\x20'];a0_0x18b3=function(){return _0x1cdca7;};return a0_0x18b3();}async function batchTranslator(_0x39eef7,_0x9b1380,_0x89fdf5){const _0x55617e=a0_0x5cb51a;if(!channel||!appKey)return _0x89fdf5&&_0x89fdf5(_0x39eef7);const _0x566741=Object[_0x55617e(0x1f1)](_0x39eef7)['filter'](([_0x4b0f73])=>!/^__/g['test'](_0x4b0f73));if(!_0x566741[_0x55617e(0x1f4)])return _0x89fdf5&&_0x89fdf5(_0x39eef7);const _0x2834e1={'baidu':baiduTranslator,'youdao':youDaoTranslator,'google':googleTranslator}[channel],_0x27d20b={},_0x1be618=0xa,_0x43f2bf='[#]',_0x53619a=/\[\s*#\s*\]/g;console['log'](new Array(0x50)['join']('-')),console['log']('-\x20翻译:------\x20'+_0x9b1380+'\x20-\x20'+channel+_0x55617e(0x1ea)+_0x566741[_0x55617e(0x1f4)]+_0x55617e(0x1f0)+_0x1be618+_0x55617e(0x1c7));for(let _0xa07e36=0x0;_0xa07e36<_0x566741['length'];_0xa07e36+=_0x1be618){const _0x45aea4=_0x566741[_0x55617e(0x1dd)](_0xa07e36,_0xa07e36+_0x1be618),_0x4f562b=_0x45aea4[_0x55617e(0x1d9)](([_0x37e786,_0x14579c])=>_0x14579c),_0x46be11=_0x4f562b['join'](_0x43f2bf);try{const _0x59bc64=await _0x2834e1(_0x46be11,_0x9b1380,{'appKey':appKey,'secretKey':secretKey}),_0x501d69=_0x59bc64[_0x55617e(0x206)](_0x53619a);for(let _0x3b93c6=0x0;_0x3b93c6<_0x45aea4[_0x55617e(0x1f4)];_0x3b93c6++){const [_0x8c9c9d,_0x1c882d]=_0x45aea4[_0x3b93c6];_0x27d20b[_0x8c9c9d]=(_0x501d69[_0x3b93c6]||_0x1c882d)['trim']();}_0x501d69[_0x55617e(0x1f4)]!==_0x45aea4['length']&&console[_0x55617e(0x1d4)](_0x55617e(0x1e7)+_0x501d69['length']+_0x55617e(0x1f8)+_0x45aea4[_0x55617e(0x1f4)]+')不匹配,请检查分隔符是否被翻译接口修改');}catch(_0x8654fc){console[_0x55617e(0x1d4)](_0x55617e(0x1d5)+((_0x8654fc===null||_0x8654fc===void 0x0?void 0x0:_0x8654fc[_0x55617e(0x1e9)])||_0x8654fc));}console[_0x55617e(0x1d4)](_0x55617e(0x1ed)+(Math[_0x55617e(0x1f2)](_0xa07e36+_0x1be618,_0x566741[_0x55617e(0x1f4)])/_0x566741[_0x55617e(0x1f4)]*0x64)['toFixed'](0x2)+'%');if(_0xa07e36+_0x1be618<_0x566741[_0x55617e(0x1f4)])await new Promise(_0x4eca88=>setTimeout(_0x4eca88,0x3e8));}console[_0x55617e(0x1d4)](_0x55617e(0x1e2)+_0x9b1380+_0x55617e(0x1e1)+channel+_0x55617e(0x20a)),console[_0x55617e(0x1d4)](new Array(0x50)[_0x55617e(0x1da)]('-')),_0x89fdf5&&_0x89fdf5(Object['assign'](_0x39eef7,_0x27d20b));}async function translator(_0x34b6ec,_0x55ec5c,_0x1b42a5){const _0x4a9044=a0_0x5cb51a;var _0x322f4c;if(!channel||!appKey)return _0x1b42a5&&_0x1b42a5(_0x34b6ec);const _0x2cff66=Object[_0x4a9044(0x1f1)](_0x34b6ec)['filter'](([_0x13ad99])=>!/^__/g['test'](_0x13ad99));if(!_0x2cff66['length'])return _0x1b42a5&&_0x1b42a5(_0x34b6ec);const _0x4f5005={'baidu':baiduTranslator,'youdao':youDaoTranslator,'google':googleTranslator}[channel],_0x459957={},_0x1a3560=0x1;console[_0x4a9044(0x1d4)](new Array(0x50)[_0x4a9044(0x1da)]('-')),console[_0x4a9044(0x1d4)](_0x4a9044(0x1e2)+_0x55ec5c+_0x4a9044(0x1e1)+channel+_0x4a9044(0x1d0)+_0x2cff66[_0x4a9044(0x1f4)]+_0x4a9044(0x1f0)+_0x1a3560+')');for(let _0x50ebb3=0x0;_0x50ebb3<_0x2cff66[_0x4a9044(0x1f4)];_0x50ebb3+=_0x1a3560){const _0x1d4056=_0x2cff66[_0x4a9044(0x1dd)](_0x50ebb3,_0x50ebb3+_0x1a3560),_0xef0c10=await Promise[_0x4a9044(0x1f7)](_0x1d4056[_0x4a9044(0x1d9)](([_0x44de33,_0x25d0b1])=>_0x4f5005(_0x25d0b1,_0x55ec5c,{'appKey':appKey,'secretKey':secretKey})[_0x4a9044(0x204)](_0xc9975d=>({'k':_0x44de33,'t':_0xc9975d}))));for(const _0x4d94c5 of _0xef0c10){_0x4d94c5['status']==='fulfilled'?_0x459957[_0x4d94c5[_0x4a9044(0x1cc)]['k']]=_0x4d94c5[_0x4a9044(0x1cc)]['t']:console[_0x4a9044(0x1d4)]('-\x20翻译:------\x20翻译失败:\x20'+(((_0x322f4c=_0x4d94c5[_0x4a9044(0x1ec)])===null||_0x322f4c===void 0x0?void 0x0:_0x322f4c[_0x4a9044(0x1e9)])||_0x4d94c5['reason']));}console[_0x4a9044(0x1d4)]('-\x20翻译:------\x20进度:'+(Math[_0x4a9044(0x1f2)](_0x50ebb3+_0x1a3560,_0x2cff66[_0x4a9044(0x1f4)])/_0x2cff66[_0x4a9044(0x1f4)]*0x64)[_0x4a9044(0x1e3)](0x2)+'%');if(_0x50ebb3+_0x1a3560<_0x2cff66[_0x4a9044(0x1f4)])await new Promise(_0x2c5862=>setTimeout(_0x2c5862,0x3e8));}console['log']('-\x20翻译:------\x20'+_0x55ec5c+_0x4a9044(0x1e1)+channel+_0x4a9044(0x1e4)),console[_0x4a9044(0x1d4)](new Array(0x50)[_0x4a9044(0x1da)]('-')),_0x1b42a5&&_0x1b42a5(Object[_0x4a9044(0x1e6)](_0x34b6ec,_0x459957));}const BAIDU_TO_FIX={'zh-cn':'zh','en-us':'en','en-gb':'en','zh-hk':'cht','zh-tw':'cht','ja-jp':'jp','ja':'jp'};function baiduTranslator(_0xf20b4f,_0x20a57f,_0x1cbb8a){const _0x2660ef=a0_0x5cb51a,_0x13d8df=new Date()['getTime']()+'_'+Math['random']()[_0x2660ef(0x1ce)](0x24)[_0x2660ef(0x1dd)](0x2,0x8),_0x4c2bac=''+Date[_0x2660ef(0x1d8)]()[_0x2660ef(0x1ce)](0x24)+'_',_0x53f566=_0xf20b4f[_0x2660ef(0x1c1)](/\n/g,_0x4c2bac),_0x3e8144=crypto_js_1[_0x2660ef(0x1c8)][_0x2660ef(0x201)](_0x1cbb8a[_0x2660ef(0x1ef)]+_0x53f566+_0x13d8df+_0x1cbb8a['secretKey'])[_0x2660ef(0x1ce)](),_0x123ef5=new URLSearchParams({'q':_0x53f566,'appid':_0x1cbb8a['appKey'],'salt':_0x13d8df,'from':'zh','to':BAIDU_TO_FIX[_0x20a57f[_0x2660ef(0x1d3)]()]||_0x20a57f,'sign':_0x3e8144})['toString']();return new Promise((_0x4d36eb,_0x2d9254)=>{const _0xcdfb58=_0x2660ef;axios_1[_0xcdfb58(0x1c8)][_0xcdfb58(0x1c2)](_0xcdfb58(0x209)+_0x123ef5)['then'](_0x2ae471=>{const _0x516d0a=_0xcdfb58;var _0x5aeb60,_0x16276f,_0x4682cd;if((_0x16276f=(_0x5aeb60=_0x2ae471['data'])===null||_0x5aeb60===void 0x0?void 0x0:_0x5aeb60[_0x516d0a(0x1d7)])===null||_0x16276f===void 0x0?void 0x0:_0x16276f[0x0]){const _0x28ae83=_0x2ae471[_0x516d0a(0x1de)][_0x516d0a(0x1d7)][0x0][_0x516d0a(0x1fd)][_0x516d0a(0x1c1)](new RegExp(_0x4c2bac,'g'),'\x0a');_0x4d36eb(_0x28ae83);}else _0x2d9254(((_0x4682cd=_0x2ae471['data'])===null||_0x4682cd===void 0x0?void 0x0:_0x4682cd[_0x516d0a(0x203)])||'百度翻译返回格式异常');})[_0xcdfb58(0x1fe)](_0x3c8cb4=>{const _0x1c2b5d=_0xcdfb58;_0x2d9254(_0x3c8cb4[_0x1c2b5d(0x1e9)]||_0x3c8cb4);});});}const YOUDAO_TO_FIX={'zh-cn':a0_0x5cb51a(0x1f5),'en-us':'en','en-gb':'en','zh-hk':a0_0x5cb51a(0x1fc),'zh-tw':a0_0x5cb51a(0x1fc),'ja-jp':'ja'};function youDaoTranslator(_0x55f2dd,_0x3ef40f,_0x3527e9){const _0x1b24dd=a0_0x5cb51a,_0x1addff=new Date()['getTime']()+'_'+Math[_0x1b24dd(0x1cd)]()[_0x1b24dd(0x1ce)](0x24)[_0x1b24dd(0x1dd)](0x2,0x8),_0x1ce144=Math[_0x1b24dd(0x1e0)](new Date()[_0x1b24dd(0x20b)]()/0x3e8),_0x5560cc=_0x2f28e4=>{const _0x4cbb38=_0x1b24dd,_0xf14c82=_0x2f28e4[_0x4cbb38(0x1f4)];if(_0xf14c82<=0x14)return _0x2f28e4;return _0x2f28e4[_0x4cbb38(0x202)](0x0,0xa)+_0xf14c82+_0x2f28e4[_0x4cbb38(0x202)](_0xf14c82-0xa,_0xf14c82);},_0x196ff1=''+Date[_0x1b24dd(0x1d8)]()['toString'](0x24)+'_',_0x1b0be8=_0x55f2dd['replace'](/\n/g,_0x196ff1),_0x1c2c1a=_0x3527e9[_0x1b24dd(0x1ef)]+_0x5560cc(_0x1b0be8)+_0x1addff+_0x1ce144+_0x3527e9[_0x1b24dd(0x1ff)],_0xb0963e=crypto_js_1[_0x1b24dd(0x1c8)][_0x1b24dd(0x1fa)](_0x1c2c1a)[_0x1b24dd(0x1ce)](crypto_js_1[_0x1b24dd(0x1c8)][_0x1b24dd(0x1db)][_0x1b24dd(0x1dc)]),_0x4542e9=new URLSearchParams({'q':_0x1b0be8,'appKey':_0x3527e9[_0x1b24dd(0x1ef)],'salt':_0x1addff,'from':'zh','to':YOUDAO_TO_FIX[_0x3ef40f[_0x1b24dd(0x1d3)]()]||_0x3ef40f,'sign':_0xb0963e,'signType':'v3','curtime':''+_0x1ce144})['toString']();return new Promise((_0x3d7d02,_0x382cab)=>{const _0x2df9c2=_0x1b24dd;axios_1[_0x2df9c2(0x1c8)]['get'](_0x2df9c2(0x20f)+_0x4542e9)[_0x2df9c2(0x204)](_0x167642=>{const _0x15fbca=_0x2df9c2;var _0x341dae,_0x170329;if(((_0x341dae=_0x167642['data'])===null||_0x341dae===void 0x0?void 0x0:_0x341dae[_0x15fbca(0x1c3)])==='0'){const _0x4ef7e6=(''+_0x167642[_0x15fbca(0x1de)][_0x15fbca(0x1f9)][0x0])[_0x15fbca(0x1c1)](new RegExp(_0x196ff1,'g'),'\x0a');_0x3d7d02(_0x4ef7e6);}else _0x382cab(((_0x170329=_0x167642[_0x15fbca(0x1de)])===null||_0x170329===void 0x0?void 0x0:_0x170329[_0x15fbca(0x1c3)])||_0x15fbca(0x1eb));})[_0x2df9c2(0x1fe)](_0x50d84c=>{const _0x534cc3=_0x2df9c2;_0x382cab(_0x50d84c[_0x534cc3(0x1e9)]||_0x50d84c);});});}const GOOGLE_TO_FIX={'zh-cn':a0_0x5cb51a(0x1ee),'en-us':'en','en-gb':'en','zh-hk':'zh-HK','zh-tw':'zh-TW','ja-jp':'ja'};function googleTranslator(_0x54a6aa,_0xc84eea,_0x2f1cc){const _0x19ed87=a0_0x5cb51a,_0x477337='https://translation.googleapis.com/language/translate/v2?key='+_0x2f1cc[_0x19ed87(0x1ef)],_0x4a9787={'q':[_0x54a6aa],'target':GOOGLE_TO_FIX[_0xc84eea[_0x19ed87(0x1d3)]()]||_0xc84eea,'source':'zh-CN','format':'text'};return new Promise((_0x1bec5e,_0x2ec5c4)=>{const _0x35945c=_0x19ed87;axios_1[_0x35945c(0x1c8)][_0x35945c(0x207)](_0x477337,_0x4a9787)[_0x35945c(0x204)](_0x19483c=>{const _0x12d74a=_0x35945c;var _0x54af73,_0x49310e,_0x1fc067,_0x505d8e,_0x4a5624;((_0x1fc067=(_0x49310e=(_0x54af73=_0x19483c['data'])===null||_0x54af73===void 0x0?void 0x0:_0x54af73['data'])===null||_0x49310e===void 0x0?void 0x0:_0x49310e['translations'])===null||_0x1fc067===void 0x0?void 0x0:_0x1fc067[0x0])?_0x1bec5e(_0x19483c[_0x12d74a(0x1de)][_0x12d74a(0x1de)][_0x12d74a(0x1f6)][0x0][_0x12d74a(0x200)]):_0x2ec5c4(((_0x4a5624=(_0x505d8e=_0x19483c[_0x12d74a(0x1de)])===null||_0x505d8e===void 0x0?void 0x0:_0x505d8e[_0x12d74a(0x1df)])===null||_0x4a5624===void 0x0?void 0x0:_0x4a5624[_0x12d74a(0x1e9)])||_0x12d74a(0x1e8));})['catch'](_0x2f5e25=>{const _0x23eeee=_0x35945c;var _0x1839ca,_0x4a648c,_0x5def30;_0x2ec5c4(((_0x5def30=(_0x4a648c=(_0x1839ca=_0x2f5e25[_0x23eeee(0x1c5)])===null||_0x1839ca===void 0x0?void 0x0:_0x1839ca[_0x23eeee(0x1de)])===null||_0x4a648c===void 0x0?void 0x0:_0x4a648c[_0x23eeee(0x1df)])===null||_0x5def30===void 0x0?void 0x0:_0x5def30['message'])||_0x2f5e25['message']);});});}
@@ -97,3 +97,7 @@ export declare function buildReplacement(entry: {
97
97
  key: string;
98
98
  params?: I18nParam[];
99
99
  }): string;
100
+ export declare function mergeLocaleFile(obj: Record<string, any>, filePath: string, translateLocale: string, force: boolean): Promise<{
101
+ addObj: object;
102
+ delObj: object;
103
+ }>;
@@ -1 +1 @@
1
- 'use strict';const a0_0x3f9333=a0_0x3ecb;(function(_0x6d4c7d,_0x176ceb){const _0x1056c9=a0_0x3ecb,_0x2e3fcd=_0x6d4c7d();while(!![]){try{const _0x5c52ba=-parseInt(_0x1056c9(0x18e))/0x1*(-parseInt(_0x1056c9(0x192))/0x2)+parseInt(_0x1056c9(0x19d))/0x3*(-parseInt(_0x1056c9(0x193))/0x4)+parseInt(_0x1056c9(0x18c))/0x5*(parseInt(_0x1056c9(0x1a5))/0x6)+parseInt(_0x1056c9(0x1a4))/0x7+parseInt(_0x1056c9(0x187))/0x8+parseInt(_0x1056c9(0x190))/0x9*(parseInt(_0x1056c9(0x1a3))/0xa)+parseInt(_0x1056c9(0x19f))/0xb*(-parseInt(_0x1056c9(0x1a6))/0xc);if(_0x5c52ba===_0x176ceb)break;else _0x2e3fcd['push'](_0x2e3fcd['shift']());}catch(_0x822833){_0x2e3fcd['push'](_0x2e3fcd['shift']());}}}(a0_0x556e,0xb9dd1));var __importDefault=this&&this[a0_0x3f9333(0x1a1)]||function(_0x38c172){return _0x38c172&&_0x38c172['__esModule']?_0x38c172:{'default':_0x38c172};};Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports[a0_0x3f9333(0x198)]=makeKey,exports[a0_0x3f9333(0x1a7)]=extractBalanced,exports['extractTranslation']=extractTranslation,exports[a0_0x3f9333(0x18d)]=parseNamedArguments,exports['buildReplacement']=buildReplacement;const crypto_js_1=__importDefault(require(a0_0x3f9333(0x197)));function makeKey(_0x2c21c1){const _0x35f113=a0_0x3f9333;return't'+crypto_js_1[_0x35f113(0x1a8)][_0x35f113(0x196)](_0x2c21c1)[_0x35f113(0x19b)]()[_0x35f113(0x18f)](0x0,0xc);}function a0_0x556e(){const _0x2c27e9=['5085605MvTcPZ','44040NagWuZ','21588xshvSR','extractBalanced','default','4010040iuIKCM','test','expr','length','match','25RxDXGm','parseNamedArguments','5777Fnyxli','substring','4023ATFJCT','index','262BIWACt','141364xDxlGX','slice','trim','MD5','crypto-js','makeKey','key','S.current.','toString','name','123ShWprI','params','1848CdhoAd','push','__importDefault','map','10990ToAfQX'];a0_0x556e=function(){return _0x2c27e9;};return a0_0x556e();}function extractBalanced(_0x28d0a8,_0x23e08f,_0x41c107,_0x1ad2db){const _0x2af29b=a0_0x3f9333;if(_0x28d0a8[_0x1ad2db]!==_0x23e08f)return null;let _0x38fe85=0x0;for(let _0x3ec3d1=_0x1ad2db;_0x3ec3d1<_0x28d0a8[_0x2af29b(0x18a)];_0x3ec3d1++){const _0x94251=_0x28d0a8[_0x3ec3d1];if(_0x94251===_0x23e08f)_0x38fe85++;else{if(_0x94251===_0x41c107){_0x38fe85--;if(_0x38fe85===0x0)return _0x28d0a8['slice'](_0x1ad2db+0x1,_0x3ec3d1);}}}return null;}function a0_0x3ecb(_0x279861,_0x3846b5){_0x279861=_0x279861-0x187;const _0x556eec=a0_0x556e();let _0x3ecb8a=_0x556eec[_0x279861];return _0x3ecb8a;}function extractTranslation(_0x519941){const _0x814c30=a0_0x3f9333,_0x3aa7fc=[],_0x5cceb6=/\$t\(\s*(['"])/g;let _0x30a9a9;while((_0x30a9a9=_0x5cceb6['exec'](_0x519941))!==null){const _0x54aa1f=_0x30a9a9[0x1],_0x1749eb=_0x30a9a9['index']+_0x30a9a9[0x0][_0x814c30(0x18a)];let _0x21fa1b='',_0x46fdf8=_0x1749eb;while(_0x46fdf8<_0x519941['length']){if(_0x519941[_0x46fdf8]==='\x5c')_0x21fa1b+=_0x519941[_0x46fdf8+0x1],_0x46fdf8+=0x2;else{if(_0x519941[_0x46fdf8]===_0x54aa1f)break;else _0x21fa1b+=_0x519941[_0x46fdf8],_0x46fdf8++;}}if(_0x519941[_0x46fdf8]!==_0x54aa1f)continue;_0x46fdf8++;if(!_0x21fa1b)continue;_0x3aa7fc[_0x814c30(0x1a0)]({'template':_0x21fa1b,'start':_0x30a9a9[_0x814c30(0x191)],'end':_0x46fdf8});}return _0x3aa7fc;}function parseNamedArguments(_0xa4e5a0){const _0x44bedf=a0_0x3f9333,_0x57b570=[];let _0x59c408=0x0;while(_0x59c408<_0xa4e5a0[_0x44bedf(0x18a)]){while(_0x59c408<_0xa4e5a0['length']&&/[\s,]/[_0x44bedf(0x188)](_0xa4e5a0[_0x59c408]))_0x59c408++;if(_0x59c408>=_0xa4e5a0[_0x44bedf(0x18a)])break;const _0x4b750d=_0xa4e5a0[_0x44bedf(0x194)](_0x59c408)[_0x44bedf(0x18b)](/^'(\w+)'\s*:\s*/);if(!_0x4b750d)break;const _0x590509=_0x4b750d[0x1];_0x59c408+=_0x4b750d[0x0][_0x44bedf(0x18a)];let _0x5e176e='',_0x59f794=0x0;while(_0x59c408<_0xa4e5a0['length']){const _0x20263b=_0xa4e5a0[_0x59c408];if(_0x20263b==='('||_0x20263b==='['||_0x20263b==='{')_0x59f794++;else{if(_0x20263b===')'||_0x20263b===']'){if(_0x59f794===0x0)break;_0x59f794--;}else{if(_0x20263b==='}'){if(_0x59f794===0x0)break;_0x59f794--;}else{if(_0x20263b===','&&_0x59f794===0x0)break;}}}_0x5e176e+=_0x20263b,_0x59c408++;}_0x5e176e[_0x44bedf(0x195)]()&&_0x57b570[_0x44bedf(0x1a0)]({'name':_0x590509,'expr':_0x5e176e[_0x44bedf(0x195)]()});}return _0x57b570;}function buildReplacement(_0x5b8e1d){const _0x27730a=a0_0x3f9333;if(!_0x5b8e1d[_0x27730a(0x19e)]||_0x5b8e1d['params'][_0x27730a(0x18a)]===0x0)return _0x27730a(0x19a)+_0x5b8e1d[_0x27730a(0x199)];const _0x2da240=_0x5b8e1d[_0x27730a(0x19e)][_0x27730a(0x1a2)](_0x3cd14c=>_0x3cd14c[_0x27730a(0x19c)]+':\x20'+_0x3cd14c[_0x27730a(0x189)])['join'](',\x20');return'S.current.'+_0x5b8e1d[_0x27730a(0x199)]+'('+_0x2da240+')';}
1
+ 'use strict';const a1_0x931381=a1_0x4456;(function(_0x2c3042,_0x2578e6){const _0x26f5cf=a1_0x4456,_0x2b22ce=_0x2c3042();while(!![]){try{const _0x9e0332=-parseInt(_0x26f5cf(0x145))/0x1*(-parseInt(_0x26f5cf(0x142))/0x2)+-parseInt(_0x26f5cf(0x12c))/0x3*(-parseInt(_0x26f5cf(0x11c))/0x4)+parseInt(_0x26f5cf(0x13a))/0x5*(parseInt(_0x26f5cf(0x146))/0x6)+parseInt(_0x26f5cf(0x132))/0x7*(parseInt(_0x26f5cf(0x118))/0x8)+-parseInt(_0x26f5cf(0x123))/0x9+-parseInt(_0x26f5cf(0x11d))/0xa*(parseInt(_0x26f5cf(0x129))/0xb)+-parseInt(_0x26f5cf(0x13f))/0xc*(parseInt(_0x26f5cf(0x12f))/0xd);if(_0x9e0332===_0x2578e6)break;else _0x2b22ce['push'](_0x2b22ce['shift']());}catch(_0x591ec3){_0x2b22ce['push'](_0x2b22ce['shift']());}}}(a1_0x2f2c,0xac651));function a1_0x4456(_0x4e0764,_0x29ac40){_0x4e0764=_0x4e0764-0x115;const _0x2f2c56=a1_0x2f2c();let _0x445685=_0x2f2c56[_0x4e0764];return _0x445685;}var __importDefault=this&&this[a1_0x931381(0x135)]||function(_0x50fba6){const _0x569da6=a1_0x931381;return _0x50fba6&&_0x50fba6[_0x569da6(0x121)]?_0x50fba6:{'default':_0x50fba6};};Object[a1_0x931381(0x11a)](exports,a1_0x931381(0x121),{'value':!![]}),exports[a1_0x931381(0x144)]=makeKey,exports[a1_0x931381(0x141)]=extractBalanced,exports[a1_0x931381(0x116)]=extractTranslation,exports[a1_0x931381(0x143)]=parseNamedArguments,exports[a1_0x931381(0x131)]=buildReplacement,exports[a1_0x931381(0x12b)]=mergeLocaleFile;const crypto_js_1=__importDefault(require(a1_0x931381(0x137))),js_utils_plus_1=require(a1_0x931381(0x122)),translation_1=require('./translation');function a1_0x2f2c(){const _0x5c364f=['10645551LeZluk','stringify','MD5','index','slice','name','7018OUwjQq','toString','mergeLocaleFile','51NPTzXh','S.current.','exec','78CGlbgp','objectOmit','buildReplacement','63lpHFSd','objectNested','expr','__importDefault','test','crypto-js','length','join','39995WasDsV','objectFlatten','push','key','map','191868uTWbbq','substring','extractBalanced','267164RSJWuX','parseNamedArguments','makeKey','1ppCTXF','720NMQUhR','batchTranslator','extractTranslation','trim','603304nytQAI','log','defineProperty','default','120908fknosI','4720ghTorW','keys','writeFileSync','params','__esModule','js-utils-plus'];a1_0x2f2c=function(){return _0x5c364f;};return a1_0x2f2c();}function makeKey(_0x22d54a){const _0x506fbf=a1_0x931381;return't'+crypto_js_1[_0x506fbf(0x11b)][_0x506fbf(0x125)](_0x22d54a)[_0x506fbf(0x12a)]()[_0x506fbf(0x140)](0x0,0xc);}function extractBalanced(_0x42d572,_0x16cd68,_0x19da7e,_0x56faf0){const _0x3b8f9d=a1_0x931381;if(_0x42d572[_0x56faf0]!==_0x16cd68)return null;let _0x479dda=0x0;for(let _0x116a3b=_0x56faf0;_0x116a3b<_0x42d572[_0x3b8f9d(0x138)];_0x116a3b++){const _0x3fcbd5=_0x42d572[_0x116a3b];if(_0x3fcbd5===_0x16cd68)_0x479dda++;else{if(_0x3fcbd5===_0x19da7e){_0x479dda--;if(_0x479dda===0x0)return _0x42d572[_0x3b8f9d(0x127)](_0x56faf0+0x1,_0x116a3b);}}}return null;}function extractTranslation(_0x39dd0f){const _0x315264=a1_0x931381,_0xd28a4e=[],_0x2093da=/\$t\(\s*(['"])/g;let _0x2243fc;while((_0x2243fc=_0x2093da[_0x315264(0x12e)](_0x39dd0f))!==null){const _0x358e6a=_0x2243fc[0x1],_0x4dc8b3=_0x2243fc[_0x315264(0x126)]+_0x2243fc[0x0]['length'];let _0x5f009e='',_0x4d777f=_0x4dc8b3;while(_0x4d777f<_0x39dd0f[_0x315264(0x138)]){if(_0x39dd0f[_0x4d777f]==='\x5c')_0x5f009e+=_0x39dd0f[_0x4d777f+0x1],_0x4d777f+=0x2;else{if(_0x39dd0f[_0x4d777f]===_0x358e6a)break;else _0x5f009e+=_0x39dd0f[_0x4d777f],_0x4d777f++;}}if(_0x39dd0f[_0x4d777f]!==_0x358e6a)continue;_0x4d777f++;if(!_0x5f009e)continue;_0xd28a4e['push']({'template':_0x5f009e,'start':_0x2243fc[_0x315264(0x126)],'end':_0x4d777f});}return _0xd28a4e;}function parseNamedArguments(_0x5c6900){const _0x540fdf=a1_0x931381,_0xd0ee1b=[];let _0x4bfed1=0x0;while(_0x4bfed1<_0x5c6900[_0x540fdf(0x138)]){while(_0x4bfed1<_0x5c6900['length']&&/[\s,]/[_0x540fdf(0x136)](_0x5c6900[_0x4bfed1]))_0x4bfed1++;if(_0x4bfed1>=_0x5c6900['length'])break;const _0x359982=_0x5c6900[_0x540fdf(0x127)](_0x4bfed1)['match'](/^'(\w+)'\s*:\s*/);if(!_0x359982)break;const _0x42a6b7=_0x359982[0x1];_0x4bfed1+=_0x359982[0x0][_0x540fdf(0x138)];let _0x1c06d8='',_0x2502fd=0x0;while(_0x4bfed1<_0x5c6900['length']){const _0x37c3df=_0x5c6900[_0x4bfed1];if(_0x37c3df==='('||_0x37c3df==='['||_0x37c3df==='{')_0x2502fd++;else{if(_0x37c3df===')'||_0x37c3df===']'){if(_0x2502fd===0x0)break;_0x2502fd--;}else{if(_0x37c3df==='}'){if(_0x2502fd===0x0)break;_0x2502fd--;}else{if(_0x37c3df===','&&_0x2502fd===0x0)break;}}}_0x1c06d8+=_0x37c3df,_0x4bfed1++;}_0x1c06d8[_0x540fdf(0x117)]()&&_0xd0ee1b[_0x540fdf(0x13c)]({'name':_0x42a6b7,'expr':_0x1c06d8[_0x540fdf(0x117)]()});}return _0xd0ee1b;}function buildReplacement(_0x591205){const _0x110614=a1_0x931381;if(!_0x591205[_0x110614(0x120)]||_0x591205['params'][_0x110614(0x138)]===0x0)return _0x110614(0x12d)+_0x591205[_0x110614(0x13d)];const _0x54468d=_0x591205['params'][_0x110614(0x13e)](_0x3d3379=>_0x3d3379[_0x110614(0x128)]+':\x20'+_0x3d3379[_0x110614(0x134)])[_0x110614(0x139)](',\x20');return _0x110614(0x12d)+_0x591205['key']+'('+_0x54468d+')';}async function mergeLocaleFile(_0x18f9a6,_0x52ebe5,_0x2b7e9a,_0x30f6d9){const _0xb8373e=a1_0x931381,_0xb88762=(0x0,js_utils_plus_1['readFileSync'])(_0x52ebe5,!![])||{},_0x40e0c2=(0x0,js_utils_plus_1[_0xb8373e(0x13b)])(_0x18f9a6),_0x5757d2=(0x0,js_utils_plus_1[_0xb8373e(0x13b)])(_0xb88762),_0x31708e=(0x0,js_utils_plus_1['objectOmit'])(_0x40e0c2,Object['keys'](_0x5757d2));if(_0x2b7e9a&&Object[_0xb8373e(0x11e)](_0x31708e)[_0xb8373e(0x138)]>0x0&&!_0x30f6d9)await(0x0,translation_1[_0xb8373e(0x115)])(_0x31708e,_0x2b7e9a,_0x1f5e8f=>{const _0x30cf41=_0xb8373e,_0x1162a3=JSON[_0x30cf41(0x124)]((0x0,js_utils_plus_1[_0x30cf41(0x133)])({..._0x5757d2,..._0x1f5e8f}),null,0x2);(0x0,js_utils_plus_1[_0x30cf41(0x11f)])(_0x52ebe5,_0x1162a3);});else{const _0x5beb61=JSON[_0xb8373e(0x124)]((0x0,js_utils_plus_1['objectNested'])(_0x30f6d9?_0x40e0c2:{..._0x5757d2,..._0x31708e}),null,0x2);(0x0,js_utils_plus_1[_0xb8373e(0x11f)])(_0x52ebe5,_0x5beb61);}return!_0x30f6d9&&console[_0xb8373e(0x119)]('-\x20输出:\x20[语种]\x20'+_0x52ebe5),{'addObj':_0x31708e,'delObj':(0x0,js_utils_plus_1[_0xb8373e(0x130)])(_0x5757d2,Object['keys'](_0x40e0c2))};}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- 'use strict';function a1_0x5650(){const _0x1698cc=['.arb','1126023MrjvzF','buildReplacement','existsSync','46982804shsZGu','option','549wgnWLm','trim','S.current.','\x20\x20[DRY-RUN]\x20将替换:\x20','extractor','-\x20文件:','js-utils-plus','显示帮助信息','\x0a[DRY-RUN]\x20ARB\x20将写入:\x20','length','lib/l10n/','default','keys','parse','dir','exit','makeKey','getOwnPropertyDescriptor','8100102WFSexB','join','-f,\x20--file\x20<path>','includes','错误:\x20文件不存在\x20—\x20','name','mkdirSync','\x0a\x20后续步骤:','create','import\x20\x27package:','扫描\x20Flutter\x20项目中的\x20$t()\x20调用,提取国际化文本并生成\x20ARB\x20文件','599925BJuehe','error','-l,\x20--locale\x20<value...>','getOwnPropertyNames','-o,\x20--output\x20<dir>','Flutter\x20国际化提取工具,基于\x20`$t()`\x20显式标记的\x20i18n\x20自动化方案','intl_','__importStar','test','push','key','25368aVjEAH','slice','./core/utils','16VfvUZX','dryRun','stringify','扫描的目录路径,默认\x20lib/','0.0.1','defineProperty','full','扫描结果输出路径,默认\x20lib/l10n/','log','--dry-run','writeFileSync','\x20\x202.\x20fvm\x20flutter\x20analyze','readFileSync','utf-8','错误:\x20仅支持\x20.dart\x20文件\x20—\x20','output','161510vzKiOf','\x20\x201.\x20IDE\x20中右键\x20lib/l10n/\x20→\x20Flutter\x20Intl:\x20Generate(或等\x20IDE\x20自动触发)','baidu','184rgdSsg','显示版本号','template','2CCoGOx','helpOption','-h,\x20--help','call','get','1348776AVDXvK','extractBalanced','action','version','...','Command','-v,\x20--version','仅处理指定的单个\x20.dart\x20文件,不扫描目录','-d,\x20--dir\x20<dir>','-e,\x20--exclude\x20<patterns>','__esModule','prototype','entries','start','__setModuleDefault','file','sort','params','replace','\x20\x20✅\x20已写入:\x20','\x20\x20[','__importDefault','lib/','\x20处)','使用\x20--help\x20查看用法说明','.dart'];a1_0x5650=function(){return _0x1698cc;};return a1_0x5650();}const a1_0xfafcd1=a1_0x84eb;(function(_0x58a369,_0xa1fbe9){const _0x359909=a1_0x84eb,_0x4a1035=_0x58a369();while(!![]){try{const _0x1992b3=parseInt(_0x359909(0x9d))/0x1*(-parseInt(_0x359909(0x7d))/0x2)+parseInt(_0x359909(0x82))/0x3*(-parseInt(_0x359909(0xcd))/0x4)+-parseInt(_0x359909(0xbf))/0x5+-parseInt(_0x359909(0xb4))/0x6+parseInt(_0x359909(0xca))/0x7*(parseInt(_0x359909(0x7a))/0x8)+parseInt(_0x359909(0xa2))/0x9*(parseInt(_0x359909(0x77))/0xa)+parseInt(_0x359909(0xa0))/0xb;if(_0x1992b3===_0xa1fbe9)break;else _0x4a1035['push'](_0x4a1035['shift']());}catch(_0x361f0c){_0x4a1035['push'](_0x4a1035['shift']());}}}(a1_0x5650,0xe6cb6));var __createBinding=this&&this['__createBinding']||(Object[a1_0xfafcd1(0xbc)]?function(_0x5ef950,_0x257926,_0x11fd58,_0x1b5b31){const _0x4d3f85=a1_0xfafcd1;if(_0x1b5b31===undefined)_0x1b5b31=_0x11fd58;var _0x9e063e=Object[_0x4d3f85(0xb3)](_0x257926,_0x11fd58);(!_0x9e063e||(_0x4d3f85(0x81)in _0x9e063e?!_0x257926[_0x4d3f85(0x8c)]:_0x9e063e['writable']||_0x9e063e['configurable']))&&(_0x9e063e={'enumerable':!![],'get':function(){return _0x257926[_0x11fd58];}}),Object[_0x4d3f85(0xd2)](_0x5ef950,_0x1b5b31,_0x9e063e);}:function(_0x500031,_0x5a34ab,_0x3aec99,_0x5ba312){if(_0x5ba312===undefined)_0x5ba312=_0x3aec99;_0x500031[_0x5ba312]=_0x5a34ab[_0x3aec99];}),__setModuleDefault=this&&this[a1_0xfafcd1(0x90)]||(Object[a1_0xfafcd1(0xbc)]?function(_0x1eb882,_0x1a4d48){const _0x8ca31d=a1_0xfafcd1;Object[_0x8ca31d(0xd2)](_0x1eb882,_0x8ca31d(0xad),{'enumerable':!![],'value':_0x1a4d48});}:function(_0x2f2cf1,_0x240146){const _0x52d588=a1_0xfafcd1;_0x2f2cf1[_0x52d588(0xad)]=_0x240146;}),__importStar=this&&this[a1_0xfafcd1(0xc6)]||(function(){var _0x5958b5=function(_0x4c013f){const _0x2761b0=a1_0x84eb;return _0x5958b5=Object[_0x2761b0(0xc2)]||function(_0x5ca7bb){const _0x442dbf=_0x2761b0;var _0x38358b=[];for(var _0x53ea3d in _0x5ca7bb)if(Object[_0x442dbf(0x8d)]['hasOwnProperty'][_0x442dbf(0x80)](_0x5ca7bb,_0x53ea3d))_0x38358b[_0x38358b[_0x442dbf(0xab)]]=_0x53ea3d;return _0x38358b;},_0x5958b5(_0x4c013f);};return function(_0x1dba48){const _0x1b46ee=a1_0x84eb;if(_0x1dba48&&_0x1dba48[_0x1b46ee(0x8c)])return _0x1dba48;var _0x48392f={};if(_0x1dba48!=null){for(var _0x1d6931=_0x5958b5(_0x1dba48),_0x1428de=0x0;_0x1428de<_0x1d6931[_0x1b46ee(0xab)];_0x1428de++)if(_0x1d6931[_0x1428de]!==_0x1b46ee(0xad))__createBinding(_0x48392f,_0x1dba48,_0x1d6931[_0x1428de]);}return __setModuleDefault(_0x48392f,_0x1dba48),_0x48392f;};}()),__importDefault=this&&this[a1_0xfafcd1(0x97)]||function(_0x130301){const _0x3c73a5=a1_0xfafcd1;return _0x130301&&_0x130301[_0x3c73a5(0x8c)]?_0x130301:{'default':_0x130301};};Object[a1_0xfafcd1(0xd2)](exports,'__esModule',{'value':!![]});const fs=__importStar(require('fs')),commander_1=require('commander'),js_utils_plus_1=require(a1_0xfafcd1(0xa8)),utils_1=require(a1_0xfafcd1(0xcc)),path_1=__importDefault(require('path')),__path=process['cwd'](),S_IMPORT='import\x20\x27package:flutter_app_plus/generated/l10n.dart\x27;';function parseTranslationFile(_0x103e8e){const _0x135c8f=a1_0xfafcd1,_0x193c20=fs[_0x135c8f(0x73)](_0x103e8e,'utf-8'),_0x4ed10d=[];for(const {template:_0x371bae,start:_0x52ea3d,end:_0x5deaa5}of(0x0,utils_1['extractTranslation'])(_0x193c20)){let _0x465768=[],_0x49c99f=_0x5deaa5;while(_0x49c99f<_0x193c20['length']&&/[\s,]/[_0x135c8f(0xc7)](_0x193c20[_0x49c99f]))_0x49c99f++;if(_0x193c20[_0x49c99f]==='{'){const _0x201f5b=(0x0,utils_1[_0x135c8f(0x83)])(_0x193c20,'{','}',_0x49c99f);_0x201f5b!==null&&(_0x465768=(0x0,utils_1['parseNamedArguments'])(_0x201f5b),_0x49c99f+=_0x201f5b[_0x135c8f(0xab)]+0x2);}while(_0x49c99f<_0x193c20['length']&&/\s/[_0x135c8f(0xc7)](_0x193c20[_0x49c99f]))_0x49c99f++;if(_0x193c20[_0x49c99f]===')')_0x49c99f++;_0x4ed10d[_0x135c8f(0xc8)]({'template':_0x371bae,'params':_0x465768,'start':_0x52ea3d,'full':_0x193c20[_0x135c8f(0xcb)](_0x52ea3d,_0x49c99f)});}return _0x4ed10d;}function writeArb(_0x470147,_0x1cfc0d,_0x4a5fc7){const _0x2696a6=a1_0xfafcd1;!fs[_0x2696a6(0x9f)](_0x4a5fc7)&&fs[_0x2696a6(0xba)](_0x4a5fc7,{'recursive':!![]});for(let _0x5e0041=0x0;_0x5e0041<_0x1cfc0d[_0x2696a6(0xab)];_0x5e0041++){const _0x1caf5f=_0x1cfc0d[_0x5e0041],_0x122eff=path_1['default'][_0x2696a6(0xb5)](_0x4a5fc7,'intl_'+_0x1caf5f+_0x2696a6(0x9c));let _0x2f894a={};if(fs[_0x2696a6(0x9f)](_0x122eff))try{_0x2f894a=JSON[_0x2696a6(0xaf)](fs[_0x2696a6(0x73)](_0x122eff,_0x2696a6(0x74)));}catch{}const _0x2697c5={..._0x2f894a};for(const [_0x4d8c1a,_0x281487]of Object[_0x2696a6(0x8e)](_0x470147)){!_0x2697c5[_0x4d8c1a]&&(_0x2697c5[_0x4d8c1a]=_0x5e0041===0x0?_0x281487:'');}const _0x4322a7={};for(const _0x57aa0c of Object[_0x2696a6(0xae)](_0x2697c5)[_0x2696a6(0x92)]()){_0x4322a7[_0x57aa0c]=_0x2697c5[_0x57aa0c];}fs['writeFileSync'](_0x122eff,JSON[_0x2696a6(0xcf)](_0x4322a7,null,0x2)+'\x0a',_0x2696a6(0x74)),console[_0x2696a6(0x6f)](_0x2696a6(0x95)+_0x122eff);}}function replaceInFile(_0x26eac7,_0x26357f,_0x2fd633){const _0x1b1974=a1_0xfafcd1;let _0x30e88f=fs['readFileSync'](_0x26eac7,'utf-8');const _0x5092a3=[..._0x26357f][_0x1b1974(0x92)]((_0x2d9500,_0x40ad8f)=>_0x40ad8f[_0x1b1974(0x8f)]-_0x2d9500[_0x1b1974(0x8f)]);for(const _0x3b4d53 of _0x5092a3){const _0x45db40=(0x0,utils_1[_0x1b1974(0x9e)])(_0x3b4d53);_0x30e88f=_0x30e88f[_0x1b1974(0xcb)](0x0,_0x3b4d53[_0x1b1974(0x8f)])+_0x45db40+_0x30e88f[_0x1b1974(0xcb)](_0x3b4d53[_0x1b1974(0x8f)]+_0x3b4d53[_0x1b1974(0xd3)][_0x1b1974(0xab)]);}_0x30e88f=_0x30e88f[_0x1b1974(0x94)](/^import 'package:flutter_app_plus\/utils\/i18n_marker\.dart';\s*\n?/gm,'');if(_0x30e88f['includes'](_0x1b1974(0xa4))&&!_0x30e88f[_0x1b1974(0xb7)]('generated/l10n.dart')){const _0x3862a6=_0x30e88f['split']('\x0a');let _0x1da073=-0x1;for(let _0x51c488=0x0;_0x51c488<_0x3862a6['length'];_0x51c488++){const _0x4eb8a2=_0x3862a6[_0x51c488][_0x1b1974(0xa3)]();_0x4eb8a2['startsWith'](_0x1b1974(0xbd))&&!_0x4eb8a2[_0x1b1974(0xb7)]('flutter_app_plus/')&&(_0x1da073=_0x51c488);}_0x1da073>=0x0?(_0x3862a6['splice'](_0x1da073+0x1,0x0,S_IMPORT),_0x30e88f=_0x3862a6[_0x1b1974(0xb5)]('\x0a')):_0x30e88f=S_IMPORT+'\x0a'+_0x30e88f;}if(_0x2fd633){console[_0x1b1974(0x6f)](_0x1b1974(0xa5)+_0x26eac7+'\x20('+_0x26357f[_0x1b1974(0xab)]+_0x1b1974(0x99));return;}fs[_0x1b1974(0x71)](_0x26eac7,_0x30e88f,'utf-8'),console[_0x1b1974(0x6f)]('\x20\x20已替换:\x20'+_0x26eac7+'\x20('+_0x26357f[_0x1b1974(0xab)]+'\x20处)');}function a1_0x84eb(_0x23caad,_0x485429){_0x23caad=_0x23caad-0x6e;const _0x565009=a1_0x5650();let _0x84eb07=_0x565009[_0x23caad];return _0x84eb07;}function run(_0x5e43c1){const _0xd9350a=a1_0xfafcd1;var _0x1e517a;const _0x47d1f6=Object['assign']({'dir':_0xd9350a(0x98),'output':_0xd9350a(0xac),'channel':_0xd9350a(0x79),'locale':['en']},_0x5e43c1),_0x575d5a=path_1[_0xd9350a(0xad)][_0xd9350a(0xb5)](__path,_0x47d1f6[_0xd9350a(0xb0)]);console['log'](new Array(0x50)[_0xd9350a(0xb5)]('═')),console['log'](_0xd9350a(0xc4)),console['log'](new Array(0x50)['join']('═'));let _0x48a1b2;if(_0x47d1f6[_0xd9350a(0x91)]){const _0x1c0cc0=path_1[_0xd9350a(0xad)][_0xd9350a(0xb5)](__path,_0x47d1f6[_0xd9350a(0x91)]);!fs[_0xd9350a(0x9f)](_0x1c0cc0)&&(console['error'](_0xd9350a(0xb8)+_0x1c0cc0),process[_0xd9350a(0xb1)](0x1)),!_0x1c0cc0['endsWith']('.dart')&&(console[_0xd9350a(0xc0)](_0xd9350a(0x75)+_0x1c0cc0),process[_0xd9350a(0xb1)](0x1)),_0x48a1b2=[_0x1c0cc0];}else{const _0x4a8e0=(_0x47d1f6['exclude']||[])['map'](_0x450e93=>path_1[_0xd9350a(0xad)]['join'](_0x575d5a,_0x450e93));_0x48a1b2=(0x0,js_utils_plus_1['listFilesRecursively'])(_0x575d5a,_0xd9350a(0x9b),_0x4a8e0);}console['log'](new Array(0x50)[_0xd9350a(0xb5)]('-'));const _0x412f4a={},_0x19e718={};for(const _0x2f989d of _0x48a1b2){const _0x210ae0=parseTranslationFile(_0x2f989d);if(_0x210ae0[_0xd9350a(0xab)]===0x0)continue;for(const _0x45467c of _0x210ae0){const _0x1b2d79=(0x0,utils_1[_0xd9350a(0xb2)])(_0x45467c[_0xd9350a(0x7c)]);_0x412f4a[_0x1b2d79]=_0x45467c[_0xd9350a(0x7c)],((_0x1e517a=_0x19e718[_0x2f989d])!==null&&_0x1e517a!==void 0x0?_0x1e517a:_0x19e718[_0x2f989d]=[])[_0xd9350a(0xc8)]({'key':_0x1b2d79,'template':_0x45467c[_0xd9350a(0x7c)],'params':_0x45467c[_0xd9350a(0x93)],'start':_0x45467c[_0xd9350a(0x8f)],'full':_0x45467c['full']});}}for(const [_0x2e6119,_0x5d61dc]of Object[_0xd9350a(0x8e)](_0x19e718)){console['log'](_0xd9350a(0xa7)+_0x2e6119+'\x20('+_0x5d61dc[_0xd9350a(0xab)]+'\x20处)');if(_0x47d1f6[_0xd9350a(0x91)])for(const _0xf56ad9 of _0x5d61dc){const _0x924068=_0xf56ad9['params'][_0xd9350a(0xab)]>0x0?'\x20[插值]':'',_0xb6774c=_0xf56ad9['template'][_0xd9350a(0xab)]>0x3c?_0xf56ad9[_0xd9350a(0x7c)][_0xd9350a(0xcb)](0x0,0x3c)+_0xd9350a(0x86):_0xf56ad9[_0xd9350a(0x7c)];console[_0xd9350a(0x6f)](_0xd9350a(0x96)+_0xf56ad9[_0xd9350a(0xc9)]+']'+_0x924068+'\x20'+_0xb6774c);}}if(!_0x47d1f6[_0xd9350a(0xce)])for(const [_0x15294b,_0x27e40b]of Object[_0xd9350a(0x8e)](_0x19e718)){replaceInFile(_0x15294b,_0x27e40b,_0x47d1f6[_0xd9350a(0xce)]);}if(!_0x47d1f6[_0xd9350a(0xce)]){const _0x2d2203=path_1[_0xd9350a(0xad)][_0xd9350a(0xb5)](__path,_0x47d1f6['output']),_0x4074e7=_0x47d1f6['locale'];writeArb(_0x412f4a,_0x4074e7,_0x2d2203);}else{const _0x3331f7=_0x47d1f6['locale'],_0x93166b=path_1[_0xd9350a(0xad)][_0xd9350a(0xb5)](__path,_0x47d1f6[_0xd9350a(0x76)]);console[_0xd9350a(0x6f)](_0xd9350a(0xaa)+_0x3331f7['map'](_0x138a2d=>path_1['default'][_0xd9350a(0xb5)](_0x93166b,_0xd9350a(0xc5)+_0x138a2d+'.arb'))[_0xd9350a(0xb5)](',\x20'));}console['log'](_0xd9350a(0xbb)),console['log'](_0xd9350a(0x78)),console[_0xd9350a(0x6f)](_0xd9350a(0x72));}const program=new commander_1[(a1_0xfafcd1(0x87))]();program[a1_0xfafcd1(0xb9)](a1_0xfafcd1(0xa6))['description'](a1_0xfafcd1(0xbe))[a1_0xfafcd1(0x85)](a1_0xfafcd1(0xd1),a1_0xfafcd1(0x88),a1_0xfafcd1(0x7b))[a1_0xfafcd1(0x7e)](a1_0xfafcd1(0x7f),a1_0xfafcd1(0xa9))[a1_0xfafcd1(0xa1)](a1_0xfafcd1(0x8a),a1_0xfafcd1(0xd0))[a1_0xfafcd1(0xa1)](a1_0xfafcd1(0xb6),a1_0xfafcd1(0x89))[a1_0xfafcd1(0xa1)](a1_0xfafcd1(0xc3),a1_0xfafcd1(0x6e))[a1_0xfafcd1(0xa1)](a1_0xfafcd1(0x8b),'排除的文件/目录,逗号分隔')[a1_0xfafcd1(0xa1)](a1_0xfafcd1(0xc1),'生成的语言代码,默认\x20en')[a1_0xfafcd1(0xa1)](a1_0xfafcd1(0x70),'仅预览匹配结果,不实际修改任何文件')['showHelpAfterError'](a1_0xfafcd1(0x9a))[a1_0xfafcd1(0x84)](run),program[a1_0xfafcd1(0xaf)]();
2
+ 'use strict';function a2_0x675a(){const _0x268e14=['file','log','0.0.1','replace','mergeLocaleFile','buildReplacement','557511ByLUHG','baidu','显示帮助信息','parseNamedArguments','default','flutter_app_plus/','lib/l10n/','Command','extractTranslation','readFileSync','629449xGVSlN','trim','-e,\x20--exclude\x20<patterns>','entries','__importDefault','-h,\x20--help','-f,\x20--file\x20<path>','slice','--appKey\x20<value>','./core/translation','join','showHelpAfterError','翻译渠道:baidu(百度)\x20|\x20youdao(有道)\x20|\x20google(谷歌)','-o,\x20--output\x20<dir>','sort','extractBalanced','utf-8','\x20\x201.\x20IDE\x20中右键\x20lib/l10n/\x20→\x20Flutter\x20Intl:\x20Generate(或等\x20IDE\x20自动触发)','appKey','扫描结果输出路径,默认\x20lib/l10n/','name','扫描\x20Flutter\x20项目中的\x20$t()\x20调用,提取国际化文本并生成\x20ARB\x20文件','6592380XJowdF','js-utils-plus','-v,\x20--version','2ouRHmg','错误:\x20仅支持\x20.dart\x20文件\x20—\x20','9423AzjyAu','.dart','424TLiYko','-\x20文件:','writeFileSync','key','-l,\x20--locale\x20<value...>','setTranslationConfig','params','makeKey','generated/l10n.dart','使用\x20--help\x20查看用法说明','-c,\x20--channel\x20<value>','output','split','./core/utils','12bDszEx','exit','splice','--secretKey\x20<value>','lib/','dryRun','push','扫描的目录路径,默认\x20lib/','\x20\x202.\x20fvm\x20flutter\x20analyze','-t,\x20--translate\x20<value...>','\x0a\x20后续步骤:','option','.arb','\x20[插值]','\x20处)','full','生成的语言代码,默认\x20en','defineProperty','version','翻译\x20API\x20应用\x20key','intl_','Flutter\x20国际化提取工具,基于\x20`$t()`\x20显式标记的\x20i18n\x20自动化方案','template','includes','locale','description','__esModule','cwd','3485382iNjlml','secretKey','3473260bVkrBO','start','startsWith','helpOption','existsSync','353855KXwRyA','zh_CN','listFilesRecursively','import\x20\x27package:flutter_app_plus/generated/l10n.dart\x27;','parse','test','\x20\x20[','import\x20\x27package:','...','排除的文件/目录,逗号分隔','exclude','length','error'];a2_0x675a=function(){return _0x268e14;};return a2_0x675a();}const a2_0x2f5343=a2_0x5dfe;(function(_0x103b40,_0x4caa87){const _0x1c916a=a2_0x5dfe,_0x340124=_0x103b40();while(!![]){try{const _0x1eebd6=parseInt(_0x1c916a(0x159))/0x1*(parseInt(_0x1c916a(0x172))/0x2)+-parseInt(_0x1c916a(0x14f))/0x3*(parseInt(_0x1c916a(0x184))/0x4)+-parseInt(_0x1c916a(0x13c))/0x5+parseInt(_0x1c916a(0x135))/0x6+parseInt(_0x1c916a(0x137))/0x7+-parseInt(_0x1c916a(0x176))/0x8*(parseInt(_0x1c916a(0x174))/0x9)+-parseInt(_0x1c916a(0x16f))/0xa;if(_0x1eebd6===_0x4caa87)break;else _0x340124['push'](_0x340124['shift']());}catch(_0x435d99){_0x340124['push'](_0x340124['shift']());}}}(a2_0x675a,0x58bfb));var __importDefault=this&&this[a2_0x2f5343(0x15d)]||function(_0x2c7499){const _0x4807da=a2_0x2f5343;return _0x2c7499&&_0x2c7499[_0x4807da(0x133)]?_0x2c7499:{'default':_0x2c7499};};Object[a2_0x2f5343(0x12a)](exports,a2_0x2f5343(0x133),{'value':!![]});const fs_1=__importDefault(require('fs')),path_1=__importDefault(require('path')),commander_1=require('commander'),js_utils_plus_1=require(a2_0x2f5343(0x170)),translation_1=require(a2_0x2f5343(0x162)),utils_1=require(a2_0x2f5343(0x183)),__path=process[a2_0x2f5343(0x134)](),S_IMPORT=a2_0x2f5343(0x13f);function parseTranslationFile(_0xc7e8ff){const _0xba1a7b=a2_0x2f5343,_0x2531be=fs_1[_0xba1a7b(0x153)][_0xba1a7b(0x158)](_0xc7e8ff,_0xba1a7b(0x169)),_0x32d3fe=[];for(const {template:_0x3d60bd,start:_0x16b240,end:_0x46ac0b}of(0x0,utils_1[_0xba1a7b(0x157)])(_0x2531be)){let _0x4360c2=[],_0x429cd4=_0x46ac0b;while(_0x429cd4<_0x2531be[_0xba1a7b(0x147)]&&/[\s,]/[_0xba1a7b(0x141)](_0x2531be[_0x429cd4]))_0x429cd4++;if(_0x2531be[_0x429cd4]==='{'){const _0x237a99=(0x0,utils_1[_0xba1a7b(0x168)])(_0x2531be,'{','}',_0x429cd4);_0x237a99!==null&&(_0x4360c2=(0x0,utils_1[_0xba1a7b(0x152)])(_0x237a99),_0x429cd4+=_0x237a99['length']+0x2);}while(_0x429cd4<_0x2531be[_0xba1a7b(0x147)]&&/\s/[_0xba1a7b(0x141)](_0x2531be[_0x429cd4]))_0x429cd4++;if(_0x2531be[_0x429cd4]===')')_0x429cd4++;_0x32d3fe[_0xba1a7b(0x11f)]({'template':_0x3d60bd,'params':_0x4360c2,'start':_0x16b240,'full':_0x2531be[_0xba1a7b(0x160)](_0x16b240,_0x429cd4)});}return _0x32d3fe;}async function generateArbFiles(_0x10588c,_0x18cd5b){const _0x4f50f6=a2_0x2f5343;var _0x112ba9;for(let _0x2b35b7=0x0;_0x2b35b7<_0x18cd5b['locale']['length'];_0x2b35b7++){const _0x600be1=_0x18cd5b[_0x4f50f6(0x131)][_0x2b35b7],_0xd9d1c7=path_1[_0x4f50f6(0x153)][_0x4f50f6(0x163)](__path,_0x18cd5b[_0x4f50f6(0x181)],_0x4f50f6(0x12d)+_0x600be1+_0x4f50f6(0x125)),_0x45d73e=((_0x112ba9=_0x18cd5b['translate'])===null||_0x112ba9===void 0x0?void 0x0:_0x112ba9[_0x4f50f6(0x130)](_0x600be1))?_0x600be1:'';await(0x0,utils_1[_0x4f50f6(0x14d)])(_0x10588c,_0xd9d1c7,_0x45d73e,_0x2b35b7===0x0);}}function replaceInFile(_0x42ee64,_0x5a447b,_0x1a3f5d){const _0x1e78ac=a2_0x2f5343;let _0x2030b1=fs_1[_0x1e78ac(0x153)][_0x1e78ac(0x158)](_0x42ee64,_0x1e78ac(0x169));const _0x22dba9=[..._0x5a447b][_0x1e78ac(0x167)]((_0x3fb245,_0x4b4fc5)=>_0x4b4fc5[_0x1e78ac(0x138)]-_0x3fb245['start']);for(const _0x559399 of _0x22dba9){const _0x52bdd9=(0x0,utils_1[_0x1e78ac(0x14e)])(_0x559399);_0x2030b1=_0x2030b1['slice'](0x0,_0x559399['start'])+_0x52bdd9+_0x2030b1['slice'](_0x559399[_0x1e78ac(0x138)]+_0x559399[_0x1e78ac(0x128)]['length']);}_0x2030b1=_0x2030b1[_0x1e78ac(0x14c)](/^import 'package:flutter_app_plus\/utils\/i18n_marker\.dart';\s*\n?/gm,'');if(_0x2030b1[_0x1e78ac(0x130)]('S.current.')&&!_0x2030b1[_0x1e78ac(0x130)](_0x1e78ac(0x17e))){const _0x5cf396=_0x2030b1[_0x1e78ac(0x182)]('\x0a');let _0x49fb33=-0x1;for(let _0x146bb0=0x0;_0x146bb0<_0x5cf396[_0x1e78ac(0x147)];_0x146bb0++){const _0x4e4346=_0x5cf396[_0x146bb0][_0x1e78ac(0x15a)]();_0x4e4346[_0x1e78ac(0x139)](_0x1e78ac(0x143))&&!_0x4e4346[_0x1e78ac(0x130)](_0x1e78ac(0x154))&&(_0x49fb33=_0x146bb0);}_0x49fb33>=0x0?(_0x5cf396[_0x1e78ac(0x11b)](_0x49fb33+0x1,0x0,S_IMPORT),_0x2030b1=_0x5cf396[_0x1e78ac(0x163)]('\x0a')):_0x2030b1=S_IMPORT+'\x0a'+_0x2030b1;}if(_0x1a3f5d)return;fs_1[_0x1e78ac(0x153)][_0x1e78ac(0x178)](_0x42ee64,_0x2030b1,'utf-8');}function a2_0x5dfe(_0x5954e9,_0x53831e){_0x5954e9=_0x5954e9-0x11b;const _0x675a92=a2_0x675a();let _0x5dfec5=_0x675a92[_0x5954e9];return _0x5dfec5;}function run(_0x54692d){const _0x4de9ef=a2_0x2f5343;var _0x59f5e9;const _0x255e5e=Object['assign']({'dir':_0x4de9ef(0x11d),'output':_0x4de9ef(0x155),'channel':_0x4de9ef(0x150),'locale':[_0x4de9ef(0x13d)]},_0x54692d);(0x0,translation_1[_0x4de9ef(0x17b)])({'channel':_0x255e5e['channel'],'appKey':_0x255e5e[_0x4de9ef(0x16b)],'secretKey':_0x255e5e[_0x4de9ef(0x136)]}),console[_0x4de9ef(0x14a)](new Array(0x50)['join']('═')),console[_0x4de9ef(0x14a)](_0x4de9ef(0x12e)),console[_0x4de9ef(0x14a)](new Array(0x50)[_0x4de9ef(0x163)]('═'));const _0x837e44=path_1[_0x4de9ef(0x153)][_0x4de9ef(0x163)](__path,_0x255e5e['dir']);let _0x39db1e;if(_0x255e5e['file']){const _0x2ba0ec=path_1[_0x4de9ef(0x153)][_0x4de9ef(0x163)](__path,_0x255e5e['file']);!fs_1[_0x4de9ef(0x153)][_0x4de9ef(0x13b)](_0x2ba0ec)&&(console[_0x4de9ef(0x148)]('错误:\x20文件不存在\x20—\x20'+_0x2ba0ec),process[_0x4de9ef(0x185)](0x1)),!_0x2ba0ec['endsWith']('.dart')&&(console[_0x4de9ef(0x148)](_0x4de9ef(0x173)+_0x2ba0ec),process[_0x4de9ef(0x185)](0x1)),_0x39db1e=[_0x2ba0ec];}else{const _0x268a5d=(_0x255e5e[_0x4de9ef(0x146)]||[])['map'](_0x282973=>path_1['default'][_0x4de9ef(0x163)](_0x837e44,_0x282973));_0x39db1e=(0x0,js_utils_plus_1[_0x4de9ef(0x13e)])(_0x837e44,_0x4de9ef(0x175),_0x268a5d);}console[_0x4de9ef(0x14a)](new Array(0x50)[_0x4de9ef(0x163)]('-'));const _0x4f0f6e={},_0x108b40={};for(const _0x33c1d2 of _0x39db1e){const _0x27f9e7=parseTranslationFile(_0x33c1d2);if(_0x27f9e7['length']===0x0)continue;for(const _0x4ad90d of _0x27f9e7){const _0x3b04dc=(0x0,utils_1[_0x4de9ef(0x17d)])(_0x4ad90d['template']);_0x4f0f6e[_0x3b04dc]=_0x4ad90d['template'],((_0x59f5e9=_0x108b40[_0x33c1d2])!==null&&_0x59f5e9!==void 0x0?_0x59f5e9:_0x108b40[_0x33c1d2]=[])[_0x4de9ef(0x11f)]({'key':_0x3b04dc,'template':_0x4ad90d[_0x4de9ef(0x12f)],'params':_0x4ad90d['params'],'start':_0x4ad90d[_0x4de9ef(0x138)],'full':_0x4ad90d[_0x4de9ef(0x128)]});}}for(const [_0x9ebc86,_0x1ff916]of Object[_0x4de9ef(0x15c)](_0x108b40)){console[_0x4de9ef(0x14a)](_0x4de9ef(0x177)+_0x9ebc86+'\x20('+_0x1ff916[_0x4de9ef(0x147)]+_0x4de9ef(0x127));if(_0x255e5e[_0x4de9ef(0x149)])for(const _0x12ca20 of _0x1ff916){const _0x1772af=_0x12ca20[_0x4de9ef(0x17c)][_0x4de9ef(0x147)]>0x0?_0x4de9ef(0x126):'',_0x52d8cf=_0x12ca20[_0x4de9ef(0x12f)]['length']>0x3c?_0x12ca20[_0x4de9ef(0x12f)]['slice'](0x0,0x3c)+_0x4de9ef(0x144):_0x12ca20[_0x4de9ef(0x12f)];console[_0x4de9ef(0x14a)](_0x4de9ef(0x142)+_0x12ca20[_0x4de9ef(0x179)]+']'+_0x1772af+'\x20'+_0x52d8cf);}}if(!_0x255e5e[_0x4de9ef(0x11e)])for(const [_0x1c9e1f,_0x2dfa54]of Object[_0x4de9ef(0x15c)](_0x108b40)){replaceInFile(_0x1c9e1f,_0x2dfa54,_0x255e5e[_0x4de9ef(0x11e)]);}console[_0x4de9ef(0x14a)](new Array(0x50)[_0x4de9ef(0x163)]('-')),!_0x255e5e[_0x4de9ef(0x149)]&&generateArbFiles(_0x4f0f6e,_0x255e5e),console['log'](_0x4de9ef(0x123)),console[_0x4de9ef(0x14a)](_0x4de9ef(0x16a)),console[_0x4de9ef(0x14a)](_0x4de9ef(0x121));}const program=new commander_1[(a2_0x2f5343(0x156))]();program[a2_0x2f5343(0x16d)]('extractor')[a2_0x2f5343(0x132)](a2_0x2f5343(0x16e))[a2_0x2f5343(0x12b)](a2_0x2f5343(0x14b),a2_0x2f5343(0x171),'显示版本号')[a2_0x2f5343(0x13a)](a2_0x2f5343(0x15e),a2_0x2f5343(0x151))['option']('-d,\x20--dir\x20<dir>',a2_0x2f5343(0x120))['option'](a2_0x2f5343(0x15f),'仅处理指定的单个\x20.dart\x20文件,不扫描目录')[a2_0x2f5343(0x124)](a2_0x2f5343(0x166),a2_0x2f5343(0x16c))[a2_0x2f5343(0x124)](a2_0x2f5343(0x15b),a2_0x2f5343(0x145))[a2_0x2f5343(0x124)](a2_0x2f5343(0x17a),a2_0x2f5343(0x129))['option'](a2_0x2f5343(0x122),'需要翻译的语言代码,对应\x20--locale\x20参数')[a2_0x2f5343(0x124)](a2_0x2f5343(0x180),a2_0x2f5343(0x165))['option'](a2_0x2f5343(0x161),a2_0x2f5343(0x12c))[a2_0x2f5343(0x124)](a2_0x2f5343(0x11c),'翻译\x20API\x20密钥')[a2_0x2f5343(0x124)]('--dry-run','仅预览匹配结果,不实际修改任何文件')[a2_0x2f5343(0x164)](a2_0x2f5343(0x17f))['action'](run),program[a2_0x2f5343(0x140)]();
package/package.json CHANGED
@@ -1,15 +1,14 @@
1
1
  {
2
2
  "name": "flutter-i18n-generator",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Flutter国际化i18n编译器,提取项目中的”中文“替换为多语言$t(key)并导出翻译文件。",
5
- "main": "dist/index.js",
6
5
  "bin": {
7
6
  "extractor": "dist/index.js"
8
7
  },
9
8
  "scripts": {
10
9
  "dev": "tsc -w",
11
10
  "test": "tsc && node dist/index.js --dry-run --file test/login.dart",
12
- "test2": "tsc && node dist/index.js --dry-run -d test/",
11
+ "test2": "tsc && node dist/index.js --dry-run -d test/ -o test/l10n/ -l zh_CN en -t en --channel baidu --appKey 20230608001664654 --secretKey 0Z1g5k7q3r6s4e2f",
13
12
  "build": "rimraf dist && tsc && javascript-obfuscator dist --output dist"
14
13
  },
15
14
  "repository": {