@flightdev/i18n 0.1.5 → 0.2.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 +17 -17
- package/package.json +77 -71
- package/LICENSE +0 -21
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @flightdev/i18n
|
|
2
2
|
|
|
3
3
|
Internationalization for Flight Framework. Supports multiple translation libraries with a unified API, automatic locale detection, and SSR-friendly design.
|
|
4
4
|
|
|
@@ -38,7 +38,7 @@ Internationalization for Flight Framework. Supports multiple translation librari
|
|
|
38
38
|
## Installation
|
|
39
39
|
|
|
40
40
|
```bash
|
|
41
|
-
npm install @
|
|
41
|
+
npm install @flightdev/i18n
|
|
42
42
|
|
|
43
43
|
# Install your preferred adapter:
|
|
44
44
|
npm install i18next # Most popular, feature-rich
|
|
@@ -55,8 +55,8 @@ npm install @lingui/core # Compile-time extraction
|
|
|
55
55
|
|
|
56
56
|
```typescript
|
|
57
57
|
// src/i18n.ts
|
|
58
|
-
import { createI18n } from '@
|
|
59
|
-
import { i18next } from '@
|
|
58
|
+
import { createI18n } from '@flightdev/i18n';
|
|
59
|
+
import { i18next } from '@flightdev/i18n/i18next';
|
|
60
60
|
|
|
61
61
|
export const i18n = createI18n(i18next({
|
|
62
62
|
locales: ['en', 'es', 'fr', 'de'],
|
|
@@ -119,7 +119,7 @@ i18n.t('welcome'); // "Bienvenido a nuestra app"
|
|
|
119
119
|
The most popular option with extensive features.
|
|
120
120
|
|
|
121
121
|
```typescript
|
|
122
|
-
import { i18next } from '@
|
|
122
|
+
import { i18next } from '@flightdev/i18n/i18next';
|
|
123
123
|
|
|
124
124
|
const adapter = i18next({
|
|
125
125
|
locales: ['en', 'es', 'fr'],
|
|
@@ -143,7 +143,7 @@ const adapter = i18next({
|
|
|
143
143
|
Compile-time translations for the smallest bundle size.
|
|
144
144
|
|
|
145
145
|
```typescript
|
|
146
|
-
import { paraglide } from '@
|
|
146
|
+
import { paraglide } from '@flightdev/i18n/paraglide';
|
|
147
147
|
import * as messages from './paraglide/messages';
|
|
148
148
|
|
|
149
149
|
const adapter = paraglide({
|
|
@@ -158,7 +158,7 @@ const adapter = paraglide({
|
|
|
158
158
|
ICU message format with powerful formatting.
|
|
159
159
|
|
|
160
160
|
```typescript
|
|
161
|
-
import { formatjs } from '@
|
|
161
|
+
import { formatjs } from '@flightdev/i18n/formatjs';
|
|
162
162
|
|
|
163
163
|
const adapter = formatjs({
|
|
164
164
|
locales: ['en', 'es'],
|
|
@@ -175,7 +175,7 @@ const adapter = formatjs({
|
|
|
175
175
|
Compile-time extraction with excellent developer experience.
|
|
176
176
|
|
|
177
177
|
```typescript
|
|
178
|
-
import { lingui } from '@
|
|
178
|
+
import { lingui } from '@flightdev/i18n/lingui';
|
|
179
179
|
import { messages as enMessages } from './locales/en/messages';
|
|
180
180
|
import { messages as esMessages } from './locales/es/messages';
|
|
181
181
|
|
|
@@ -196,7 +196,7 @@ const adapter = lingui({
|
|
|
196
196
|
Automatic detection from multiple sources:
|
|
197
197
|
|
|
198
198
|
```typescript
|
|
199
|
-
import { createI18n, detectLocale } from '@
|
|
199
|
+
import { createI18n, detectLocale } from '@flightdev/i18n';
|
|
200
200
|
|
|
201
201
|
const i18n = createI18n(adapter, {
|
|
202
202
|
detection: {
|
|
@@ -218,7 +218,7 @@ const i18n = createI18n(adapter, {
|
|
|
218
218
|
### Server-Side Detection
|
|
219
219
|
|
|
220
220
|
```typescript
|
|
221
|
-
import { getLocaleFromRequest } from '@
|
|
221
|
+
import { getLocaleFromRequest } from '@flightdev/i18n';
|
|
222
222
|
|
|
223
223
|
export async function loader({ request }) {
|
|
224
224
|
const locale = getLocaleFromRequest(request, {
|
|
@@ -234,7 +234,7 @@ export async function loader({ request }) {
|
|
|
234
234
|
|
|
235
235
|
```typescript
|
|
236
236
|
// Routes: /en/about, /es/about, /fr/about
|
|
237
|
-
import { createLocaleRouter } from '@
|
|
237
|
+
import { createLocaleRouter } from '@flightdev/i18n';
|
|
238
238
|
|
|
239
239
|
const router = createLocaleRouter({
|
|
240
240
|
locales: ['en', 'es', 'fr'],
|
|
@@ -250,7 +250,7 @@ const router = createLocaleRouter({
|
|
|
250
250
|
### React
|
|
251
251
|
|
|
252
252
|
```tsx
|
|
253
|
-
import { I18nProvider, useTranslation, Trans } from '@
|
|
253
|
+
import { I18nProvider, useTranslation, Trans } from '@flightdev/i18n/react';
|
|
254
254
|
|
|
255
255
|
function App() {
|
|
256
256
|
return (
|
|
@@ -292,7 +292,7 @@ function Content() {
|
|
|
292
292
|
|
|
293
293
|
```vue
|
|
294
294
|
<script setup>
|
|
295
|
-
import { useI18n } from '@
|
|
295
|
+
import { useI18n } from '@flightdev/i18n/vue';
|
|
296
296
|
|
|
297
297
|
const { t, locale, setLocale, locales } = useI18n();
|
|
298
298
|
</script>
|
|
@@ -313,7 +313,7 @@ const { t, locale, setLocale, locales } = useI18n();
|
|
|
313
313
|
|
|
314
314
|
```svelte
|
|
315
315
|
<script>
|
|
316
|
-
import { getI18n } from '@
|
|
316
|
+
import { getI18n } from '@flightdev/i18n/svelte';
|
|
317
317
|
|
|
318
318
|
const { t, locale, setLocale, locales } = getI18n();
|
|
319
319
|
</script>
|
|
@@ -331,7 +331,7 @@ const { t, locale, setLocale, locales } = useI18n();
|
|
|
331
331
|
### Solid
|
|
332
332
|
|
|
333
333
|
```tsx
|
|
334
|
-
import { useI18n, Trans } from '@
|
|
334
|
+
import { useI18n, Trans } from '@flightdev/i18n/solid';
|
|
335
335
|
|
|
336
336
|
function Content() {
|
|
337
337
|
const { t, locale, setLocale, locales } = useI18n();
|
|
@@ -365,7 +365,7 @@ import {
|
|
|
365
365
|
formatTime,
|
|
366
366
|
formatRelativeTime,
|
|
367
367
|
formatList,
|
|
368
|
-
} from '@
|
|
368
|
+
} from '@flightdev/i18n';
|
|
369
369
|
|
|
370
370
|
// Numbers
|
|
371
371
|
formatNumber(1234567.89, 'en-US'); // "1,234,567.89"
|
|
@@ -604,7 +604,7 @@ hydrateRoot(
|
|
|
604
604
|
Implement the `I18nAdapter` interface:
|
|
605
605
|
|
|
606
606
|
```typescript
|
|
607
|
-
import type { I18nAdapter } from '@
|
|
607
|
+
import type { I18nAdapter } from '@flightdev/i18n';
|
|
608
608
|
|
|
609
609
|
export function myAdapter(config: MyConfig): I18nAdapter {
|
|
610
610
|
return {
|
package/package.json
CHANGED
|
@@ -1,72 +1,78 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@flightdev/i18n",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Agnostic internationalization for Flight Framework. Choose your engine: i18next, Paraglide, FormatJS, Lingui, or custom.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./i18next": {
|
|
12
|
+
"types": "./dist/adapters/i18next.d.ts",
|
|
13
|
+
"import": "./dist/adapters/i18next.js"
|
|
14
|
+
},
|
|
15
|
+
"./paraglide": {
|
|
16
|
+
"types": "./dist/adapters/paraglide.d.ts",
|
|
17
|
+
"import": "./dist/adapters/paraglide.js"
|
|
18
|
+
},
|
|
19
|
+
"./formatjs": {
|
|
20
|
+
"types": "./dist/adapters/formatjs.d.ts",
|
|
21
|
+
"import": "./dist/adapters/formatjs.js"
|
|
22
|
+
},
|
|
23
|
+
"./lingui": {
|
|
24
|
+
"types": "./dist/adapters/lingui.d.ts",
|
|
25
|
+
"import": "./dist/adapters/lingui.js"
|
|
26
|
+
},
|
|
27
|
+
"./routing": {
|
|
28
|
+
"types": "./dist/routing.d.ts",
|
|
29
|
+
"import": "./dist/routing.js"
|
|
30
|
+
},
|
|
31
|
+
"./middleware": {
|
|
32
|
+
"types": "./dist/middleware.d.ts",
|
|
33
|
+
"import": "./dist/middleware.js"
|
|
34
|
+
},
|
|
35
|
+
"./typegen": {
|
|
36
|
+
"types": "./dist/typegen.d.ts",
|
|
37
|
+
"import": "./dist/typegen.js"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"files": [
|
|
41
|
+
"dist"
|
|
42
|
+
],
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsup",
|
|
45
|
+
"dev": "tsup --watch",
|
|
46
|
+
"test": "vitest run",
|
|
47
|
+
"typecheck": "tsc --noEmit"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"@formatjs/intl": "\u003e=2.0.0",
|
|
51
|
+
"@lingui/core": "\u003e=5.0.0",
|
|
52
|
+
"i18next": "\u003e=23.0.0"
|
|
53
|
+
},
|
|
54
|
+
"peerDependenciesMeta": {
|
|
55
|
+
"@formatjs/intl": {
|
|
56
|
+
"optional": true
|
|
57
|
+
},
|
|
58
|
+
"@lingui/core": {
|
|
59
|
+
"optional": true
|
|
60
|
+
},
|
|
61
|
+
"i18next": {
|
|
62
|
+
"optional": true
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"@types/node": "^22.0.0",
|
|
67
|
+
"tsup": "^8.0.0",
|
|
68
|
+
"typescript": "^5.7.0",
|
|
69
|
+
"vitest": "^2.0.0"
|
|
70
|
+
},
|
|
71
|
+
"license": "MIT",
|
|
72
|
+
"homepage": "https://github.com/EliosLT/FlightDev",
|
|
73
|
+
"repository": {
|
|
74
|
+
"url": "https://github.com/EliosLT/FlightDev.git",
|
|
75
|
+
"directory": "packages/i18n",
|
|
76
|
+
"type": "git"
|
|
77
|
+
}
|
|
72
78
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024-2026 Flight Contributors
|
|
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.
|