kotori 6.1.2 → 6.1.3

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 CHANGED
@@ -61,7 +61,7 @@ const Component = () => {
61
61
  - Variables typed and inferred from string literals — no more string typos
62
62
  - Maximum type safety with minimum types
63
63
 
64
- Demo: <https://stackblitz.com/edit/kotori?file=src%2FApp.tsx>
64
+ Demo: <https://github.com/tylim88/kotori-demo>
65
65
 
66
66
  ## Installation
67
67
 
@@ -81,7 +81,7 @@ export const { useT, d, setLanguage } = kotori({
81
81
  secondaries: ['zh', 'ja', 'ms'],
82
82
  })
83
83
 
84
- // you can define your dicts in the same file or separate them by component, it's up to you
84
+ // you can define your dicts in the same file/folder or separate them by component, it's up to you
85
85
  export const intro = d({
86
86
  en: 'my name is {{name}}, I am {{age}} years old.',
87
87
  zh: '我叫{{name}},我今年{{age}}岁了。',
@@ -248,9 +248,16 @@ Detects the user's preferred language from browser settings and sets it on the k
248
248
 
249
249
  ```ts
250
250
  import { detectLanguage } from 'kotori'
251
- import { i18n } from './locales'
251
+ import { kotori } from 'kotori'
252
+
253
+ const i18n = kotori({
254
+ primary: 'en',
255
+ secondaries: ['zh', 'ja', 'ms'],
256
+ })
252
257
 
253
258
  detectLanguage(i18n)
259
+
260
+ export const { useT, d, setLanguage } = i18n
254
261
  ```
255
262
 
256
263
  | option | type | default | description |
@@ -289,7 +296,8 @@ kotori({ primary: 'klingon', secondaries: ['zh'] }) // ❌ compile error
289
296
  ## Tips
290
297
 
291
298
  - If you plan to add new languages frequently, consider colocating all your dicts in a single file or multiple files in one folder. It is easier to copy the entire files and hand it to an AI to translate.
292
- - If your supported languages are fixed, consider splitting dicts by page or component. Translations stay close to the code that uses them and are easier to maintain.
299
+ - If your supported languages are fixed, consider splitting dicts by page or component. This keeps translations close to the code that uses them and makes them easier to maintain.
300
+ - For large or rarely used components, you can also reduce your bundle size by dynamically importing them only when they are needed on the page.
293
301
 
294
302
  ## Roadmap
295
303
 
package/dist/index.cjs CHANGED
@@ -35,6 +35,8 @@ let react = require("react");
35
35
  *
36
36
  * detectLanguage(i18n, { fallbackToSubtag: false })
37
37
  * // browser: ['zh-CN'] → no exact match → no-op, stays 'en'
38
+ *
39
+ * export const { useT, d, setLanguage } = i18n
38
40
  * ```
39
41
  *
40
42
  * @example
package/dist/index.d.cts CHANGED
@@ -208,6 +208,8 @@ declare const kotori: <const Primary extends BCP47LanguageTagNameWithSubTag, con
208
208
  *
209
209
  * detectLanguage(i18n, { fallbackToSubtag: false })
210
210
  * // browser: ['zh-CN'] → no exact match → no-op, stays 'en'
211
+ *
212
+ * export const { useT, d, setLanguage } = i18n
211
213
  * ```
212
214
  *
213
215
  * @example
package/dist/index.d.mts CHANGED
@@ -208,6 +208,8 @@ declare const kotori: <const Primary extends BCP47LanguageTagNameWithSubTag, con
208
208
  *
209
209
  * detectLanguage(i18n, { fallbackToSubtag: false })
210
210
  * // browser: ['zh-CN'] → no exact match → no-op, stays 'en'
211
+ *
212
+ * export const { useT, d, setLanguage } = i18n
211
213
  * ```
212
214
  *
213
215
  * @example
package/dist/index.mjs CHANGED
@@ -34,6 +34,8 @@ import { useSyncExternalStore } from "react";
34
34
  *
35
35
  * detectLanguage(i18n, { fallbackToSubtag: false })
36
36
  * // browser: ['zh-CN'] → no exact match → no-op, stays 'en'
37
+ *
38
+ * export const { useT, d, setLanguage } = i18n
37
39
  * ```
38
40
  *
39
41
  * @example
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "kotori",
3
3
  "description": "0.29kB Strongly-typed and tree-shakeable internationalization library for React",
4
- "version": "6.1.2",
4
+ "version": "6.1.3",
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",