ai-localize-scanner 2.0.5 → 2.0.6
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/CHANGELOG.md +7 -0
- package/README.md +75 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# ai-localize-scanner
|
|
2
|
+
|
|
3
|
+
> Babel AST-based hardcoded text detection + asset scanner for the [ai-localize-core](https://github.com/ai-localize/ai-localize-core) platform.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/ai-localize-scanner)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## What it does
|
|
11
|
+
|
|
12
|
+
- Parses JS/TS/JSX/TSX/Vue/Angular source files with `@babel/parser`
|
|
13
|
+
- Detects hardcoded strings in JSX text, attributes, string literals, template literals
|
|
14
|
+
- Skips strings already inside translation calls (`t()`, `useTranslation`, custom hooks)
|
|
15
|
+
- Detects static asset references (images, fonts, CSS, JS)
|
|
16
|
+
- Finds legacy CDN URLs for migration
|
|
17
|
+
- Supports **incremental scanning** (git-aware file hashing cache)
|
|
18
|
+
- Generates deterministic `suggestedKey` for every detected string
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install ai-localize-scanner
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { ProjectScanner } from 'ai-localize-scanner';
|
|
30
|
+
|
|
31
|
+
const scanner = new ProjectScanner({
|
|
32
|
+
framework: 'react-vite',
|
|
33
|
+
sourceDir: 'src',
|
|
34
|
+
localesDir: 'locales',
|
|
35
|
+
defaultLanguage: 'en',
|
|
36
|
+
targetLanguages: ['fr', 'de'],
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const result = await scanner.scan();
|
|
40
|
+
// result.detectedTexts — array of DetectedText
|
|
41
|
+
// result.assets — array of AssetReference
|
|
42
|
+
// result.legacyCdnUrls — array of LegacyCdnUrl
|
|
43
|
+
// result.scannedFiles — number of files processed
|
|
44
|
+
// result.duration — scan time in ms
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Detected text contexts
|
|
48
|
+
|
|
49
|
+
`jsx-text` · `string-literal` · `jsx-attribute` · `placeholder` · `aria-label` · `title` · `alt` · `button` · `heading` · `label` · `validation` · `tooltip` · `table-header` · `modal` · `toast` · `alert` · `template-literal` · `object-value` · `array-item`
|
|
50
|
+
|
|
51
|
+
## Key generation
|
|
52
|
+
|
|
53
|
+
Keys are generated deterministically from file path + text:
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
src/pages/dashboard/Banner.tsx + "Welcome to the Dashboard"
|
|
57
|
+
→ pages.dashboard.banner.welcome_to_the_dashboard
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Set `keyStyle: "screaming_snake"` for UPPER_SNAKE_CASE keys:
|
|
61
|
+
```
|
|
62
|
+
"Save Changes" → SAVE_CHANGES
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Incremental scanning
|
|
66
|
+
|
|
67
|
+
Enable with `incrementalCache: true` (default). File hashes are stored in `.ai-localize-cache/scan-cache.json`. Only changed files are re-scanned on subsequent runs.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Part of ai-localize-core
|
|
72
|
+
|
|
73
|
+
Install the CLI for the complete toolset: `npm install -g ai-localize-cli`
|
|
74
|
+
|
|
75
|
+
MIT © ai-localize-core contributors
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-localize-scanner",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"description": "AST-based hardcoded text scanner for frontend applications",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"@babel/traverse": "^7.23.9",
|
|
40
40
|
"@babel/types": "^7.23.9",
|
|
41
41
|
"glob": "^10.3.10",
|
|
42
|
-
"ai-localize-shared": "2.0.
|
|
43
|
-
"ai-localize-config": "2.0.
|
|
42
|
+
"ai-localize-shared": "2.0.6",
|
|
43
|
+
"ai-localize-config": "2.0.6"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/babel__traverse": "^7.20.5",
|