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.
Files changed (2) hide show
  1. package/README.md +18 -10
  2. 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
- // ❌ compile error: missing japanese translation
11
+ // ❌ TypeScript error: missing japanese translation
12
12
  const intro = dict({
13
- en: 'Hello {{name}}, is it {{time}} now?', // base string drives the type contract
14
- zh: '你好,现在是 {{time}} 吗?', // compile error: missing key 'nam'
15
- ms: 'Hai {{nam}}, adakah pukul {{time}} sekarang?' // ❌ compile error: unknown key 'nam'
16
- })<{name: string; time: `${number}:${number}`}> // optional: type your arguments, by default it's `Record<'name'|'time', string>` in this example
17
-
18
- t('intro', { name: 'John', time: '12:25' }) // ✅
19
- t('intro', { time: '12:25' }) // compile error: missing { name }
20
- t('intro', { nama: 'John', time: '12:25' }) // ❌ compile error: unknown key 'nama'
21
- t('intro', { name: 'John', time: '12-00' }) // ❌ compile error: invalid format for 'time'
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.8",
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",