@astroscope/i18n 0.4.5 → 0.5.0

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
@@ -6,24 +6,24 @@ i18n for Astro + React islands — automatic tree-shaking, parallel loading, any
6
6
 
7
7
  ## Why this library?
8
8
 
9
- **SSR-first** — The only i18n solution built specifically for SSR + islands architecture. Works seamlessly with Astro's partial hydration model where most i18n libraries fail.
9
+ **SSR-first** — Built for Astro's SSR + islands architecture, where client-only i18n libraries have no server story.
10
10
 
11
- **Automatic tree-shaking** — Only translations actually used by each component are delivered to the browser. No manual chunk splitting, no configuration. It just works.
11
+ **Automatic tree-shaking** — Only the translations each component actually uses are delivered to the browser. No manual chunk splitting or configuration.
12
12
 
13
- **Parallel loading** — Translations load alongside component hydration via custom `client:*-x` directives. No waiting for translations before rendering.
13
+ **Parallel loading** — Translations load alongside component hydration via custom `client:*-x` directives, so hydration doesn't wait on a separate translation fetch.
14
14
 
15
- **Unified API** — Same `t()` function works identically in Astro templates and React islands.
15
+ **Unified API** — The same `t()` function works in Astro templates and React islands.
16
16
 
17
- **Any translation source** — Fetch translations from any provider: JSON files, database, headless CMS, TMS, or custom API. All of them will be optimized and chunked automatically.
17
+ **Any translation source** — Fetch translations from any provider: JSON files, database, headless CMS, TMS, or custom API. All are chunked and optimized the same way.
18
18
 
19
- **Production optimized** — Fallback strings are stripped from production bundles via Babel, reducing bundle size while keeping fallbacks available via the manifest.
19
+ **Production optimized** — Fallback strings are stripped from production bundles via Babel and kept available through the manifest.
20
20
 
21
21
  ## Features
22
22
 
23
23
  - **Per-chunk translation loading** — each island gets only its translations
24
24
  - **Unicode MessageFormat 2** (MF2) support via `messageformat` v4
25
25
  - **Built-in formatters** — `:number`, `:integer`, `:percent`, `:currency`, `:date`, `:time`, `:datetime`, `:unit`
26
- - **Babel-based extraction** — robust AST parsing, source maps, production stripping
26
+ - **Babel-based extraction** — AST parsing, source maps, production stripping
27
27
  - **Manifest fallbacks** — missing translations automatically use extracted fallbacks
28
28
  - **Full TypeScript support**
29
29
  - **Tiny client runtime** — ~8KB gzipped for translations
@@ -58,17 +58,17 @@ The integration checks for translation key consistency — when the same key is
58
58
 
59
59
  ```ts
60
60
  i18n({
61
- consistency: 'warn', // 'warn' (default) | 'error' | 'off'
61
+ consistency: 'error', // 'error' (default) | 'warn' | 'off'
62
62
  })
63
63
  ```
64
64
 
65
- - **`'warn'`** — Log a warning but continue (default)
66
- - **`'error'`** — Fail the build
65
+ - **`'error'`** — Fail the build (default)
66
+ - **`'warn'`** — Log a warning but continue
67
67
  - **`'off'`** — Disable consistency checking
68
68
 
69
69
  ### 2. Configure i18n in your boot file
70
70
 
71
- **VERY IMPORTANT:** `i18n.configure` must be awaited during boot before handling any requests!
71
+ > **Note:** `i18n.configure` must be awaited during boot, before any requests are handled.
72
72
 
73
73
  ```ts
74
74
  // src/boot.ts
@@ -1,5 +1,5 @@
1
- import { a as ExtractionManifest } from '../types-moTgocy7.js';
2
- export { C as ChunkManifest, E as ExtractedKey } from '../types-moTgocy7.js';
1
+ import { E as ExtractionManifest } from '../types-ChMT6Vbd.js';
2
+ export { C as ChunkManifest, a as ExtractedKey } from '../types-ChMT6Vbd.js';
3
3
  import { AstroIntegrationLogger } from 'astro';
4
4
  import { Plugin } from 'vite';
5
5
  import { C as ConsistencyCheckLevel } from '../types-B_8vAmvv.js';
@@ -1,4 +1,4 @@
1
- import { a as ExtractionManifest } from './types-moTgocy7.js';
1
+ import { E as ExtractionManifest } from './types-ChMT6Vbd.js';
2
2
  import { T as TranslationMeta, C as CompiledTranslations, R as RawTranslations } from './types-DNRFj1XA.js';
3
3
 
4
4
  /**
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { AstroIntegration, APIContext, MiddlewareHandler } from 'astro';
2
2
  import { I as I18nOptions } from './types-B_8vAmvv.js';
3
- export { F as FallbackBehavior, I as I18nConfig, i as i18n } from './i18n-BmK1MjH7.js';
3
+ export { F as FallbackBehavior, I as I18nConfig, i as i18n } from './i18n-B--L7OQk.js';
4
4
  import { ExcludePattern } from '@astroscope/excludes';
5
5
  export { R as RawTranslations, T as TranslationMeta } from './types-DNRFj1XA.js';
6
- export { E as ExtractedKey, a as ExtractionManifest } from './types-moTgocy7.js';
6
+ export { a as ExtractedKey, E as ExtractionManifest } from './types-ChMT6Vbd.js';
7
7
 
8
8
  /**
9
9
  * Astro integration for i18n with automatic per-chunk translation loading.
@@ -1,7 +1,7 @@
1
- import { a as I18nContext } from './i18n-BmK1MjH7.js';
2
- export { i as i18n } from './i18n-BmK1MjH7.js';
1
+ import { a as I18nContext } from './i18n-B--L7OQk.js';
2
+ export { i as i18n } from './i18n-B--L7OQk.js';
3
3
  export { I as I18nClientState } from './types-DNRFj1XA.js';
4
- import './types-moTgocy7.js';
4
+ import './types-ChMT6Vbd.js';
5
5
 
6
6
  /**
7
7
  * Get the current i18n context
@@ -27,4 +27,4 @@ type ExtractionManifest = {
27
27
  imports: ImportsManifest;
28
28
  };
29
29
 
30
- export type { ChunkManifest as C, ExtractedKey as E, ExtractionManifest as a };
30
+ export type { ChunkManifest as C, ExtractionManifest as E, ExtractedKey as a };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astroscope/i18n",
3
- "version": "0.4.5",
3
+ "version": "0.5.0",
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",
@@ -82,7 +82,7 @@
82
82
  },
83
83
  "homepage": "https://github.com/entwico/astroscope/tree/main/packages/i18n#readme",
84
84
  "dependencies": {
85
- "@astrojs/compiler": "^3.0.1",
85
+ "@astrojs/compiler": "^4.0.0",
86
86
  "@babel/core": "^7.29.0",
87
87
  "@babel/preset-typescript": "^7.28.5",
88
88
  "messageformat": "^4.0.0",
@@ -91,10 +91,11 @@
91
91
  "devDependencies": {
92
92
  "@babel/types": "^7.29.0",
93
93
  "@types/babel__core": "^7.20.5",
94
- "astro": "^6.1.8",
94
+ "astro": "^6.2.2",
95
95
  "tsup": "^8.5.1",
96
96
  "typescript": "^5.9.3",
97
- "vite": "^7.0.0"
97
+ "vite": "^7.0.0",
98
+ "@astroscope/excludes": "^0.3.2"
98
99
  },
99
100
  "peerDependencies": {
100
101
  "astro": "^6.0.0",
@@ -103,7 +104,7 @@
103
104
  "scripts": {
104
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",
105
106
  "typecheck": "tsc --noEmit",
106
- "lint": "eslint src",
107
+ "lint": "eslint src --cache",
107
108
  "lint:fix": "eslint src --fix"
108
109
  }
109
110
  }