i18n-json-react 0.0.0-stage → 0.1.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.
Files changed (157) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +401 -2
  3. package/bundlers/shared.cjs +91 -0
  4. package/dist/cjs/api-types.d.ts +17 -0
  5. package/dist/cjs/api-types.d.ts.map +1 -0
  6. package/dist/cjs/api-types.js +3 -0
  7. package/dist/cjs/api-types.js.map +1 -0
  8. package/dist/cjs/core.d.ts +10 -0
  9. package/dist/cjs/core.d.ts.map +1 -0
  10. package/dist/cjs/core.js +31 -0
  11. package/dist/cjs/core.js.map +1 -0
  12. package/dist/cjs/default-store.d.ts +7 -0
  13. package/dist/cjs/default-store.d.ts.map +1 -0
  14. package/dist/cjs/default-store.js +96 -0
  15. package/dist/cjs/default-store.js.map +1 -0
  16. package/dist/cjs/dictionaries.d.ts +7 -0
  17. package/dist/cjs/dictionaries.d.ts.map +1 -0
  18. package/dist/cjs/dictionaries.js +31 -0
  19. package/dist/cjs/dictionaries.js.map +1 -0
  20. package/dist/cjs/index.d.ts +24 -0
  21. package/dist/cjs/index.d.ts.map +1 -0
  22. package/dist/cjs/index.js +38 -0
  23. package/dist/cjs/index.js.map +1 -0
  24. package/dist/cjs/interpolation.d.ts +6 -0
  25. package/dist/cjs/interpolation.d.ts.map +1 -0
  26. package/dist/cjs/interpolation.js +26 -0
  27. package/dist/cjs/interpolation.js.map +1 -0
  28. package/dist/cjs/languages.d.ts +4 -0
  29. package/dist/cjs/languages.d.ts.map +1 -0
  30. package/dist/cjs/languages.js +61 -0
  31. package/dist/cjs/languages.js.map +1 -0
  32. package/dist/cjs/package.json +1 -0
  33. package/dist/cjs/react.d.ts +15 -0
  34. package/dist/cjs/react.d.ts.map +1 -0
  35. package/dist/cjs/react.js +54 -0
  36. package/dist/cjs/react.js.map +1 -0
  37. package/dist/cjs/resource.d.ts +8 -0
  38. package/dist/cjs/resource.d.ts.map +1 -0
  39. package/dist/cjs/resource.js +34 -0
  40. package/dist/cjs/resource.js.map +1 -0
  41. package/dist/cjs/store-types.d.ts +10 -0
  42. package/dist/cjs/store-types.d.ts.map +1 -0
  43. package/dist/cjs/store-types.js +17 -0
  44. package/dist/cjs/store-types.js.map +1 -0
  45. package/dist/cjs/store.d.ts +24 -0
  46. package/dist/cjs/store.d.ts.map +1 -0
  47. package/dist/cjs/store.js +139 -0
  48. package/dist/cjs/store.js.map +1 -0
  49. package/dist/cjs/typed-react.d.ts +5 -0
  50. package/dist/cjs/typed-react.d.ts.map +1 -0
  51. package/dist/cjs/typed-react.js +23 -0
  52. package/dist/cjs/typed-react.js.map +1 -0
  53. package/dist/cjs/types.d.ts +91 -0
  54. package/dist/cjs/types.d.ts.map +1 -0
  55. package/dist/cjs/types.js +3 -0
  56. package/dist/cjs/types.js.map +1 -0
  57. package/dist/esm/api-types.d.ts +17 -0
  58. package/dist/esm/api-types.d.ts.map +1 -0
  59. package/dist/esm/api-types.js +2 -0
  60. package/dist/esm/api-types.js.map +1 -0
  61. package/dist/esm/core.d.ts +10 -0
  62. package/dist/esm/core.d.ts.map +1 -0
  63. package/dist/esm/core.js +25 -0
  64. package/dist/esm/core.js.map +1 -0
  65. package/dist/esm/default-store.d.ts +7 -0
  66. package/dist/esm/default-store.d.ts.map +1 -0
  67. package/dist/esm/default-store.js +93 -0
  68. package/dist/esm/default-store.js.map +1 -0
  69. package/dist/esm/dictionaries.d.ts +7 -0
  70. package/dist/esm/dictionaries.d.ts.map +1 -0
  71. package/dist/esm/dictionaries.js +26 -0
  72. package/dist/esm/dictionaries.js.map +1 -0
  73. package/dist/esm/index.d.ts +24 -0
  74. package/dist/esm/index.d.ts.map +1 -0
  75. package/dist/esm/index.js +31 -0
  76. package/dist/esm/index.js.map +1 -0
  77. package/dist/esm/interpolation.d.ts +6 -0
  78. package/dist/esm/interpolation.d.ts.map +1 -0
  79. package/dist/esm/interpolation.js +22 -0
  80. package/dist/esm/interpolation.js.map +1 -0
  81. package/dist/esm/languages.d.ts +4 -0
  82. package/dist/esm/languages.d.ts.map +1 -0
  83. package/dist/esm/languages.js +57 -0
  84. package/dist/esm/languages.js.map +1 -0
  85. package/dist/esm/package.json +1 -0
  86. package/dist/esm/react.d.ts +15 -0
  87. package/dist/esm/react.d.ts.map +1 -0
  88. package/dist/esm/react.js +51 -0
  89. package/dist/esm/react.js.map +1 -0
  90. package/dist/esm/resource.d.ts +8 -0
  91. package/dist/esm/resource.d.ts.map +1 -0
  92. package/dist/esm/resource.js +31 -0
  93. package/dist/esm/resource.js.map +1 -0
  94. package/dist/esm/store-types.d.ts +10 -0
  95. package/dist/esm/store-types.d.ts.map +1 -0
  96. package/dist/esm/store-types.js +14 -0
  97. package/dist/esm/store-types.js.map +1 -0
  98. package/dist/esm/store.d.ts +24 -0
  99. package/dist/esm/store.d.ts.map +1 -0
  100. package/dist/esm/store.js +136 -0
  101. package/dist/esm/store.js.map +1 -0
  102. package/dist/esm/typed-react.d.ts +5 -0
  103. package/dist/esm/typed-react.d.ts.map +1 -0
  104. package/dist/esm/typed-react.js +20 -0
  105. package/dist/esm/typed-react.js.map +1 -0
  106. package/dist/esm/types.d.ts +91 -0
  107. package/dist/esm/types.d.ts.map +1 -0
  108. package/dist/esm/types.js +2 -0
  109. package/dist/esm/types.js.map +1 -0
  110. package/dist/types/registry.d.cts +10 -0
  111. package/native/README.md +179 -0
  112. package/native/android/README.md +14 -0
  113. package/native/android/cli.cjs +2 -0
  114. package/native/android/expo.cjs +1 -0
  115. package/native/android/expo.d.cts +1 -0
  116. package/native/android/index.cjs +3 -0
  117. package/native/android/index.d.cts +5 -0
  118. package/native/android/metro.cjs +3 -0
  119. package/native/android/metro.d.cts +7 -0
  120. package/native/android/prepare.cjs +3 -0
  121. package/native/cli.cjs +43 -0
  122. package/native/expo.cjs +17 -0
  123. package/native/expo.d.cts +7 -0
  124. package/native/index.cjs +18 -0
  125. package/native/index.d.cts +14 -0
  126. package/native/ios/README.md +58 -0
  127. package/native/ios/cli.cjs +2 -0
  128. package/native/ios/expo.cjs +1 -0
  129. package/native/ios/expo.d.cts +1 -0
  130. package/native/ios/index.cjs +3 -0
  131. package/native/ios/index.d.cts +5 -0
  132. package/native/ios/metro.cjs +3 -0
  133. package/native/ios/metro.d.cts +7 -0
  134. package/native/ios/prepare.cjs +3 -0
  135. package/native/metro.cjs +45 -0
  136. package/native/metro.d.cts +34 -0
  137. package/native/prepare.cjs +120 -0
  138. package/package.json +165 -4
  139. package/src/api-types.ts +42 -0
  140. package/src/core.ts +29 -0
  141. package/src/default-store.ts +106 -0
  142. package/src/dictionaries.ts +31 -0
  143. package/src/index.ts +46 -0
  144. package/src/interpolation.ts +31 -0
  145. package/src/languages.ts +62 -0
  146. package/src/react.ts +83 -0
  147. package/src/resource.ts +40 -0
  148. package/src/store-types.ts +36 -0
  149. package/src/store.ts +150 -0
  150. package/src/typed-react.ts +33 -0
  151. package/src/types.ts +113 -0
  152. package/types/registry.d.cts +10 -0
  153. package/vite/index.cjs +145 -0
  154. package/vite/index.d.cts +15 -0
  155. package/webpack/index.cjs +46 -0
  156. package/webpack/index.d.cts +22 -0
  157. package/webpack/loader.cjs +21 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 alex-tsx
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
@@ -1,3 +1,402 @@
1
- # Temporary Holding Version
1
+ # i18n-json-react
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Feature-local JSON translations with typed keys, React hooks, and optional per-language Vite, Webpack, or Android/iOS Metro assets. No runtime dependencies other than the React peer for the main entry. The `/core` entry works without React; the optional Expo adapter uses native peer modules.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ npm install i18n-json-react
9
+ ```
10
+
11
+ Use React 18.3 or 19. Build tools require Node 22.13 or newer; the declarations require TypeScript 5.4 or newer. Enable TypeScript's `resolveJsonModule` to infer keys from JSON imports.
12
+
13
+ ## Start with inline JSON
14
+
15
+ Keep translations beside the feature, in `i18n.json` or `*.i18n.json`. Language identifiers are configured by your app; no languages are hard-coded. Keys are flat strings, so dots in keys are literal.
16
+
17
+ ```json
18
+ {
19
+ "en": { "hello": "Hello, {name}", "buttons.save": "Save" },
20
+ "uk": { "hello": "Вітаю, {name}", "buttons.save": "Зберегти" },
21
+ "pt-BR": { "hello": "Olá, {name}", "buttons.save": "Salvar" }
22
+ }
23
+ ```
24
+
25
+ Configure the shared default instance during application startup:
26
+
27
+ ```ts
28
+ // i18n.ts
29
+ import I18N from 'i18n-json-react';
30
+
31
+ I18N.configure({
32
+ supportedLanguages: ['en', 'uk', 'pt-BR'],
33
+ fallbackLanguage: 'en',
34
+ });
35
+ ```
36
+
37
+ ```tsx
38
+ // profile.tsx
39
+ import { memo } from 'react';
40
+ import { createUseTypo } from 'i18n-json-react';
41
+ import messages from './i18n.json';
42
+
43
+ const useProfileTypo = createUseTypo(messages);
44
+
45
+ export const Profile = memo(function Profile() {
46
+ const t = useProfileTypo();
47
+ const buttons = useProfileTypo({ keyPrefix: 'buttons.' });
48
+ return (
49
+ <button>
50
+ {t('hello', { name: 'Alex' })} — {buttons('save')}
51
+ </button>
52
+ );
53
+ });
54
+ ```
55
+
56
+ Inline imports work in Webpack, Vite, and other bundlers without a plugin, provider, loader component, or Suspense. All imported languages remain in the JavaScript bundle. Create hooks and translation components at module scope, outside render.
57
+
58
+ The default export and package-level translation helpers share one configuration. `createUseTypo`, `createTypo`, and `createTypoGetter` can run before `configure`, so importing feature modules before startup configuration is safe. Call `configure` before rendering translations or reading language state; otherwise those reads throw a setup error. There are no implicit supported languages. Import your setup module from the application entry point before rendering.
59
+
60
+ `configure` accepts the same options as `createI18n`. Calling it again replaces the whole configuration, resets language detection and dictionary caches, and updates existing helpers and mounted roots. Include the supported languages and fallback on every call. Invalid options leave the active configuration intact. Use `setCurrentLang` for ordinary language switching.
61
+
62
+ For independent applications or server requests, create an isolated instance instead:
63
+
64
+ ```ts
65
+ import { createI18n } from 'i18n-json-react';
66
+
67
+ export const i18n = createI18n({
68
+ supportedLanguages: ['en', 'uk'],
69
+ fallbackLanguage: 'en',
70
+ });
71
+
72
+ export const { createUseTypo, createTypo, useI18nLanguage, setCurrentLang } = i18n;
73
+ ```
74
+
75
+ Factory-created instances are independent of `I18N.configure`. Their configured language union checks both language operations and feature dictionary locale keys. Package-level helpers can obtain the same checks through an application declaration, described below. Translation keys and prefixes retain their JSON-based types in both APIs.
76
+
77
+ `t` is callable and supports `const { t } = useProfileTypo()`. Unknown keys fail type checking; a prefix limits keys to the matching suffixes. Missing messages fall back per key to `fallbackLanguage`, then to `i18n(key)`. Pass `{ placehold: false }` to return `''` for missing messages. Empty translations stay empty.
78
+
79
+ Interpolation replaces `{name}` with string/number values. Missing, `null`, and `undefined` values become empty strings. Values are plain text; render them normally in React. ICU messages, automatic plural rules, nested key traversal, and HTML parsing are outside this package's scope. Use `Intl` for dates and numbers.
80
+
81
+ ### Application-wide TypeScript configuration
82
+
83
+ Runtime calls to `I18N.configure` cannot change types in other modules. Register the shared instance's language types by augmenting `CustomTypeOptions` in a separate declaration file included by your `tsconfig.json`:
84
+
85
+ ```ts
86
+ // src/i18n-types.d.ts
87
+ import 'i18n-json-react';
88
+
89
+ declare module 'i18n-json-react' {
90
+ interface CustomTypeOptions {
91
+ supportedLanguages: 'EN' | 'UK';
92
+ fallbackLanguage: 'UK';
93
+ }
94
+ }
95
+ ```
96
+
97
+ This checks imported JSON variables at each dictionary-taking helper (`createTypo`, `createUseTypo`, `createTypoGetter`, `useTypoAsObject`, and `getTypoAsObject`). The default export and named helpers use the same declaration in ESM and CommonJS.
98
+
99
+ ```ts
100
+ import I18N, { createTypo, setCurrentLang } from 'i18n-json-react';
101
+ import messages from './i18n.json';
102
+
103
+ I18N.configure({ supportedLanguages: ['EN', 'UK'], fallbackLanguage: 'UK' });
104
+ const Text = createTypo(messages); // Rejects unknown locale keys or a missing UK entry.
105
+ setCurrentLang('EN');
106
+ setCurrentLang('FR'); // Type error.
107
+ ```
108
+
109
+ - `supportedLanguages` is a union of exact JSON locale identifiers. Unknown identifiers, including a casing mismatch, are type errors. Runtime configuration must include the declared language set.
110
+ - `fallbackLanguage` is optional in the declaration. When provided, runtime configuration must use that fallback and feature JSON must contain its entry. Other supported locales and individual message keys may remain partial.
111
+ - Translation keys and prefixes are still inferred from each JSON import. An opaque `DictionaryReference` preserves its declared keys; it no longer contains locale entries to check.
112
+ - Without an application declaration, shared helpers continue to accept arbitrary locale identifiers. Isolated `createI18n` and `/core` stores always check their own configured language union and do not inherit the global declaration.
113
+
114
+ Keep runtime and type configuration together by deriving the declaration from shared constants:
115
+
116
+ ```ts
117
+ // src/i18n-config.ts
118
+ export const SUPPORTED_LANGUAGES = ['EN', 'UK'] as const;
119
+ export const FALLBACK_LANGUAGE = 'UK';
120
+ ```
121
+
122
+ ```ts
123
+ // src/i18n-types.d.ts
124
+ import 'i18n-json-react';
125
+ import type { FALLBACK_LANGUAGE, SUPPORTED_LANGUAGES } from './i18n-config.js';
126
+
127
+ declare module 'i18n-json-react' {
128
+ interface CustomTypeOptions {
129
+ supportedLanguages: (typeof SUPPORTED_LANGUAGES)[number];
130
+ fallbackLanguage: typeof FALLBACK_LANGUAGE;
131
+ }
132
+ }
133
+ ```
134
+
135
+ Pass those same constants to `I18N.configure({ supportedLanguages: SUPPORTED_LANGUAGES, fallbackLanguage: FALLBACK_LANGUAGE })` during startup. The declaration is type-only and does not perform runtime configuration. Checks occur at the helper call using the original imported JSON; they do not install a JSON editor schema or check files that are never passed to a typed helper.
136
+
137
+ ### Custom interpolation delimiters
138
+
139
+ Set `interpolation` in `I18N.configure` or when creating an instance. Both delimiters are literal, nonempty strings; the default is `{ prefix: '{', suffix: '}' }`.
140
+
141
+ ```ts
142
+ const i18n = createI18n({
143
+ supportedLanguages: ['en', 'uk'],
144
+ fallbackLanguage: 'en',
145
+ interpolation: { prefix: '${', suffix: '}' },
146
+ });
147
+
148
+ const t = i18n.createTypoGetter({ en: { hello: 'Hello, ${name}' } });
149
+ t('hello', { name: 'Alex' }); // "Hello, Alex"
150
+ ```
151
+
152
+ The instance configuration applies to hooks, translation components, getters, fallback messages, and both inline and extracted dictionaries. Delimiters are compiled once per instance. Existing JSON files need no build-tool configuration change.
153
+
154
+ | Placeholder | `prefix` | `suffix` |
155
+ | --------------------------- | ------------------ | ------------------ |
156
+ | `{name}` (default) | `{` | `}` |
157
+ | `{{name}}` | `{{` | `}}` |
158
+ | `${name}` | `${` | `}` |
159
+ | `$${name}` | `$${` | `}` |
160
+ | `"name"` | `"` | `"` |
161
+ | `'name'` | `'` | `'` |
162
+ | <code>&#96;name&#96;</code> | <code>&#96;</code> | <code>&#96;</code> |
163
+
164
+ Parameter names support ASCII letters, digits, underscores, dots, and hyphens. Quote delimiters treat quoted parameter names as placeholders, so choose them accordingly for text that also uses quotation marks. Missing values keep the same empty-string behavior for every delimiter pair. Calling a translator without values leaves its template unchanged.
165
+
166
+ For a standalone template, pass the delimiters as the third argument, or use the instance's configured helper:
167
+
168
+ ```ts
169
+ import { interpolateTypo } from 'i18n-json-react';
170
+
171
+ interpolateTypo('Hello, {{name}}', { name: 'Alex' }, { prefix: '{{', suffix: '}}' });
172
+ i18n.interpolateTypo('Hello, ${name}', { name: 'Alex' });
173
+ ```
174
+
175
+ `I18N.interpolateTypo` uses the shared configuration. The standalone named `interpolateTypo` helper remains independent: it uses `{name}` unless its third argument supplies custom delimiters.
176
+
177
+ ## Language selection
178
+
179
+ ```ts
180
+ i18n.getCurrentLang();
181
+ i18n.setCurrentLang('pt-BR'); // Persists the choice and updates subscribed React roots.
182
+ const language = i18n.useI18nLanguage(); // Inside a component.
183
+ const unsubscribe = i18n.subscribe(() => console.log(i18n.getCurrentLang()));
184
+ unsubscribe();
185
+ ```
186
+
187
+ Each instance shares its language across all roots and non-React callers. Separate instances are isolated. Choose separate `storageKey` values if instances should remember independent choices.
188
+
189
+ On first use, selection checks `initialLanguage`, the saved choice, browser preferences, then the fallback. Locale matching ignores case and treats `_` as `-`; an exact regional or script match wins, then progressively shorter tags (`zh-Hant-TW` → `zh-Hant` → `zh`). Matching returns the configured spelling. A generic language does not arbitrarily choose a region (`pt` does not choose `pt-BR`). There are no application-specific locale aliases. Use matching identifiers in your config and JSON files, including case.
190
+
191
+ Uppercase identifiers work with either API:
192
+
193
+ ```ts
194
+ import I18N, { setCurrentLang } from 'i18n-json-react';
195
+
196
+ I18N.configure({ supportedLanguages: ['EN', 'UK'], fallbackLanguage: 'UK' });
197
+ setCurrentLang('EN');
198
+ ```
199
+
200
+ Use `EN` and `UK` keys in your JSON. Browser preferences such as `en-US` and `uk-UA` resolve to those configured spellings, and extracted files are named `EN.json` and `UK.json`.
201
+
202
+ Configuration:
203
+
204
+ | Option | Default / behavior |
205
+ | --------------------- | ------------------------------------------------------------------------------------------------------- |
206
+ | `supportedLanguages` | Required, nonempty list of language identifiers; infers the language union |
207
+ | `fallbackLanguage` | Required member of that list |
208
+ | `initialLanguage` | Explicit initial choice; useful for SSR and controlled startup |
209
+ | `storage` | Browser `localStorage`; `false` disables persistence; accepts a synchronous `getItem`/`setItem` adapter |
210
+ | `storageKey` | `i18n-language`; stores plain strings such as `pt-BR` |
211
+ | `interpolation` | `{ prefix: '{', suffix: '}' }`; literal placeholder delimiters for all instance translators |
212
+ | `getBrowserLanguages` | `navigator.languages`, then `navigator.language`; accepts a custom function for nonbrowser hosts |
213
+ | `onError` | `console.error`; reports storage access failures while language switching continues |
214
+ | `loadDictionary` | Optional async loader for extracted language files |
215
+ | `dictionaries` | Optional preloaded extracted files, keyed by language |
216
+
217
+ Language changes are explicit within each instance. Other libraries and browser tabs can follow `subscribe` and call `setCurrentLang` as needed.
218
+
219
+ ## Android and iOS / React Native
220
+
221
+ See the [native integration guide](native/README.md) for Metro configuration, Expo SDK 54+ loading, native storage/locale setup, and a shared Health Ledger PWA/Android/iOS layout.
222
+
223
+ The native integration replaces feature imports with IDs and packages each locale as a separate data asset outside the main JavaScript/Hermes bundle. Only selected/fallback translations are read and parsed initially. All packaged locales remain available offline; use the build's `languages` option to reduce the packaged language set.
224
+
225
+ Use `i18n-json-react/native/metro` at build time and `i18n-json-react/native/expo` in Expo startup code. Shared feature code keeps importing hooks/components and JSON normally. The same workspace root gives feature IDs matching the web builds.
226
+
227
+ Translation preparation runs at Metro startup: restart Metro after translation JSON changes. Web/Vite reload behavior is unchanged. The guide includes a preparation CLI for native type-checking and CI.
228
+
229
+ ## Extract language files with Vite 7 or 8
230
+
231
+ ```ts
232
+ // vite.config.ts
233
+ import { defineConfig } from 'vite';
234
+ import { i18nJsonPlugin } from 'i18n-json-react/vite';
235
+
236
+ export default defineConfig({
237
+ plugins: [i18nJsonPlugin({ exclude: ['scripts/**'] })],
238
+ });
239
+ ```
240
+
241
+ The plugin replaces default imports of `i18n.json` and `*.i18n.json` with feature IDs. Production builds emit `i18n/<language>.json`; during development the Vite server serves the same files under the configured `base` path. A translation edit, addition, or deletion triggers a full page reload so cached language resources are recreated. No query provider or additional client code is needed.
242
+
243
+ Use the same runtime loading setup described below. For Vite, include its public base path:
244
+
245
+ ```ts
246
+ loadDictionary: createFetchDictionaryLoader({
247
+ baseUrl: `${import.meta.env.BASE_URL}i18n`,
248
+ }),
249
+ ```
250
+
251
+ Options:
252
+
253
+ | Option | Default / behavior |
254
+ | ----------- | ------------------------------------------------------------------------------------------------ |
255
+ | `root` | Vite's project root; an explicit path can be absolute or relative to that root |
256
+ | `dirs` | `['.']`; directory globs relative to `root` |
257
+ | `exclude` | File/directory globs relative to `root`; Vite's build output directory is excluded automatically |
258
+ | `outputDir` | `i18n`; relative emitted and served directory; match the runtime loader's `baseUrl` |
259
+
260
+ For example, use `dirs: ['.', 'node_modules/@your-org/*']` to collect dependency dictionaries. Nested dependency folders and `.git` are skipped. The Vite and Webpack integrations share validation, collection, and ID generation. JSON excluded from collection stays inline; explicit `?raw` and `?url` imports keep Vite's normal behavior.
261
+
262
+ If Vite prebundles a dependency that imports these JSON files, add that package to `optimizeDeps.exclude` so the plugin can process its source imports. Put translated source files outside Vite's `publicDir`, whose contents are copied as static files without module processing.
263
+
264
+ ## Extract language files with Webpack 5
265
+
266
+ The optional loader replaces each JSON import with `{ __id: "..." }`. The collector emits `i18n/<language>.json`, containing feature IDs and their messages. Original JSON files still provide TypeScript's key inference. The same runtime API works with inline imports or extracted references.
267
+
268
+ ```js
269
+ // webpack.config.cjs
270
+ const { I18nCollectPlugin, i18nLoaderRule } = require('i18n-json-react/webpack');
271
+
272
+ module.exports = {
273
+ module: { rules: [i18nLoaderRule()] },
274
+ plugins: [new I18nCollectPlugin({ exclude: ['scripts/**', 'dist/**'] })],
275
+ };
276
+ ```
277
+
278
+ The collector scans the project by default, skipping nested `node_modules`, `ide_node_modules`, and `.git` directories. To include feature dictionaries from dependencies, list their directories explicitly:
279
+
280
+ ```js
281
+ new I18nCollectPlugin({
282
+ dirs: ['.', 'node_modules/@your-org/*'],
283
+ exclude: ['scripts/**', 'dist/**'],
284
+ outputDir: 'i18n',
285
+ });
286
+ ```
287
+
288
+ It collects all matching files under those directories, including files that are not imported. `exclude` globs are relative to `root`. IDs use real file paths relative to `root`, so linked packages work too. The collector tracks files and directories for watch rebuilds.
289
+
290
+ Both helpers accept `root`, an absolute path or a path relative to Webpack's context. Set the same root on both. `outputDir` is a relative emitted asset path, defaulting to `i18n`. The plugin and runtime emit/load the exact language identifiers from your JSON. JSON must contain objects of string messages; invalid input fails the build.
291
+
292
+ ## Load extracted translations
293
+
294
+ Configure fetching for either bundler:
295
+
296
+ ```ts
297
+ import I18N, { createFetchDictionaryLoader } from 'i18n-json-react';
298
+
299
+ I18N.configure({
300
+ supportedLanguages: ['en', 'uk', 'pt-BR'],
301
+ fallbackLanguage: 'en',
302
+ loadDictionary: createFetchDictionaryLoader({ baseUrl: '/i18n' }),
303
+ });
304
+ ```
305
+
306
+ `baseUrl` defaults to `i18n` (relative to the current page). Include your deployment's public path explicitly, such as `/app/assets/i18n`. You can supply `fetch` and `requestInit`, or replace the loader entirely with an async function returning a language dictionary. HTTP failures and malformed payloads reject.
307
+
308
+ ```tsx
309
+ import { Suspense } from 'react';
310
+ import { LoaderForI18N } from 'i18n-json-react';
311
+
312
+ <Suspense fallback={<span>Loading translations…</span>}>
313
+ <LoaderForI18N />
314
+ <App />
315
+ </Suspense>;
316
+ ```
317
+
318
+ Extracted translation hooks also suspend automatically, so `LoaderForI18N` is optional. It is useful to load translations before other app content. Put it inside the same Suspense boundary as the content. Use an error boundary for failed loads.
319
+
320
+ A small internal resource caches each language's promise, result, or error. It loads the fallback and selected language concurrently, deduplicates requests across roots, and never refetches successful files automatically. A failed file throws to the error boundary; it does not silently mark a failed request as loaded.
321
+
322
+ ```ts
323
+ await I18N.loadLanguage('pt-BR'); // Preload selected language and fallback without changing the language.
324
+ I18N.setCurrentLang('pt-BR');
325
+
326
+ // After a failure: retry the request, then reset your error boundary.
327
+ await I18N.loadLanguage('pt-BR', { retry: true });
328
+ ```
329
+
330
+ Serve matching JavaScript and dictionary assets together, with an appropriate HTTP cache policy. Use a fresh instance, reconfigure the default instance, or reload the page to load a new version of a successfully cached dictionary.
331
+
332
+ ## Other helpers
333
+
334
+ ```tsx
335
+ import { createTypo, useTypoAsObject } from 'i18n-json-react';
336
+
337
+ const Text = createTypo(messages);
338
+ <Text id="hello" values={{ name: 'Alex' }} />;
339
+
340
+ const ButtonText = createTypo(messages, 'buttons.');
341
+ <ButtonText id="save" />;
342
+
343
+ // In a component: a memoized object merged with the fallback.
344
+ const texts = useTypoAsObject(messages);
345
+ // Each property's value is string | undefined; missing values are not placeholders.
346
+ ```
347
+
348
+ For non-React code:
349
+
350
+ ```ts
351
+ import { createTypoGetter } from 'i18n-json-react';
352
+
353
+ const getText = createTypoGetter(messages);
354
+ getText('hello', { name: 'Alex' });
355
+
356
+ const getEnglish = createTypoGetter(messages, { language: 'en', placehold: false });
357
+ ```
358
+
359
+ Getters follow the current language unless fixed explicitly. They do not subscribe, fetch, or suspend. With extracted files, await `loadLanguage` before calling them. In React render, use the hooks/components so language changes rerender your UI.
360
+
361
+ Use `createI18nStore` from `i18n-json-react/core` for the same language, loading, getter, and subscription APIs without importing React. `createFetchDictionaryLoader` and `interpolateTypo` are available from both entry points. Custom build tools can produce `{ __id }` references typed as `DictionaryReference<YourKeys>` and language files typed as `LanguageDictionary`.
362
+
363
+ ## Server rendering
364
+
365
+ Create an instance per request, with `storage: false` and an explicit `initialLanguage`. For extracted files, supply `dictionaries` or await `loadLanguage` before rendering. Use the same initial language and preloaded dictionaries when hydrating. React's server snapshot uses `initialLanguage` or the fallback and never reads browser storage.
366
+
367
+ ```ts
368
+ const requestI18n = createI18n({
369
+ supportedLanguages: ['en', 'uk'],
370
+ fallbackLanguage: 'en',
371
+ initialLanguage: 'uk',
372
+ storage: false,
373
+ dictionaries: { en: englishDictionary, uk: ukrainianDictionary },
374
+ });
375
+ ```
376
+
377
+ Bind the request's feature hooks to that instance. Do not put a mutable server instance in a process-wide singleton shared by requests.
378
+
379
+ ## Differences from the SDK implementation
380
+
381
+ - Configure languages and fallback per instance rather than using a fixed `UK`/`EN` global.
382
+ - Use `createUseTypo` for callable translators. The deprecated `createUseTypoHook` proxy export is omitted.
383
+ - No TanStack Query or query provider is needed.
384
+ - `createTypoGetter` takes an options object instead of positional language/placeholder arguments.
385
+ - Storage adapters use the native string storage contract. The SDK stored a versioned JSON record under `item:{i18n-language}`; migrate its `value` explicitly if you want to keep existing preferences.
386
+ - Failed dictionary loads throw to an error boundary and can be retried explicitly.
387
+ - Default collection scans only the project; include dependency directories explicitly.
388
+ - Feature IDs differ from SDK IDs. Use this package's loader and collector together.
389
+
390
+ ## Development
391
+
392
+ ```sh
393
+ npm ci
394
+ npm run check
395
+ npm pack --dry-run
396
+ ```
397
+
398
+ `check` builds ESM and CommonJS with declaration/source maps, checks consumer types for both formats, and runs runtime, React, SSR, Vite build/dev-server, Webpack extraction/watch, and production Android/iOS Metro tests. Set `I18N_JSON_REACT_HERMES` to an installed Hermes CLI to also execute both native bundles in Hermes. React, bundlers, and Expo modules are optional peers; install only those required by your entry points. There are no runtime `dependencies`.
399
+
400
+ The [GitHub Actions workflow](.github/workflows/test.yml) runs on pushes and pull requests, using Node 22 and 24 with npm 11 on Linux, macOS, and Windows. Each job installs from the lockfile, runs `npm run check`, and checks packaging with `npm pack --dry-run`. CI builds and checks both native bundles; executing them in Hermes requires the optional local CLI described above.
401
+
402
+ Licensed under the [MIT License](LICENSE). Nothing in the build publishes or commits changes.
@@ -0,0 +1,91 @@
1
+ const { createHash } = require('node:crypto');
2
+ const { realpathSync } = require('node:fs');
3
+ const { glob, readFile, realpath, stat } = require('node:fs/promises');
4
+ const path = require('node:path');
5
+
6
+ function resolveRoot(context, root) {
7
+ return realpathSync(path.resolve(context, root ?? '.'));
8
+ }
9
+
10
+ function computeId(file, root) {
11
+ // Bundlers normally resolve linked packages to real paths. Collection must use the same identity.
12
+ const relative = path.relative(realpathSync(root), realpathSync(file)).split(path.sep).join('/');
13
+ return createHash('sha256').update(relative).digest('hex').slice(0, 16);
14
+ }
15
+
16
+ function parseFeature(content, file) {
17
+ const json = JSON.parse(content);
18
+ if (!isRecord(json)) throw new Error(`Expected a language object in ${file}`);
19
+ for (const [language, messages] of Object.entries(json)) {
20
+ if (!/^[a-zA-Z]{2,8}(?:[-_][a-zA-Z0-9]{1,8})*$/.test(language)) {
21
+ throw new Error(`Invalid language identifier "${language}" in ${file}`);
22
+ }
23
+ if (!isRecord(messages)) throw new Error(`Expected a message object for "${language}" in ${file}`);
24
+ for (const [key, value] of Object.entries(messages)) {
25
+ if (typeof value !== 'string') throw new Error(`Expected a string for "${language}.${key}" in ${file}`);
26
+ }
27
+ }
28
+ return json;
29
+ }
30
+
31
+ function resolveOutputDir(outputDir = 'i18n') {
32
+ if (path.isAbsolute(outputDir) || outputDir.includes('\\') || outputDir.split('/').includes('..')) {
33
+ throw new Error('i18n outputDir must be a relative POSIX asset path');
34
+ }
35
+ return path.posix.normalize(outputDir).replace(/\/+$/, '').replace(/^\.$/, '');
36
+ }
37
+
38
+ async function collectDictionaries(root, options = {}, onDirectory = () => {}) {
39
+ const files = new Set();
40
+ const excludes = options.exclude ?? [];
41
+ // Directory dependencies also detect newly added feature files.
42
+ onDirectory(root);
43
+ for (const pattern of options.dirs ?? ['.']) {
44
+ const dirs = /[*?[\]{}]/.test(pattern) ? glob(pattern, { cwd: root }) : [pattern];
45
+ for await (const dir of dirs) {
46
+ const absolute = path.resolve(root, dir);
47
+ let stats;
48
+ try {
49
+ stats = await stat(absolute);
50
+ } catch (error) {
51
+ if (error.code === 'ENOENT') continue;
52
+ throw error;
53
+ }
54
+ if (!stats.isDirectory()) continue;
55
+ onDirectory(await realpath(absolute));
56
+ for await (const file of glob('**/{i18n,*.i18n}.json', {
57
+ cwd: absolute,
58
+ exclude: ['**/node_modules/**', '**/ide_node_modules/**', '**/.git/**'],
59
+ })) {
60
+ const fullPath = path.resolve(absolute, file);
61
+ const relative = path.relative(root, fullPath).split(path.sep).join('/');
62
+ if (excludes.some(exclude => path.matchesGlob(relative, exclude))) continue;
63
+ files.add(await realpath(fullPath));
64
+ }
65
+ }
66
+ }
67
+
68
+ const sortedFiles = [...files].sort();
69
+ const perLanguage = new Map();
70
+ const fingerprints = new Map();
71
+ const ids = new Map();
72
+ for (const file of sortedFiles) {
73
+ const id = computeId(file, root);
74
+ if (ids.has(id)) throw new Error(`i18n ID collision: ${file} and ${ids.get(id)}`);
75
+ ids.set(id, file);
76
+ const content = await readFile(file, 'utf8');
77
+ const json = parseFeature(content, file);
78
+ fingerprints.set(file, createHash('sha256').update(content).digest('hex'));
79
+ for (const [language, messages] of Object.entries(json)) {
80
+ if (!perLanguage.has(language)) perLanguage.set(language, Object.create(null));
81
+ perLanguage.get(language)[id] = messages;
82
+ }
83
+ }
84
+ return { files: sortedFiles, perLanguage, fingerprints };
85
+ }
86
+
87
+ function isRecord(value) {
88
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
89
+ }
90
+
91
+ module.exports = { resolveRoot, computeId, parseFeature, resolveOutputDir, collectDictionaries };
@@ -0,0 +1,17 @@
1
+ import type { NamedExoticComponent } from 'react';
2
+ import type { createReactBindings } from './react.js';
3
+ import type { I18nStore } from './store-types.js';
4
+ import type { CheckedDictionary, DefaultI18nOptions, DictionaryInput, DictionaryKeys, RegisteredFallbackLanguage, RemovePrefix, SupportedLanguage, TypoHook, TypoProps } from './types.js';
5
+ export interface DictionaryReactBindings<L extends string, F extends string = never> {
6
+ createUseTypo<const D extends DictionaryInput>(info: CheckedDictionary<D, L, F>): TypoHook<DictionaryKeys<D>>;
7
+ createTypo<const D extends DictionaryInput>(info: CheckedDictionary<D, L, F>): NamedExoticComponent<TypoProps<DictionaryKeys<D>>>;
8
+ createTypo<const D extends DictionaryInput, P extends string>(info: CheckedDictionary<D, L, F>, prefix: P): NamedExoticComponent<TypoProps<RemovePrefix<DictionaryKeys<D>, P>>>;
9
+ useTypoAsObject<const D extends DictionaryInput>(info: CheckedDictionary<D, L, F>): Record<DictionaryKeys<D>, string | undefined>;
10
+ }
11
+ export type ReactBindings<L extends string, F extends string = never> = Omit<ReturnType<typeof createReactBindings<L>>, keyof DictionaryReactBindings<L, F>> & DictionaryReactBindings<L, F>;
12
+ export type I18n<L extends string, F extends string = never> = I18nStore<L, F> & ReactBindings<L, F>;
13
+ export interface DefaultConfiguration {
14
+ configure<const L extends SupportedLanguage>(options: DefaultI18nOptions<L>): void;
15
+ }
16
+ export type DefaultI18n = I18n<SupportedLanguage, RegisteredFallbackLanguage> & DefaultConfiguration;
17
+ //# sourceMappingURL=api-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-types.d.ts","sourceRoot":"","sources":["../../src/api-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,0BAA0B,EAC1B,YAAY,EACZ,iBAAiB,EACjB,QAAQ,EACR,SAAS,EACV,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,uBAAuB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,GAAG,KAAK;IACjF,aAAa,CAAC,KAAK,CAAC,CAAC,SAAS,eAAe,EAAE,IAAI,EAAE,iBAAiB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9G,UAAU,CAAC,KAAK,CAAC,CAAC,SAAS,eAAe,EACxC,IAAI,EAAE,iBAAiB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAC/B,oBAAoB,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACtD,UAAU,CAAC,KAAK,CAAC,CAAC,SAAS,eAAe,EAAE,CAAC,SAAS,MAAM,EAC1D,IAAI,EAAE,iBAAiB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAChC,MAAM,EAAE,CAAC,GACR,oBAAoB,CAAC,SAAS,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACvE,eAAe,CAAC,KAAK,CAAC,CAAC,SAAS,eAAe,EAC7C,IAAI,EAAE,iBAAiB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAC/B,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;CAClD;AAED,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,GAAG,KAAK,IAAI,IAAI,CAC1E,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAAC,CAAC,EACzC,MAAM,uBAAuB,CAAC,CAAC,EAAE,CAAC,CAAC,CACpC,GACC,uBAAuB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAEhC,MAAM,MAAM,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,GAAG,KAAK,IAAI,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAErG,MAAM,WAAW,oBAAoB;IACnC,SAAS,CAAC,KAAK,CAAC,CAAC,SAAS,iBAAiB,EAAE,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;CACpF;AAED,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,iBAAiB,EAAE,0BAA0B,CAAC,GAAG,oBAAoB,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=api-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-types.js","sourceRoot":"","sources":["../../src/api-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ import type { I18nStore } from './store-types.js';
2
+ import type { FetchDictionaryOptions, I18nOptions, LanguageDictionary } from './types.js';
3
+ export { interpolateTypo } from './interpolation.js';
4
+ export type { I18nStore } from './store-types.js';
5
+ export type * from './types.js';
6
+ /** Creates a React-independent store whose dictionary APIs check the configured languages. */
7
+ export declare function createI18nStore<const L extends string>(options: I18nOptions<L>): I18nStore<L>;
8
+ /** HTTP loader for the language files emitted by I18nCollectPlugin. */
9
+ export declare function createFetchDictionaryLoader(options?: FetchDictionaryOptions): (language: string) => Promise<LanguageDictionary>;
10
+ //# sourceMappingURL=core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,sBAAsB,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAE1F,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,YAAY,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,mBAAmB,YAAY,CAAC;AAEhC,8FAA8F;AAC9F,wBAAgB,eAAe,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAE7F;AAED,uEAAuE;AACvE,wBAAgB,2BAA2B,CAAC,OAAO,GAAE,sBAA2B,IAEhE,UAAU,MAAM,KAAG,OAAO,CAAC,kBAAkB,CAAC,CAU7D"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.interpolateTypo = void 0;
4
+ exports.createI18nStore = createI18nStore;
5
+ exports.createFetchDictionaryLoader = createFetchDictionaryLoader;
6
+ const dictionaries_js_1 = require("./dictionaries.js");
7
+ const store_js_1 = require("./store.js");
8
+ const store_types_js_1 = require("./store-types.js");
9
+ var interpolation_js_1 = require("./interpolation.js");
10
+ Object.defineProperty(exports, "interpolateTypo", { enumerable: true, get: function () { return interpolation_js_1.interpolateTypo; } });
11
+ /** Creates a React-independent store whose dictionary APIs check the configured languages. */
12
+ function createI18nStore(options) {
13
+ return (0, store_types_js_1.withDictionaryTypes)((0, store_js_1.createI18nStore)(options));
14
+ }
15
+ /** HTTP loader for the language files emitted by I18nCollectPlugin. */
16
+ function createFetchDictionaryLoader(options = {}) {
17
+ const baseUrl = (options.baseUrl ?? 'i18n').replace(/\/+$/, '');
18
+ return async (language) => {
19
+ const fetcher = options.fetch ?? globalThis.fetch;
20
+ if (!fetcher)
21
+ throw new Error('No fetch implementation available; provide options.fetch');
22
+ const url = `${baseUrl}/${encodeURIComponent(language)}.json`;
23
+ const response = await fetcher(url, options.requestInit);
24
+ if (!response.ok)
25
+ throw new Error(`Failed to load ${url}: HTTP ${response.status} ${response.statusText}`);
26
+ const dictionary = await response.json();
27
+ (0, dictionaries_js_1.validateLanguageDictionary)(dictionary);
28
+ return dictionary;
29
+ };
30
+ }
31
+ //# sourceMappingURL=core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":";;;AAWA,0CAEC;AAGD,kEAYC;AA5BD,uDAA+D;AAC/D,yCAA4D;AAC5D,qDAAuD;AAIvD,uDAAqD;AAA5C,mHAAA,eAAe,OAAA;AAIxB,8FAA8F;AAC9F,SAAgB,eAAe,CAAyB,OAAuB;IAC7E,OAAO,IAAA,oCAAmB,EAAC,IAAA,0BAAW,EAAC,OAAO,CAAC,CAAC,CAAC;AACnD,CAAC;AAED,uEAAuE;AACvE,SAAgB,2BAA2B,CAAC,UAAkC,EAAE;IAC9E,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAChE,OAAO,KAAK,EAAE,QAAgB,EAA+B,EAAE;QAC7D,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC;QAClD,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;QAC1F,MAAM,GAAG,GAAG,GAAG,OAAO,IAAI,kBAAkB,CAAC,QAAQ,CAAC,OAAO,CAAC;QAC9D,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;QACzD,IAAI,CAAC,QAAQ,CAAC,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,GAAG,UAAU,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;QAC3G,MAAM,UAAU,GAAY,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAClD,IAAA,4CAA0B,EAAC,UAAU,CAAC,CAAC;QACvC,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { I18nStore } from './store.js';
2
+ import type { DefaultI18nOptions, SupportedLanguage } from './types.js';
3
+ /** Stable delegates let module-scope feature factories work before configuration. */
4
+ export declare function createDefaultI18nStore(): I18nStore<string> & {
5
+ configure: <const L extends SupportedLanguage>(options: DefaultI18nOptions<L>) => void;
6
+ };
7
+ //# sourceMappingURL=default-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-store.d.ts","sourceRoot":"","sources":["../../src/default-store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAGV,kBAAkB,EAKlB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAEpB,qFAAqF;AACrF,wBAAgB,sBAAsB;sBA2EX,CAAC,SAAS,iBAAiB,WAAW,kBAAkB,CAAC,CAAC,CAAC,KAAG,IAAI;EAgB5F"}