kotori 5.0.7 → 5.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 +22 -1
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -2,7 +2,16 @@
2
2
  <img src="logo.webp" alt="kotori i18n logo">
3
3
  </p>
4
4
 
5
- Strongly-typed, modular i18n for React. Variables are inferred directly from your strings — no codegen, no JSON, no schema files.
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>
9
+ <img src="https://img.shields.io/badge/bundle%20size-0.28kB-emerald" alt="Bundle Size">
10
+ </p>
11
+
12
+ <p align="center">
13
+ 🕊️ Kotori is a zero-config, fully type-safe, and modular internationalization library for React that compiles down to just 0.28kB. No JSON, no external CLI tools, no codegen—just live type inference from your strings.
14
+ </p>
6
15
 
7
16
  ```ts
8
17
  const { dict, t } = kotori({
@@ -191,14 +200,26 @@ const time = dict({ en: '{{hour}}:{{minute}}' })<{
191
200
 
192
201
  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.).
193
202
 
203
+ ```ts
204
+ setLanguage('zh')
205
+ ```
206
+
194
207
  ### `t(dict, args?)`
195
208
 
196
209
  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.
197
210
 
211
+ ```tsx
212
+ <p>{t(intro, { name: 'John', age: 30 })}</p>
213
+ ```
214
+
198
215
  ### `useT()`
199
216
 
200
217
  React hook. Returns the current language tag as a reactive value. Updates when `setLanguage` is called.
201
218
 
219
+ ```ts
220
+ const language = useT()
221
+ ```
222
+
202
223
  ## Language Tags
203
224
 
204
225
  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
- "description": "Strongly-typed and composable internationalization library for React",
4
- "version": "5.0.7",
3
+ "description": "0.28kB Strongly-typed and tree-shakeable internationalization library for React",
4
+ "version": "5.0.10",
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",