kotori 3.0.0 → 3.0.1
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 +17 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ npm i kotori
|
|
|
61
61
|
**utils.ts**
|
|
62
62
|
|
|
63
63
|
```ts
|
|
64
|
-
import { kotori } from '
|
|
64
|
+
import { kotori } from 'kotori'
|
|
65
65
|
|
|
66
66
|
export const { useT, dict, setLanguage } = kotori({
|
|
67
67
|
primaryLanguageTag: 'en',
|
|
@@ -166,16 +166,29 @@ export const Page2 = () => {
|
|
|
166
166
|
|
|
167
167
|
Creates a scoped i18n instance.
|
|
168
168
|
|
|
169
|
+
```ts
|
|
170
|
+
import { kotori } from 'kotori'
|
|
171
|
+
|
|
172
|
+
export const { useT, dict, setLanguage } = kotori({
|
|
173
|
+
primaryLanguageTag: 'en',
|
|
174
|
+
secondaryLanguageTags: ['zh', 'ja', 'ms'],
|
|
175
|
+
})
|
|
176
|
+
```
|
|
177
|
+
|
|
169
178
|
| option | type | description |
|
|
170
179
|
| --- | --- | --- |
|
|
171
|
-
| `primaryLanguageTag` | `
|
|
172
|
-
| `secondaryLanguageTags` | `
|
|
180
|
+
| `primaryLanguageTag` | `BCP47LanguageTag` | The source language. Drives variable inference. |
|
|
181
|
+
| `secondaryLanguageTags` | `BCP47LanguageTag[]` | Additional supported languages. |
|
|
173
182
|
|
|
174
183
|
Returns `{ dict, useT, setLanguage }`.
|
|
175
184
|
|
|
176
185
|
### `dict(translations)<argsType?>`
|
|
177
186
|
|
|
178
|
-
Defines a translation unit. Takes one string per language.
|
|
187
|
+
Defines a translation unit. Takes one string per language.
|
|
188
|
+
|
|
189
|
+
```ts
|
|
190
|
+
const time = dict({ en: '{{hour}}:{{minute}}' })
|
|
191
|
+
```
|
|
179
192
|
|
|
180
193
|
By default, variables are typed as `string | number`. Pass a generic to narrow them:
|
|
181
194
|
|
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": "3.0.
|
|
4
|
+
"version": "3.0.1",
|
|
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",
|