kotori 0.0.9 → 0.0.11

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 +20 -11
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -8,27 +8,36 @@ 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 'name'
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
25
33
  - No JSON
26
34
  - No dependencies
35
+ - No build step
27
36
  - 0.39kb gzipped
28
37
  - Modular and tree-shakeable
29
38
  - Language change in one page rerenders all pages
30
- - Variables typed and inferred from string literals
31
39
  - Translation keys are typed — no more string typos
40
+ - Variables typed and inferred from string literals
32
41
 
33
42
  ## Installation
34
43
 
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "kotori",
3
3
  "description": "Strongly-typed and composable internationalization library for React",
4
- "version": "0.0.9",
4
+ "version": "0.0.11",
5
5
  "scripts": {
6
6
  "setup": "rm -rf node_modules && npm i && git init && husky",
7
- "prepublishOnly": "npm run build",
7
+ "prepublishOnly": "npm i && npx tsc && npm run build",
8
8
  "build": "tsdown",
9
9
  "test": "vitest",
10
10
  "lint": "npx @biomejs/biome check --write",