@fukict/i18n 0.1.0 → 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.
- package/README.md +606 -0
- package/dist/I18n.d.ts +1 -1
- package/dist/I18n.d.ts.map +1 -1
- package/dist/I18n.js +6 -6
- package/dist/I18n.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/metadata.d.ts +1 -1
- package/dist/metadata.js +1 -1
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,606 @@
|
|
|
1
|
+
# @fukict/i18n
|
|
2
|
+
|
|
3
|
+
Type-safe internationalization library for Fukict framework with reactive language switching.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Type-Safe**: Full TypeScript support with autocomplete for translation keys
|
|
8
|
+
- **Reactive**: Automatic component updates on language change
|
|
9
|
+
- **Nested Keys**: Support for deeply nested translation objects
|
|
10
|
+
- **Interpolation**: Variable substitution in translations
|
|
11
|
+
- **Pluralization**: Built-in plural form support
|
|
12
|
+
- **Fallback**: Automatic fallback to default language
|
|
13
|
+
- **Lightweight**: Minimal overhead with zero dependencies
|
|
14
|
+
- **Dynamic Loading**: Lazy load translations for code splitting
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pnpm add @fukict/i18n
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
### Define Translations
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
// locales/en.ts
|
|
28
|
+
export default {
|
|
29
|
+
common: {
|
|
30
|
+
welcome: 'Welcome',
|
|
31
|
+
hello: 'Hello {name}!',
|
|
32
|
+
logout: 'Logout',
|
|
33
|
+
},
|
|
34
|
+
user: {
|
|
35
|
+
profile: 'User Profile',
|
|
36
|
+
settings: 'Settings',
|
|
37
|
+
},
|
|
38
|
+
validation: {
|
|
39
|
+
required: 'This field is required',
|
|
40
|
+
email: 'Invalid email address',
|
|
41
|
+
},
|
|
42
|
+
} as const;
|
|
43
|
+
|
|
44
|
+
// locales/zh.ts
|
|
45
|
+
export default {
|
|
46
|
+
common: {
|
|
47
|
+
welcome: '欢迎',
|
|
48
|
+
hello: '你好 {name}!',
|
|
49
|
+
logout: '退出登录',
|
|
50
|
+
},
|
|
51
|
+
user: {
|
|
52
|
+
profile: '用户资料',
|
|
53
|
+
settings: '设置',
|
|
54
|
+
},
|
|
55
|
+
validation: {
|
|
56
|
+
required: '此字段为必填项',
|
|
57
|
+
email: '邮箱地址无效',
|
|
58
|
+
},
|
|
59
|
+
} as const;
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Create i18n Instance
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import { createI18n } from '@fukict/i18n';
|
|
66
|
+
|
|
67
|
+
import en from './locales/en';
|
|
68
|
+
import zh from './locales/zh';
|
|
69
|
+
|
|
70
|
+
const i18n = createI18n({
|
|
71
|
+
locale: 'en',
|
|
72
|
+
fallbackLocale: 'en',
|
|
73
|
+
messages: {
|
|
74
|
+
en,
|
|
75
|
+
zh,
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
export default i18n;
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Use in Components
|
|
83
|
+
|
|
84
|
+
```tsx
|
|
85
|
+
import { Fukict } from '@fukict/basic';
|
|
86
|
+
|
|
87
|
+
import i18n from './i18n';
|
|
88
|
+
|
|
89
|
+
class Greeting extends Fukict {
|
|
90
|
+
private unsubscribe?: () => void;
|
|
91
|
+
|
|
92
|
+
mounted() {
|
|
93
|
+
// Subscribe to language changes
|
|
94
|
+
this.unsubscribe = i18n.subscribe(() => {
|
|
95
|
+
this.update(this.props);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
beforeUnmount() {
|
|
100
|
+
this.unsubscribe?.();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
render() {
|
|
104
|
+
return (
|
|
105
|
+
<div>
|
|
106
|
+
<h1>{i18n.t('common.welcome')}</h1>
|
|
107
|
+
<p>{i18n.t('common.hello', { name: 'World' })}</p>
|
|
108
|
+
<button on:click={() => i18n.setLocale('zh')}>中文</button>
|
|
109
|
+
<button on:click={() => i18n.setLocale('en')}>English</button>
|
|
110
|
+
</div>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Core API
|
|
117
|
+
|
|
118
|
+
### createI18n(options)
|
|
119
|
+
|
|
120
|
+
Creates i18n instance with configuration.
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
import { createI18n } from '@fukict/i18n';
|
|
124
|
+
|
|
125
|
+
const i18n = createI18n({
|
|
126
|
+
locale: 'en', // Current locale
|
|
127
|
+
fallbackLocale: 'en', // Fallback locale
|
|
128
|
+
messages: {
|
|
129
|
+
en: enMessages,
|
|
130
|
+
zh: zhMessages,
|
|
131
|
+
ja: jaMessages,
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### i18n.t(key, values?)
|
|
137
|
+
|
|
138
|
+
Translates a key with optional interpolation values.
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
// Simple translation
|
|
142
|
+
i18n.t('common.welcome'); // "Welcome"
|
|
143
|
+
|
|
144
|
+
// With interpolation
|
|
145
|
+
i18n.t('common.hello', { name: 'Alice' }); // "Hello Alice!"
|
|
146
|
+
|
|
147
|
+
// Nested keys
|
|
148
|
+
i18n.t('user.profile'); // "User Profile"
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### i18n.setLocale(locale)
|
|
152
|
+
|
|
153
|
+
Changes current locale and notifies subscribers.
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
i18n.setLocale('zh'); // Switch to Chinese
|
|
157
|
+
i18n.setLocale('en'); // Switch to English
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### i18n.getLocale()
|
|
161
|
+
|
|
162
|
+
Returns current locale.
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
const currentLocale = i18n.getLocale(); // "en"
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### i18n.subscribe(listener)
|
|
169
|
+
|
|
170
|
+
Subscribes to locale changes.
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
const unsubscribe = i18n.subscribe(() => {
|
|
174
|
+
console.log('Locale changed to:', i18n.getLocale());
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
// Clean up
|
|
178
|
+
unsubscribe();
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Translation Features
|
|
182
|
+
|
|
183
|
+
### Nested Keys
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
const messages = {
|
|
187
|
+
pages: {
|
|
188
|
+
home: {
|
|
189
|
+
title: 'Home Page',
|
|
190
|
+
subtitle: 'Welcome to our site',
|
|
191
|
+
actions: {
|
|
192
|
+
login: 'Login',
|
|
193
|
+
signup: 'Sign Up',
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// Access nested keys with dot notation
|
|
200
|
+
i18n.t('pages.home.title'); // "Home Page"
|
|
201
|
+
i18n.t('pages.home.actions.login'); // "Login"
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Interpolation
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
const messages = {
|
|
208
|
+
greeting: 'Hello {name}, you have {count} messages',
|
|
209
|
+
profile: 'User {user} from {country}',
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
i18n.t('greeting', { name: 'Alice', count: 5 });
|
|
213
|
+
// "Hello Alice, you have 5 messages"
|
|
214
|
+
|
|
215
|
+
i18n.t('profile', { user: 'Bob', country: 'USA' });
|
|
216
|
+
// "User Bob from USA"
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Pluralization
|
|
220
|
+
|
|
221
|
+
```typescript
|
|
222
|
+
const messages = {
|
|
223
|
+
items: {
|
|
224
|
+
zero: 'No items',
|
|
225
|
+
one: 'One item',
|
|
226
|
+
other: '{count} items',
|
|
227
|
+
},
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
// Use plural helper (if implemented)
|
|
231
|
+
i18n.t('items', { count: 0 }); // "No items"
|
|
232
|
+
i18n.t('items', { count: 1 }); // "One item"
|
|
233
|
+
i18n.t('items', { count: 5 }); // "5 items"
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Fallback
|
|
237
|
+
|
|
238
|
+
```typescript
|
|
239
|
+
const i18n = createI18n({
|
|
240
|
+
locale: 'fr',
|
|
241
|
+
fallbackLocale: 'en',
|
|
242
|
+
messages: {
|
|
243
|
+
en: {
|
|
244
|
+
greeting: 'Hello',
|
|
245
|
+
goodbye: 'Goodbye',
|
|
246
|
+
},
|
|
247
|
+
fr: {
|
|
248
|
+
greeting: 'Bonjour',
|
|
249
|
+
// 'goodbye' missing in French
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
i18n.t('greeting'); // "Bonjour" (from French)
|
|
255
|
+
i18n.t('goodbye'); // "Goodbye" (fallback to English)
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## Advanced Usage
|
|
259
|
+
|
|
260
|
+
### Language Switcher Component
|
|
261
|
+
|
|
262
|
+
```tsx
|
|
263
|
+
class LanguageSwitcher extends Fukict {
|
|
264
|
+
private unsubscribe?: () => void;
|
|
265
|
+
private languages = [
|
|
266
|
+
{ code: 'en', name: 'English' },
|
|
267
|
+
{ code: 'zh', name: '中文' },
|
|
268
|
+
{ code: 'ja', name: '日本語' },
|
|
269
|
+
];
|
|
270
|
+
|
|
271
|
+
mounted() {
|
|
272
|
+
this.unsubscribe = i18n.subscribe(() => {
|
|
273
|
+
this.update(this.props);
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
beforeUnmount() {
|
|
278
|
+
this.unsubscribe?.();
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
render() {
|
|
282
|
+
const currentLocale = i18n.getLocale();
|
|
283
|
+
|
|
284
|
+
return (
|
|
285
|
+
<div class="language-switcher">
|
|
286
|
+
{this.languages.map(lang => (
|
|
287
|
+
<button
|
|
288
|
+
key={lang.code}
|
|
289
|
+
class={currentLocale === lang.code ? 'active' : ''}
|
|
290
|
+
on:click={() => i18n.setLocale(lang.code)}
|
|
291
|
+
>
|
|
292
|
+
{lang.name}
|
|
293
|
+
</button>
|
|
294
|
+
))}
|
|
295
|
+
</div>
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### Dynamic Translation Loading
|
|
302
|
+
|
|
303
|
+
```typescript
|
|
304
|
+
// Lazy load translation files
|
|
305
|
+
const loadLocale = async (locale: string) => {
|
|
306
|
+
const messages = await import(`./locales/${locale}.js`);
|
|
307
|
+
i18n.setMessages(locale, messages.default);
|
|
308
|
+
i18n.setLocale(locale);
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
// Usage in component
|
|
312
|
+
class App extends Fukict {
|
|
313
|
+
changeLanguage = async (locale: string) => {
|
|
314
|
+
await loadLocale(locale);
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
render() {
|
|
318
|
+
return (
|
|
319
|
+
<button on:click={() => this.changeLanguage('zh')}>
|
|
320
|
+
Load Chinese
|
|
321
|
+
</button>
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### Type-Safe Translation Keys
|
|
328
|
+
|
|
329
|
+
```typescript
|
|
330
|
+
// i18n.ts with typed keys
|
|
331
|
+
import type { TranslationKeys } from './locales/en';
|
|
332
|
+
|
|
333
|
+
// locales/en.ts
|
|
334
|
+
const en = {
|
|
335
|
+
common: {
|
|
336
|
+
welcome: 'Welcome',
|
|
337
|
+
hello: 'Hello {name}',
|
|
338
|
+
},
|
|
339
|
+
user: {
|
|
340
|
+
profile: 'Profile',
|
|
341
|
+
},
|
|
342
|
+
} as const;
|
|
343
|
+
|
|
344
|
+
export type TranslationKeys = typeof en;
|
|
345
|
+
export default en;
|
|
346
|
+
|
|
347
|
+
const i18n = createI18n<TranslationKeys>({
|
|
348
|
+
locale: 'en',
|
|
349
|
+
fallbackLocale: 'en',
|
|
350
|
+
messages: {
|
|
351
|
+
en,
|
|
352
|
+
zh,
|
|
353
|
+
},
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
// Now get autocomplete for keys!
|
|
357
|
+
i18n.t('common.welcome'); // ✅ Autocomplete works
|
|
358
|
+
i18n.t('invalid.key'); // ❌ TypeScript error
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### Formatting Utilities
|
|
362
|
+
|
|
363
|
+
```typescript
|
|
364
|
+
// Date formatting
|
|
365
|
+
const formatDate = (date: Date, locale: string) => {
|
|
366
|
+
return new Intl.DateTimeFormat(locale).format(date);
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
// Number formatting
|
|
370
|
+
const formatNumber = (num: number, locale: string) => {
|
|
371
|
+
return new Intl.NumberFormat(locale).format(num);
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
// Currency formatting
|
|
375
|
+
const formatCurrency = (amount: number, locale: string, currency: string) => {
|
|
376
|
+
return new Intl.NumberFormat(locale, {
|
|
377
|
+
style: 'currency',
|
|
378
|
+
currency,
|
|
379
|
+
}).format(amount);
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
// Usage in component
|
|
383
|
+
class Invoice extends Fukict {
|
|
384
|
+
render() {
|
|
385
|
+
const locale = i18n.getLocale();
|
|
386
|
+
const date = new Date();
|
|
387
|
+
const total = 1234.56;
|
|
388
|
+
|
|
389
|
+
return (
|
|
390
|
+
<div>
|
|
391
|
+
<p>Date: {formatDate(date, locale)}</p>
|
|
392
|
+
<p>Total: {formatCurrency(total, locale, 'USD')}</p>
|
|
393
|
+
</div>
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
### Integration with Router
|
|
400
|
+
|
|
401
|
+
```tsx
|
|
402
|
+
import { RouteComponent } from '@fukict/router';
|
|
403
|
+
|
|
404
|
+
import i18n from './i18n';
|
|
405
|
+
|
|
406
|
+
class LocalizedPage extends RouteComponent {
|
|
407
|
+
private unsubscribeI18n?: () => void;
|
|
408
|
+
|
|
409
|
+
mounted() {
|
|
410
|
+
// Subscribe to both router and i18n
|
|
411
|
+
this.unsubscribeI18n = i18n.subscribe(() => {
|
|
412
|
+
this.update(this.props);
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
// Get locale from URL query
|
|
416
|
+
const { lang } = this.query;
|
|
417
|
+
if (lang) {
|
|
418
|
+
i18n.setLocale(lang);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
beforeUnmount() {
|
|
423
|
+
this.unsubscribeI18n?.();
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
changeLang = (locale: string) => {
|
|
427
|
+
i18n.setLocale(locale);
|
|
428
|
+
// Update URL with new locale
|
|
429
|
+
this.updateQuery({ lang: locale });
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
render() {
|
|
433
|
+
return (
|
|
434
|
+
<div>
|
|
435
|
+
<h1>{i18n.t('pages.home.title')}</h1>
|
|
436
|
+
<button on:click={() => this.changeLang('en')}>EN</button>
|
|
437
|
+
<button on:click={() => this.changeLang('zh')}>中文</button>
|
|
438
|
+
</div>
|
|
439
|
+
);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
## Best Practices
|
|
445
|
+
|
|
446
|
+
### 1. Organize Translations by Feature
|
|
447
|
+
|
|
448
|
+
```typescript
|
|
449
|
+
// ✅ Good: Feature-based structure
|
|
450
|
+
const messages = {
|
|
451
|
+
auth: {
|
|
452
|
+
login: 'Login',
|
|
453
|
+
logout: 'Logout',
|
|
454
|
+
register: 'Register',
|
|
455
|
+
},
|
|
456
|
+
products: {
|
|
457
|
+
list: 'Product List',
|
|
458
|
+
detail: 'Product Detail',
|
|
459
|
+
addToCart: 'Add to Cart',
|
|
460
|
+
},
|
|
461
|
+
cart: {
|
|
462
|
+
title: 'Shopping Cart',
|
|
463
|
+
empty: 'Your cart is empty',
|
|
464
|
+
},
|
|
465
|
+
};
|
|
466
|
+
|
|
467
|
+
// ❌ Bad: Flat structure
|
|
468
|
+
const messages = {
|
|
469
|
+
login: 'Login',
|
|
470
|
+
logout: 'Logout',
|
|
471
|
+
productList: 'Product List',
|
|
472
|
+
cartTitle: 'Shopping Cart',
|
|
473
|
+
};
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
### 2. Subscribe at App Level
|
|
477
|
+
|
|
478
|
+
```tsx
|
|
479
|
+
// ✅ Good: Subscribe at root, read in children
|
|
480
|
+
class App extends Fukict {
|
|
481
|
+
private unsubscribe?: () => void;
|
|
482
|
+
|
|
483
|
+
mounted() {
|
|
484
|
+
this.unsubscribe = i18n.subscribe(() => {
|
|
485
|
+
this.update(this.props);
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
beforeUnmount() {
|
|
490
|
+
this.unsubscribe?.();
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
render() {
|
|
494
|
+
return (
|
|
495
|
+
<div>
|
|
496
|
+
<Header /> {/* Just reads i18n.t() */}
|
|
497
|
+
<Content /> {/* Just reads i18n.t() */}
|
|
498
|
+
</div>
|
|
499
|
+
);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
### 3. Use const assertions
|
|
505
|
+
|
|
506
|
+
```typescript
|
|
507
|
+
// ✅ Good: Use 'as const' for type inference
|
|
508
|
+
export default {
|
|
509
|
+
greeting: 'Hello',
|
|
510
|
+
farewell: 'Goodbye',
|
|
511
|
+
} as const;
|
|
512
|
+
|
|
513
|
+
// ❌ Bad: No type inference
|
|
514
|
+
export default {
|
|
515
|
+
greeting: 'Hello',
|
|
516
|
+
farewell: 'Goodbye',
|
|
517
|
+
};
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
### 4. Keep Translations Consistent
|
|
521
|
+
|
|
522
|
+
```typescript
|
|
523
|
+
// ✅ Good: Same structure across locales
|
|
524
|
+
// en.ts
|
|
525
|
+
const en = {
|
|
526
|
+
user: {
|
|
527
|
+
profile: 'Profile',
|
|
528
|
+
settings: 'Settings',
|
|
529
|
+
},
|
|
530
|
+
};
|
|
531
|
+
|
|
532
|
+
// zh.ts
|
|
533
|
+
const zh = {
|
|
534
|
+
user: {
|
|
535
|
+
profile: '资料',
|
|
536
|
+
settings: '设置',
|
|
537
|
+
},
|
|
538
|
+
};
|
|
539
|
+
|
|
540
|
+
// ❌ Bad: Inconsistent structure
|
|
541
|
+
// zh.ts - Missing keys!
|
|
542
|
+
const zh = {
|
|
543
|
+
user: {
|
|
544
|
+
profile: '资料',
|
|
545
|
+
// settings missing!
|
|
546
|
+
},
|
|
547
|
+
};
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
## Examples
|
|
551
|
+
|
|
552
|
+
### Simple Example
|
|
553
|
+
|
|
554
|
+
```tsx
|
|
555
|
+
import { Fukict, attach } from '@fukict/basic';
|
|
556
|
+
import { createI18n } from '@fukict/i18n';
|
|
557
|
+
|
|
558
|
+
const i18n = createI18n({
|
|
559
|
+
locale: 'en',
|
|
560
|
+
messages: {
|
|
561
|
+
en: {
|
|
562
|
+
title: 'Hello World',
|
|
563
|
+
greeting: 'Welcome {name}!',
|
|
564
|
+
},
|
|
565
|
+
zh: {
|
|
566
|
+
title: '你好世界',
|
|
567
|
+
greeting: '欢迎 {name}!',
|
|
568
|
+
},
|
|
569
|
+
},
|
|
570
|
+
});
|
|
571
|
+
|
|
572
|
+
class App extends Fukict {
|
|
573
|
+
private unsubscribe?: () => void;
|
|
574
|
+
|
|
575
|
+
mounted() {
|
|
576
|
+
this.unsubscribe = i18n.subscribe(() => this.update(this.props));
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
beforeUnmount() {
|
|
580
|
+
this.unsubscribe?.();
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
render() {
|
|
584
|
+
return (
|
|
585
|
+
<div>
|
|
586
|
+
<h1>{i18n.t('title')}</h1>
|
|
587
|
+
<p>{i18n.t('greeting', { name: 'User' })}</p>
|
|
588
|
+
<button on:click={() => i18n.setLocale('en')}>EN</button>
|
|
589
|
+
<button on:click={() => i18n.setLocale('zh')}>中文</button>
|
|
590
|
+
</div>
|
|
591
|
+
);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
attach(<App />, document.getElementById('app')!);
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
## Related Packages
|
|
599
|
+
|
|
600
|
+
- [@fukict/basic](../basic) - Core rendering engine
|
|
601
|
+
- [@fukict/router](../router) - SPA routing
|
|
602
|
+
- [@fukict/flux](../flux) - State management
|
|
603
|
+
|
|
604
|
+
## License
|
|
605
|
+
|
|
606
|
+
MIT
|
package/dist/I18n.d.ts
CHANGED
|
@@ -47,7 +47,7 @@ export declare class I18n<Messages extends Record<string, any>> implements I18nI
|
|
|
47
47
|
/**
|
|
48
48
|
* Translate text
|
|
49
49
|
*/
|
|
50
|
-
t(key: string, params?: Record<string, string | number>)
|
|
50
|
+
t: (key: string, params?: Record<string, string | number>) => string;
|
|
51
51
|
/**
|
|
52
52
|
* Internal translate function
|
|
53
53
|
*/
|
package/dist/I18n.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"I18n.d.ts","sourceRoot":"","sources":["../src/I18n.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK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HANGED
|
@@ -51,7 +51,7 @@ export class I18n {
|
|
|
51
51
|
/**
|
|
52
52
|
* Translate text
|
|
53
53
|
*/
|
|
54
|
-
t(key, params) {
|
|
54
|
+
t = (key, params) => {
|
|
55
55
|
// Check cache
|
|
56
56
|
const cacheKey = `${this.currentLocale}:${key}:${JSON.stringify(params || {})}`;
|
|
57
57
|
if (this.translationCache.has(cacheKey)) {
|
|
@@ -62,11 +62,11 @@ export class I18n {
|
|
|
62
62
|
// Cache result
|
|
63
63
|
this.translationCache.set(cacheKey, result);
|
|
64
64
|
return result;
|
|
65
|
-
}
|
|
65
|
+
};
|
|
66
66
|
/**
|
|
67
67
|
* Internal translate function
|
|
68
68
|
*/
|
|
69
|
-
translate(key, params) {
|
|
69
|
+
translate = (key, params) => {
|
|
70
70
|
// Try current locale
|
|
71
71
|
let text = this.getTextByKey(key, this.currentLocale);
|
|
72
72
|
// Try fallback locale
|
|
@@ -86,11 +86,11 @@ export class I18n {
|
|
|
86
86
|
text = this.interpolate(text, params);
|
|
87
87
|
}
|
|
88
88
|
return text;
|
|
89
|
-
}
|
|
89
|
+
};
|
|
90
90
|
/**
|
|
91
91
|
* Get text by key from locale
|
|
92
92
|
*/
|
|
93
|
-
getTextByKey(key, locale) {
|
|
93
|
+
getTextByKey = (key, locale) => {
|
|
94
94
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
95
95
|
const messages = this.messages[locale];
|
|
96
96
|
if (!messages)
|
|
@@ -110,7 +110,7 @@ export class I18n {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
return current;
|
|
113
|
-
}
|
|
113
|
+
};
|
|
114
114
|
/**
|
|
115
115
|
* Get plural form based on count
|
|
116
116
|
*/
|
package/dist/I18n.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"I18n.js","sourceRoot":"","sources":["../src/I18n.ts"],"names":[],"mappings":"AAYA;;GAEG;AACH,MAAM,OAAO,IAAI;IAGf;;OA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;OAEG;IACH,WAAW;QACT,+DAA+D;QAC/D,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,mBAAmB;QACjB,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,MAAc,EAAE,QAAkC;QAC5D,IAAI,CAAC,QAAQ,GAAG;YACd,GAAG,IAAI,CAAC,QAAQ;YAChB,CAAC,MAAM,CAAC,EAAE,QAAQ;SACP,CAAC;QACd,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAED;;OAEG;IACH,CAAC,CAAC,KAAa,EAAE,OAAkC;QACjD,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1E,CAAC;IAED;;OAEG;IACH,CAAC,CAAC,KAAoB,EAAE,OAAoC;QAC1D,OAAO,IAAI,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5E,CAAC;IAED;;OAEG;IACH,EAAE,CAAC,KAAa,EAAE,IAAiC;QACjD,OAAO,IAAI,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC7E,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { METADATA } from './metadata.js';
|
|
7
7
|
export { METADATA };
|
|
8
|
-
export declare const VERSION: "0.1.
|
|
8
|
+
export declare const VERSION: "0.1.1";
|
|
9
9
|
export { I18n } from './I18n';
|
|
10
10
|
export { createI18n } from './createI18n';
|
|
11
11
|
export type { I18nInstance, I18nListener, I18nOptions, KeyPath, TranslationKey, Unsubscribe, } from './types';
|
package/dist/metadata.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export declare const METADATA: {
|
|
6
6
|
readonly name: "@fukict/i18n";
|
|
7
|
-
readonly version: "0.1.
|
|
7
|
+
readonly version: "0.1.1";
|
|
8
8
|
readonly description: "Type-safe internationalization library for Fukict framework";
|
|
9
9
|
readonly author: "Fukict Team";
|
|
10
10
|
readonly license: "MIT";
|
package/dist/metadata.js
CHANGED