kotori 0.0.8 → 0.0.10
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 +18 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,17 +8,25 @@ const { dict } = kotori({
|
|
|
8
8
|
secondaryLanguageTags: ['zh', 'ja', 'ms'],
|
|
9
9
|
})
|
|
10
10
|
|
|
11
|
-
// ❌
|
|
11
|
+
// ❌ TypeScript error: missing japanese translation
|
|
12
12
|
const intro = dict({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
// ⭐ base string drives the type contract
|
|
14
|
+
en: 'Hello {{name}}, is it {{time}} now?',
|
|
15
|
+
// ❌ TypeScript error: missing key 'name'
|
|
16
|
+
zh: '你好,现在是 {{time}} 吗?',
|
|
17
|
+
// ❌ TypeScript error: unknown key 'nam'
|
|
18
|
+
ms: 'Hai {{nam}}, adakah pukul {{time}} sekarang?'
|
|
19
|
+
// optional: type your arguments, by default it's `Record<'name'|'time', string>` in this example
|
|
20
|
+
})<{name: string; time: `${number}:${number}`}>
|
|
21
|
+
|
|
22
|
+
// ✅ Works
|
|
23
|
+
t('intro', { name: 'John', time: '12:25' })
|
|
24
|
+
// ❌ TypeScript error: missing { name }
|
|
25
|
+
t('intro', { time: '12:25' })
|
|
26
|
+
// ❌ TypeScript error: unknown key 'nama'
|
|
27
|
+
t('intro', { nama: 'John', time: '12:25' })
|
|
28
|
+
// ❌ TypeScript error: invalid format for 'time'
|
|
29
|
+
t('intro', { name: 'John', time: '12-00' })
|
|
22
30
|
```
|
|
23
31
|
|
|
24
32
|
- No codegen
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kotori",
|
|
3
3
|
"description": "Strongly-typed and composable internationalization library for React",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.10",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"setup": "rm -rf node_modules && npm i && git init && husky",
|
|
7
7
|
"prepublishOnly": "npm run build",
|