kotori 5.0.9 → 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.
- package/README.md +12 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -200,14 +200,26 @@ const time = dict({ en: '{{hour}}:{{minute}}' })<{
|
|
|
200
200
|
|
|
201
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.).
|
|
202
202
|
|
|
203
|
+
```ts
|
|
204
|
+
setLanguage('zh')
|
|
205
|
+
```
|
|
206
|
+
|
|
203
207
|
### `t(dict, args?)`
|
|
204
208
|
|
|
205
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.
|
|
206
210
|
|
|
211
|
+
```tsx
|
|
212
|
+
<p>{t(intro, { name: 'John', age: 30 })}</p>
|
|
213
|
+
```
|
|
214
|
+
|
|
207
215
|
### `useT()`
|
|
208
216
|
|
|
209
217
|
React hook. Returns the current language tag as a reactive value. Updates when `setLanguage` is called.
|
|
210
218
|
|
|
219
|
+
```ts
|
|
220
|
+
const language = useT()
|
|
221
|
+
```
|
|
222
|
+
|
|
211
223
|
## Language Tags
|
|
212
224
|
|
|
213
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
3
|
"description": "0.28kB Strongly-typed and tree-shakeable internationalization library for React",
|
|
4
|
-
"version": "5.0.
|
|
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",
|