@gringow/gringow-vite 0.2.0 โ 0.2.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 +12 -15
- package/dist/build-gringow-cache.mjs +1 -1
- package/dist/get-matches-from-file.mjs +1 -1
- package/dist/get-matches-in-code.mjs +1 -1
- package/dist/get-source-ids.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ Vite plugin for Gringow that automatically extracts translation strings during d
|
|
|
7
7
|
|
|
8
8
|
## Features
|
|
9
9
|
|
|
10
|
-
- ๐ **Automatic Extraction** - Finds
|
|
10
|
+
- ๐ **Automatic Extraction** - Finds `g` and `gid` tagged templates in your code
|
|
11
11
|
- ๐ **Cache Synchronization** - Keeps translations in sync with source code
|
|
12
12
|
- ๐งน **Smart Cleanup** - Removes unused translations automatically
|
|
13
13
|
- โก **Build-Time Translation** - Generates cache during Vite builds
|
|
@@ -51,8 +51,9 @@ export default defineConfig({
|
|
|
51
51
|
// gringow.config.js
|
|
52
52
|
export default {
|
|
53
53
|
llm: {
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
provider: 'openai',
|
|
55
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
56
|
+
model: 'gpt-4o-mini',
|
|
56
57
|
},
|
|
57
58
|
languages: ['pt-BR', 'es-ES', 'fr-CA'],
|
|
58
59
|
sourceLanguage: 'en-US',
|
|
@@ -82,7 +83,7 @@ pnpm run build
|
|
|
82
83
|
```
|
|
83
84
|
|
|
84
85
|
The plugin automatically:
|
|
85
|
-
- Scans your source files for `g` tagged templates
|
|
86
|
+
- Scans your source files for `g` and `gid` tagged templates
|
|
86
87
|
- Generates translations using configured LLM
|
|
87
88
|
- Writes to `./gringow/gringow.json`
|
|
88
89
|
- Updates cache as you code
|
|
@@ -164,7 +165,7 @@ The plugin hooks into Vite's transform pipeline:
|
|
|
164
165
|
### Transform Hook
|
|
165
166
|
|
|
166
167
|
- **Scans modules** - Checks each transformed file for `g` tagged templates
|
|
167
|
-
- **Extracts strings** - Parses template literals
|
|
168
|
+
- **Extracts strings** - Parses template literals from `g`/`gid` tags
|
|
168
169
|
- **Generates IDs** - Creates content-based cache IDs
|
|
169
170
|
- **Calls core library** - Invokes `@gringow/gringow` to translate and cache
|
|
170
171
|
|
|
@@ -228,14 +229,7 @@ export default function App() {
|
|
|
228
229
|
export default {
|
|
229
230
|
// Scan TypeScript files only
|
|
230
231
|
globby: './src/**/*.{ts,tsx}',
|
|
231
|
-
|
|
232
|
-
// Or include multiple patterns
|
|
233
|
-
globby: [
|
|
234
|
-
'./src/**/*.{ts,tsx}',
|
|
235
|
-
'./components/**/*.{ts,tsx}',
|
|
236
|
-
'!./src/**/*.test.tsx'
|
|
237
|
-
],
|
|
238
|
-
|
|
232
|
+
|
|
239
233
|
languages: ['pt-BR', 'es-ES'],
|
|
240
234
|
}
|
|
241
235
|
```
|
|
@@ -321,10 +315,13 @@ pnpm run watch
|
|
|
321
315
|
|
|
322
316
|
## Related Packages
|
|
323
317
|
|
|
318
|
+
Gringow provides a complete ecosystem for AI-powered translation:
|
|
319
|
+
|
|
324
320
|
- **[@gringow/gringow](https://www.npmjs.com/package/@gringow/gringow)** - Core translation library
|
|
325
|
-
- **[@gringow/gringow-
|
|
321
|
+
- **[@gringow/gringow-vite](https://www.npmjs.com/package/@gringow/gringow-vite)** - Vite plugin for build-time extraction
|
|
322
|
+
- **[@gringow/gringow-react](https://www.npmjs.com/package/@gringow/gringow-react)** - React hooks and components
|
|
326
323
|
- **[@gringow/gringow-shadow](https://www.npmjs.com/package/@gringow/gringow-shadow)** - Web Component layer
|
|
327
|
-
- **[@gringow/cli](https://www.npmjs.com/package/@gringow/gringow-cli)** - CLI tool
|
|
324
|
+
- **[@gringow/gringow-cli](https://www.npmjs.com/package/@gringow/gringow-cli)** - CLI tool
|
|
328
325
|
- **[@gringow/gringow-nextjs](https://www.npmjs.com/package/@gringow/gringow-nextjs)** - Next.js plugin (experimental)
|
|
329
326
|
|
|
330
327
|
## Resources
|
|
@@ -6,7 +6,7 @@ import fs from 'fs/promises';
|
|
|
6
6
|
|
|
7
7
|
// src/get-matches-in-code.ts
|
|
8
8
|
function getMatchesInCode(code) {
|
|
9
|
-
const regex = /g
|
|
9
|
+
const regex = /g(?:id)?`((?:\\`|[^`])+)`/g;
|
|
10
10
|
return [...new Set([...code.matchAll(regex)].map(([, value = ""]) => value))];
|
|
11
11
|
}
|
|
12
12
|
async function getMatchesFromFile(filePath) {
|
|
@@ -4,7 +4,7 @@ import fs from 'fs/promises';
|
|
|
4
4
|
|
|
5
5
|
// src/get-matches-in-code.ts
|
|
6
6
|
function getMatchesInCode(code) {
|
|
7
|
-
const regex = /g
|
|
7
|
+
const regex = /g(?:id)?`((?:\\`|[^`])+)`/g;
|
|
8
8
|
return [...new Set([...code.matchAll(regex)].map(([, value = ""]) => value))];
|
|
9
9
|
}
|
|
10
10
|
|
package/dist/get-source-ids.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import fs from 'fs/promises';
|
|
|
6
6
|
|
|
7
7
|
// src/get-matches-in-code.ts
|
|
8
8
|
function getMatchesInCode(code) {
|
|
9
|
-
const regex = /g
|
|
9
|
+
const regex = /g(?:id)?`((?:\\`|[^`])+)`/g;
|
|
10
10
|
return [...new Set([...code.matchAll(regex)].map(([, value = ""]) => value))];
|
|
11
11
|
}
|
|
12
12
|
|
package/dist/index.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import fs from 'fs/promises';
|
|
|
6
6
|
|
|
7
7
|
// src/get-matches-in-code.ts
|
|
8
8
|
function getMatchesInCode(code) {
|
|
9
|
-
const regex = /g
|
|
9
|
+
const regex = /g(?:id)?`((?:\\`|[^`])+)`/g;
|
|
10
10
|
return [...new Set([...code.matchAll(regex)].map(([, value = ""]) => value))];
|
|
11
11
|
}
|
|
12
12
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gringow/gringow-vite",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "A Vite plugin for Gringow AI-powered translation tool",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"globby": "14.1.0",
|
|
42
42
|
"vite": "7.0.0",
|
|
43
|
-
"@gringow/gringow": "0.2.
|
|
43
|
+
"@gringow/gringow": "0.2.2"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/node": "22.15.0",
|