Repository navigation
Expand file tree
/
Copy pathpackage.json
More file actions
366 lines (366 loc) · 12.8 KB
/
Copy pathpackage.json
File metadata and controls
366 lines (366 loc) · 12.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
{
"name": "angular-translation-extractor",
"displayName": "Angular Translation Extractor",
"author": {
"name": "Adilson de Almeida Pedro",
"email": "adilson@almeidapedro.com.br",
"url": "https://adilson.almeidapedro.com.br",
"github": "https://github.com/devremoto",
"twitter": "https://twitter.com/devremoto",
"linkedin": "https://www.linkedin.com/in/adilsonpedro/"
},
"icon": "assets/angular.ico",
"description": "Extracts Angular app strings from JS/TS/HTML, generates per-file locale JSONs and translation loader artifacts.",
"version": "0.0.39",
"publisher": "AdilsondeAlmeidaPedro",
"repository": {
"type": "git",
"url": "https://github.com/devremoto/angular-translation-extractor"
},
"engines": {
"vscode": "^1.85.0"
},
"categories": [
"Other"
],
"main": "./dist/extension.js",
"activationEvents": [
"onStartupFinished",
"onLanguage:json",
"onLanguage:jsonc"
],
"contributes": {
"commands": [
{
"command": "angularTranslation.extract",
"title": "Extract translations (All app)",
"category": "Angular Translation"
},
{
"command": "angularTranslation.extractFile",
"title": "Extract translations (File)",
"category": "Angular Translation"
},
{
"command": "angularTranslation.extractSelection",
"title": "Extract translations (Selection)",
"category": "Angular Translation"
},
{
"command": "angularTranslation.reverseFromFolder",
"title": "Reverse Translate (Folder)",
"category": "Angular Translation"
},
{
"command": "angularTranslation.reverseFromFile",
"title": "Reverse Translate (File)",
"category": "Angular Translation"
},
{
"command": "angularTranslation.reverseSelection",
"title": "Reverse Translate (Selection)",
"category": "Angular Translation"
},
{
"command": "angularTranslation.extractSelectionParenthesis",
"title": "Extract Selection into ( 'KEY' | translate )",
"category": "Angular Translation"
},
{
"command": "angularTranslation.insertSelector",
"title": "Insert Language Selector",
"category": "Angular Translation"
},
{
"command": "angularTranslation.pruneSelectedKeys",
"title": "Prune Selected Translation Keys (JSON)",
"category": "Angular Translation"
},
{
"command": "angularTranslation.excludeWorkspacePath",
"title": "Exclude from Workspace Scan",
"category": "Angular Translation"
},
{
"command": "angularTranslation.clearWorkspaceState",
"title": "Clear i18n Workspace State",
"category": "Angular Translation"
}
],
"submenus": [
{
"id": "angularTranslation.menu",
"label": "Angular Translation Extractor"
}
],
"menus": {
"commandPalette": [
{
"command": "angularTranslation.extract",
"group": "navigation"
},
{
"command": "angularTranslation.reverseFromFolder",
"group": "navigation"
},
{
"command": "angularTranslation.reverseFromFile",
"group": "navigation"
}
],
"explorer/context": [
{
"submenu": "angularTranslation.menu",
"group": "navigation",
"when": "resourceScheme == file"
}
],
"editor/context": [
{
"submenu": "angularTranslation.menu",
"group": "navigation",
"when": "resourceLangId == typescript || resourceLangId == html || resourceLangId == json || resourceLangId == jsonc"
}
],
"angularTranslation.menu": [
{
"command": "angularTranslation.extract",
"group": "1_extract",
"when": "(!editorFocus || !editorHasSelection) && (!(resourceLangId == json || resourceLangId == jsonc || resourceExtname == .json) || angularTranslation.isDefaultLocaleJsonEditor)"
},
{
"command": "angularTranslation.extractFile",
"group": "1_extract",
"when": "!explorerResourceIsFolder && (!editorFocus || !editorHasSelection) && (resourceLangId == typescript || resourceLangId == html || resourceExtname == .ts || resourceExtname == .html)"
},
{
"command": "angularTranslation.extractSelection",
"group": "1_extract",
"when": "editorFocus && editorHasSelection && (resourceLangId == typescript || resourceLangId == html)"
},
{
"command": "angularTranslation.extractSelectionParenthesis",
"group": "1_extract",
"when": "editorFocus && editorHasSelection && (resourceLangId == typescript || resourceLangId == html)"
},
{
"command": "angularTranslation.reverseFromFolder",
"group": "2_reverse",
"when": "explorerResourceIsFolder"
},
{
"command": "angularTranslation.reverseFromFile",
"group": "2_reverse",
"when": "!explorerResourceIsFolder && (!editorFocus || !editorHasSelection) && (resourceLangId == typescript || resourceLangId == html || resourceExtname == .ts || resourceExtname == .html)"
},
{
"command": "angularTranslation.reverseSelection",
"group": "2_reverse",
"when": "editorFocus && editorHasSelection && (resourceLangId == typescript || resourceLangId == html)"
},
{
"command": "angularTranslation.insertSelector",
"group": "3_utils",
"when": "resourceLangId == html || resourceExtname == .html"
},
{
"command": "angularTranslation.pruneSelectedKeys",
"group": "3_utils",
"when": "editorFocus && editorHasSelection && angularTranslation.isDefaultLocaleJsonEditor"
},
{
"command": "angularTranslation.excludeWorkspacePath",
"group": "3_utils",
"when": "resourceScheme == file"
},
{
"command": "angularTranslation.clearWorkspaceState",
"group": "3_utils"
}
]
},
"configuration": {
"title": "Angular Translation Extractor",
"properties": {
"i18nExtractor.minStringLength": {
"type": "number",
"default": 2,
"description": "Ignore strings shorter than this."
},
"i18nExtractor.ignoreGlobs": {
"type": "array",
"default": [
"**/*.test.*",
"**/*.spec.*",
"**/node_modules/**",
"**/dist/**",
"**/build/**",
"**/.next/**",
"**/.angular/**",
"**/index.html",
"**/assets/**",
"**/environments/**",
"**/.agent/**",
"**/.vscode/**"
],
"items": {
"type": "string"
},
"description": "Glob patterns to ignore during scan."
},
"i18nExtractor.htmlAttributeNames": {
"type": "array",
"default": [
"title",
"alt",
"placeholder",
"aria-label",
"aria-placeholder"
],
"items": {
"type": "string"
},
"description": "HTML attribute names to extract string values from."
},
"i18nExtractor.angularBootstrapStyle": {
"type": "string",
"default": "standalone",
"enum": [
"standalone",
"module"
],
"description": "How to wire TranslateModule in main.ts."
},
"i18nExtractor.useTranslateCommand": {
"type": "boolean",
"default": false,
"description": "If true, run a translation command after generating base JSONs."
},
"i18nExtractor.translateCommand": {
"type": "string",
"default": "npx-translate",
"description": "Command to run (only if useTranslateCommand=true)."
},
"i18nExtractor.translateArgsTemplate": {
"type": "array",
"default": [
"--input",
"{baseFile}",
"--outDir",
"{outDir}",
"--from",
"{baseLocale}",
"--to",
"{targetLocale}"
],
"items": {
"type": "string"
},
"description": "Args template. Placeholders: {baseFile} {outDir} {baseLocale} {targetLocale}"
},
"i18nExtractor.updateMode": {
"type": "string",
"enum": [
"merge",
"overwrite",
"recreate"
],
"default": "merge",
"description": "Controls how JSON translation files and generated files are updated. 'merge': Only adds new blank properties (preserves existing translations and JSON structure). 'overwrite': Recreates all JSON files except the default language. 'recreate': Recreates all files including the default language."
},
"i18nExtractor.skipGlobs": {
"type": "array",
"default": [],
"items": {
"type": "string"
},
"description": "Additional glob patterns to skip during scan (merged with ignoreGlobs)."
},
"i18nExtractor.autoTranslate": {
"type": "boolean",
"default": true,
"description": "If true, automatically initiate translations for all target languages after extracting base locale strings."
},
"i18nExtractor.autoTranslateDefaultLanguage": {
"type": "boolean",
"default": false,
"description": "If false, skip translating the default language marked with 'default': true in i18n-languages.json. The default language is used as the translation source, so it typically doesn't need to be translated."
},
"i18nExtractor.aggressiveMode": {
"type": "string",
"enum": [
"low",
"moderate",
"high"
],
"default": "moderate",
"description": "Controls extraction aggressiveness for strings inside function parameters. low: blocks all; moderate: allows multi-word; high: allows all with no length limit. Restricted strings are reported in src/translate/aggressive-mode-restricted.json."
},
"i18nExtractor.aggressiveModeAllowCallRegex": {
"type": "array",
"default": [
"^alert\\s*\\(",
"^confirm\\s*\\(",
"^prompt\\s*\\("
],
"items": {
"type": "string"
},
"description": "Array of regex patterns matched against full function call source (example: alert('teste')). If matched, extraction is allowed and has priority over aggressiveMode."
},
"i18nExtractor.aggressiveModeAllowContextRegex": {
"type": "array",
"default": [
"^window\\.alert\\(arg#1\\)$",
"^window\\.confirm\\(arg#1\\)$",
"^window\\.prompt\\(arg#1\\)$"
],
"items": {
"type": "string"
},
"description": "Array of regex patterns matched against function argument context (example: this.toastr.error(arg#1)). If matched, extraction is allowed and has priority over aggressiveMode."
},
"i18nExtractor.googleTranslateDelay": {
"type": "number",
"default": 500,
"description": "Delay between translation requests in milliseconds to avoid rate limiting (minimum 100ms). Used for Google Translate."
}
}
}
},
"scripts": {
"compile-tests": "tsc -p . --outDir out",
"watch-tests": "tsc -p . -w --outDir out",
"pretest": "npm run compile-tests && npm run compile && npm run lint",
"lint": "eslint src --max-warnings=999",
"test": "vscode-test",
"clean": "rimraf dist out",
"compile": "npm run clean && npm run check-types && node esbuild.js",
"check-types": "tsc --noEmit",
"watch": "npm run clean && npm-run-all -p watch:*",
"watch:esbuild": "node esbuild.js --watch",
"watch:tsc": "tsc --noEmit --watch --project tsconfig.json",
"vscode:prepublish": "npm run package",
"package": "npm run check-types && node esbuild.js --production"
},
"devDependencies": {
"@types/babel__traverse": "^7.20.5",
"@types/node": "^20.10.0",
"@types/vscode": "^1.85.0",
"@typescript-eslint/eslint-plugin": "^8.55.0",
"@typescript-eslint/parser": "^8.55.0",
"esbuild": "^0.24.2",
"eslint": "^9.39.2",
"eslint-plugin-import": "^2.32.0",
"npm-run-all": "^4.1.5",
"rimraf": "^6.1.2",
"typescript": "^5.4.0"
},
"dependencies": {
"@babel/parser": "^7.24.0",
"@babel/traverse": "^7.24.0",
"axios": "^1.7.9",
"fast-glob": "^3.3.2",
"punycode": "^2.3.1"
}
}