@astroscope/i18n 0.3.4 → 0.4.1
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/LICENSE +21 -0
- package/README.md +17 -0
- package/dist/{chunk-A2XW2S6Z.js → chunk-IJXSX5DY.js} +1 -3
- package/dist/{chunk-P4IZCU3H.js → chunk-LXW5WYBS.js} +5 -0
- package/dist/extraction/index.js +1 -1
- package/dist/index.js +2 -2
- package/dist/internal.js +1 -1
- package/dist/server/translate.js +1 -1
- package/package.json +14 -14
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 Simon Bobrov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -421,6 +421,23 @@ For `:currency` and `:unit`, the required option (`currency` or `unit`) can be:
|
|
|
421
421
|
- `'throw'` — Throw an error
|
|
422
422
|
- `(key, meta) => string` — Custom function
|
|
423
423
|
|
|
424
|
+
## ESLint Plugin
|
|
425
|
+
|
|
426
|
+
Use [`@astroscope/eslint-plugin-i18n`](../eslint-plugin-i18n) to enforce correct `t()` usage, catch build-time extraction issues, and ensure i18n-aware hydration directives.
|
|
427
|
+
|
|
428
|
+
```bash
|
|
429
|
+
npm install -D @astroscope/eslint-plugin-i18n
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
```js
|
|
433
|
+
// eslint.config.js
|
|
434
|
+
import i18n from '@astroscope/eslint-plugin-i18n';
|
|
435
|
+
|
|
436
|
+
export default [
|
|
437
|
+
i18n.configs.recommended,
|
|
438
|
+
];
|
|
439
|
+
```
|
|
440
|
+
|
|
424
441
|
## License
|
|
425
442
|
|
|
426
443
|
MIT
|
|
@@ -313,7 +313,6 @@ function i18nVitePlugin(options) {
|
|
|
313
313
|
state.version++;
|
|
314
314
|
};
|
|
315
315
|
let isBuild = false;
|
|
316
|
-
let isSSR = false;
|
|
317
316
|
let projectRoot = "";
|
|
318
317
|
return {
|
|
319
318
|
name: "@astroscope/i18n/extract",
|
|
@@ -322,7 +321,6 @@ function i18nVitePlugin(options) {
|
|
|
322
321
|
const state = getGlobalState();
|
|
323
322
|
state.projectRoot = config.root;
|
|
324
323
|
isBuild = config.command === "build";
|
|
325
|
-
isSSR = !!config.build.ssr;
|
|
326
324
|
projectRoot = config.root;
|
|
327
325
|
},
|
|
328
326
|
async configureServer(server) {
|
|
@@ -459,7 +457,7 @@ export function getManifest() { return _getManifest(); }
|
|
|
459
457
|
}
|
|
460
458
|
},
|
|
461
459
|
writeBundle(outputOptions) {
|
|
462
|
-
if (
|
|
460
|
+
if (this.environment.name === "client" && outputOptions.dir) {
|
|
463
461
|
const chunksDir = path.resolve(outputOptions.dir, "..", "server", "chunks");
|
|
464
462
|
const manifestPath = path.join(chunksDir, MANIFEST_FILE_NAME);
|
|
465
463
|
if (fs2.existsSync(chunksDir)) {
|
|
@@ -113,6 +113,11 @@ var I18nSingleton = class {
|
|
|
113
113
|
this.compiledCache.delete(locale);
|
|
114
114
|
this.hashCache.delete(locale);
|
|
115
115
|
this.scriptCache.delete(locale);
|
|
116
|
+
for (const key of this.chunkCache.keys()) {
|
|
117
|
+
if (key.startsWith(`${locale}:`)) {
|
|
118
|
+
this.chunkCache.delete(key);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
116
121
|
const { chunks } = this.getManifest();
|
|
117
122
|
if (Object.keys(chunks).length > 0) {
|
|
118
123
|
this.hashCache.set(locale, computeAllChunkHashes(raw, chunks));
|
package/dist/extraction/index.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
i18nVitePlugin
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-IJXSX5DY.js";
|
|
4
4
|
import {
|
|
5
5
|
i18n,
|
|
6
6
|
runWithContext
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-LXW5WYBS.js";
|
|
8
8
|
import "./chunk-33JVAFGQ.js";
|
|
9
9
|
import "./chunk-FYKC3DAZ.js";
|
|
10
10
|
import "./chunk-4A5BKHFN.js";
|
package/dist/internal.js
CHANGED
package/dist/server/translate.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astroscope/i18n",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "i18n for Astro + React islands — MessageFormat 2, automatic tree-shaking, parallel loading, any translation source",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -81,30 +81,30 @@
|
|
|
81
81
|
"url": "https://github.com/smnbbrv/astroscope/issues"
|
|
82
82
|
},
|
|
83
83
|
"homepage": "https://github.com/smnbbrv/astroscope/tree/main/packages/i18n#readme",
|
|
84
|
-
"scripts": {
|
|
85
|
-
"build": "tsup src/index.ts src/internal.ts src/extraction/index.ts src/server/translate.ts src/client/translate.ts src/client/directives/load.ts src/client/directives/idle.ts src/client/directives/visible.ts src/client/directives/media.ts src/client/directives/only.ts src/client/directives/utils.ts --format esm --dts --external astro --external astro/client/load.js --external astro/client/idle.js --external astro/client/visible.js --external astro/client/media.js --external astro/client/only.js --external virtual:@astroscope/i18n/manifest --external @babel/core",
|
|
86
|
-
"typecheck": "tsc --noEmit",
|
|
87
|
-
"lint": "eslint src",
|
|
88
|
-
"lint:fix": "eslint src --fix"
|
|
89
|
-
},
|
|
90
84
|
"dependencies": {
|
|
91
|
-
"@astrojs/compiler": "^
|
|
85
|
+
"@astrojs/compiler": "^3.0.1",
|
|
92
86
|
"@babel/core": "^7.29.0",
|
|
93
87
|
"@babel/preset-typescript": "^7.28.5",
|
|
94
88
|
"messageformat": "^4.0.0",
|
|
95
|
-
"glob": "^13.0.
|
|
89
|
+
"glob": "^13.0.6",
|
|
96
90
|
"magic-string": "^0.30.21"
|
|
97
91
|
},
|
|
98
92
|
"devDependencies": {
|
|
99
93
|
"@babel/types": "^7.29.0",
|
|
100
94
|
"@types/babel__core": "^7.20.5",
|
|
101
|
-
"astro": "^
|
|
95
|
+
"astro": "^6.0.7",
|
|
102
96
|
"tsup": "^8.5.1",
|
|
103
97
|
"typescript": "^5.9.3",
|
|
104
|
-
"vite": "^
|
|
98
|
+
"vite": "^7.3.1"
|
|
105
99
|
},
|
|
106
100
|
"peerDependencies": {
|
|
107
|
-
"
|
|
108
|
-
"
|
|
101
|
+
"astro": "^6.0.0",
|
|
102
|
+
"@astroscope/excludes": "^0.3.0"
|
|
103
|
+
},
|
|
104
|
+
"scripts": {
|
|
105
|
+
"build": "tsup src/index.ts src/internal.ts src/extraction/index.ts src/server/translate.ts src/client/translate.ts src/client/directives/load.ts src/client/directives/idle.ts src/client/directives/visible.ts src/client/directives/media.ts src/client/directives/only.ts src/client/directives/utils.ts --format esm --dts --external astro --external astro/client/load.js --external astro/client/idle.js --external astro/client/visible.js --external astro/client/media.js --external astro/client/only.js --external virtual:@astroscope/i18n/manifest --external @babel/core",
|
|
106
|
+
"typecheck": "tsc --noEmit",
|
|
107
|
+
"lint": "eslint src",
|
|
108
|
+
"lint:fix": "eslint src --fix"
|
|
109
109
|
}
|
|
110
|
-
}
|
|
110
|
+
}
|