@flightdev/i18n 0.1.5 → 0.1.6
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 +7 -1
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flightdev/i18n",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Agnostic internationalization for Flight Framework. Choose your engine: i18next, Paraglide, FormatJS, Lingui, or custom.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -63,6 +63,12 @@
|
|
|
63
63
|
"vitest": "^2.0.0"
|
|
64
64
|
},
|
|
65
65
|
"license": "MIT",
|
|
66
|
+
"homepage": "https://github.com/EliosLT/FlightDev",
|
|
67
|
+
"repository": {
|
|
68
|
+
"url": "https://github.com/EliosLT/FlightDev.git",
|
|
69
|
+
"directory": "packages/i18n",
|
|
70
|
+
"type": "git"
|
|
71
|
+
},
|
|
66
72
|
"scripts": {
|
|
67
73
|
"build": "tsup",
|
|
68
74
|
"dev": "tsup --watch",
|