@hua-labs/i18n-core 2.1.0 → 2.2.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 +9 -3
- package/dist/chunk-4IYWT7MS.mjs +1104 -0
- package/dist/chunk-4IYWT7MS.mjs.map +1 -0
- package/dist/index.cjs +2086 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +22 -22
- package/dist/index.d.ts +249 -0
- package/dist/index.mjs +373 -264
- package/dist/index.mjs.map +1 -1
- package/dist/{server-4TeBq6hp.d.mts → server-CQztOmd-.d.mts} +48 -11
- package/dist/server-CQztOmd-.d.ts +404 -0
- package/dist/{chunk-EZL5TNH5.mjs → server.cjs} +148 -46
- package/dist/server.cjs.map +1 -0
- package/dist/server.d.mts +1 -1
- package/dist/server.d.ts +1 -0
- package/dist/server.mjs +1 -1
- package/package.json +16 -13
- package/src/__tests__/default-value.test.ts +149 -0
- package/src/components/MissingKeyOverlay.tsx +6 -4
- package/src/core/translator.tsx +392 -195
- package/src/hooks/useI18n.tsx +511 -367
- package/src/index.ts +5 -2
- package/src/types/index.ts +341 -156
- package/dist/chunk-EZL5TNH5.mjs.map +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-present HUA Labs
|
|
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,10 +1,10 @@
|
|
|
1
1
|
# @hua-labs/i18n-core
|
|
2
2
|
|
|
3
|
-
Lightweight, production-ready i18n library for React. Delivers zero-flicker language transitions through intelligent caching, SSR-first hydration handling, and built-in state management integration. ~
|
|
3
|
+
Lightweight, production-ready i18n library for React. Delivers zero-flicker language transitions through intelligent caching, SSR-first hydration handling, and built-in state management integration. ~7KB gzipped with zero dependencies (React only).
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@hua-labs/i18n-core)
|
|
6
6
|
[](https://www.npmjs.com/package/@hua-labs/i18n-core)
|
|
7
|
-
[](https://github.com/HUA-Labs/
|
|
7
|
+
[](https://github.com/HUA-Labs/hua-packages/blob/main/LICENSE)
|
|
8
8
|
[](https://www.typescriptlang.org/)
|
|
9
9
|
[](https://reactjs.org/)
|
|
10
10
|
|
|
@@ -17,7 +17,10 @@ Lightweight, production-ready i18n library for React. Delivers zero-flicker lang
|
|
|
17
17
|
- **Type-safe arrays — tArray() returns string[] without casting**
|
|
18
18
|
- **State management — First-class Zustand support via i18n-core-zustand**
|
|
19
19
|
- **Automatic retry — Exponential backoff for API loader failures**
|
|
20
|
-
-
|
|
20
|
+
- **React Native — Works in Expo and bare RN projects via CJS/ESM dual format**
|
|
21
|
+
- **~7KB gzipped — Zero external dependencies**
|
|
22
|
+
- **Cross-platform — I18nPlatformAdapter for Web, React Native, Flutter bridge**
|
|
23
|
+
- **Generic getRawValue<T>() — type-safe raw value access without casting**
|
|
21
24
|
|
|
22
25
|
## Installation
|
|
23
26
|
|
|
@@ -65,6 +68,8 @@ function Welcome() {
|
|
|
65
68
|
| `Translator` | class | Core translator class (for manual instantiation) |
|
|
66
69
|
| `ssrTranslate` | function | Server-side translation function (no React needed) |
|
|
67
70
|
| `serverTranslate` | function | Server-side translate with full config |
|
|
71
|
+
| `webPlatformAdapter` | adapter | Default web adapter — navigator.language detection + window event language sync |
|
|
72
|
+
| `headlessPlatformAdapter` | adapter | No-op adapter for SSR, testing, and Flutter bridge scenarios |
|
|
68
73
|
| `I18nConfig` | type | |
|
|
69
74
|
| `I18nContextType` | type | |
|
|
70
75
|
| `TranslationParams` | type | |
|
|
@@ -74,6 +79,7 @@ function Welcome() {
|
|
|
74
79
|
| `ResolvePluralKey` | type | |
|
|
75
80
|
| `PluralValue` | type | |
|
|
76
81
|
| `PluralCategory` | type | |
|
|
82
|
+
| `I18nPlatformAdapter` | interface | Platform adapter interface — implement for React Native or custom environments |
|
|
77
83
|
| `createCoreI18n` | function | Create an i18n Provider component with configuration |
|
|
78
84
|
| `CoreProvider` | function | Minimal Provider with zero config |
|
|
79
85
|
| `createLanguageProvider` | function | Create a Provider with just a language setting |
|