kotori 5.0.9 → 5.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 +16 -3
  2. package/package.json +3 -1
package/README.md CHANGED
@@ -3,10 +3,11 @@
3
3
  </p>
4
4
 
5
5
  <p align="center">
6
- <a href="https://www.npmjs.com/package/kotori"><img src="https://img.shields.io/npm/v/kotori?color=crimson" alt="NPM Version"></a>
7
- <img src="https://img.shields.io/badge/dependencies-0-success" alt="Dependencies">
8
- <a href="https://github.com/tylim88/Kotori/blob/main/LICENSE"><img src="https://img.shields.io/github/license/tylim88/Kotori?color=blue" alt="License"></a>
6
+ <a href="https://www.npmjs.com/package/kotori"><img src="https://img.shields.io/npm/v/kotori?color=blue" alt="NPM Version"></a>
7
+ <a href="https://codecov.io/gh/tylim88/Kotori"><img src="https://img.shields.io/codecov/c/github/tylim88/Kotori?branch=main" alt="Coverage"></a>
9
8
  <img src="https://img.shields.io/badge/bundle%20size-0.28kB-emerald" alt="Bundle Size">
9
+ <a href="https://github.com/tylim88/Kotori/blob/main/LICENSE"><img src="https://img.shields.io/github/license/tylim88/Kotori?color=blue" alt="License"></a>
10
+ <img src="https://img.shields.io/badge/dependencies-0-success" alt="Dependencies">
10
11
  </p>
11
12
 
12
13
  <p align="center">
@@ -200,14 +201,26 @@ const time = dict({ en: '{{hour}}:{{minute}}' })<{
200
201
 
201
202
  Updates the current language and rerenders all active `useT` consumers across all pages. Available directly on the `kotori` instance — useful for calling outside of React (route guards, axios interceptors, etc.).
202
203
 
204
+ ```ts
205
+ setLanguage('zh')
206
+ ```
207
+
203
208
  ### `t(dict, args?)`
204
209
 
205
210
  Returns the translated string for the current language. `args` is required if the string has variables, omitted if it doesn't. Available directly on the `kotori` instance for non-React usage.
206
211
 
212
+ ```tsx
213
+ <p>{t(intro, { name: 'John', age: 30 })}</p>
214
+ ```
215
+
207
216
  ### `useT()`
208
217
 
209
218
  React hook. Returns the current language tag as a reactive value. Updates when `setLanguage` is called.
210
219
 
220
+ ```ts
221
+ const language = useT()
222
+ ```
223
+
211
224
  ## Language Tags
212
225
 
213
226
  kotori uses [BCP 47](https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry) language tags. Both subtags (`en`, `zh`) and full tags (`en-US`, `zh-CN`) are accepted and validated at the type level.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "kotori",
3
3
  "description": "0.28kB Strongly-typed and tree-shakeable internationalization library for React",
4
- "version": "5.0.9",
4
+ "version": "5.0.11",
5
5
  "scripts": {
6
6
  "setup": "rm -rf node_modules && npm i && git init && husky",
7
7
  "prepublishOnly": "npm i && npx tsc && npm run build",
@@ -45,11 +45,13 @@
45
45
  ],
46
46
  "devDependencies": {
47
47
  "@biomejs/biome": "^2.4.12",
48
+ "@testing-library/react": "^16.3.2",
48
49
  "@types/react": "^19.2.14",
49
50
  "@types/react-dom": "^19.2.3",
50
51
  "@vitejs/plugin-react": "^6.0.1",
51
52
  "@vitest/coverage-v8": "^4.1.5",
52
53
  "bcp47-language-tags": "^1.1.0",
54
+ "happy-dom": "^20.9.0",
53
55
  "husky": "^9.1.7",
54
56
  "lint-staged": "^16.4.0",
55
57
  "react": "^19.2.5",