kotori 6.1.3 → 6.1.4
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 +6 -3
- package/dist/index.cjs +3 -7
- package/dist/index.mjs +3 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,10 +8,13 @@
|
|
|
8
8
|
<img src="https://img.shields.io/badge/bundle%20size-0.28kB-emerald" alt="Bundle Size">
|
|
9
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
10
|
<img src="https://img.shields.io/badge/dependencies-0-success" alt="Dependencies">
|
|
11
|
+
<a href="https://snyk.io/test/github/tylim88/Kotori">
|
|
12
|
+
<img src="https://snyk.io/test/github/tylim88/Kotori/badge.svg" alt="Snyk Vulnerabilities for npm package">
|
|
13
|
+
</a>
|
|
11
14
|
</p>
|
|
12
15
|
|
|
13
16
|
<p align="center">
|
|
14
|
-
🕊️ Kotori is a zero-config, fully type-safe, and modular internationalization library for React that compiles down to just 0.
|
|
17
|
+
🕊️ 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.
|
|
15
18
|
</p>
|
|
16
19
|
|
|
17
20
|
```ts
|
|
@@ -55,7 +58,7 @@ const Component = () => {
|
|
|
55
58
|
- No JSON
|
|
56
59
|
- No dependencies
|
|
57
60
|
- No build step
|
|
58
|
-
- 0.
|
|
61
|
+
- 0.28kB minified and gzipped
|
|
59
62
|
- Modular and tree-shakeable
|
|
60
63
|
- Language change in one page rerenders all pages
|
|
61
64
|
- Variables typed and inferred from string literals — no more string typos
|
|
@@ -163,7 +166,7 @@ export const Page2 = () => {
|
|
|
163
166
|
|
|
164
167
|

|
|
165
168
|
|
|
166
|
-
### `kotori(options)` (0.
|
|
169
|
+
### `kotori(options)` (0.28kB)
|
|
167
170
|
|
|
168
171
|
Creates a scoped i18n instance.
|
|
169
172
|
|
package/dist/index.cjs
CHANGED
|
@@ -112,7 +112,7 @@ const kotori = (config) => {
|
|
|
112
112
|
* )
|
|
113
113
|
* }
|
|
114
114
|
*/
|
|
115
|
-
const t = (dictionary, ...args) => (dictionary().d[snapshot.language]
|
|
115
|
+
const t = (dictionary, ...args) => (dictionary().d[snapshot.language] + "").replace(/\{\{\s*([\w-]+)\s*\}\}/g, (_, key) => args[0]?.[key] + "");
|
|
116
116
|
let snapshot = {
|
|
117
117
|
language: config.primary,
|
|
118
118
|
t
|
|
@@ -147,15 +147,11 @@ const kotori = (config) => {
|
|
|
147
147
|
language,
|
|
148
148
|
t: (...args) => t(...args)
|
|
149
149
|
};
|
|
150
|
-
listeners.forEach((listener) =>
|
|
151
|
-
listener();
|
|
152
|
-
});
|
|
150
|
+
listeners.forEach((listener) => listener());
|
|
153
151
|
};
|
|
154
152
|
const subscribe = (listener) => {
|
|
155
153
|
listeners.add(listener);
|
|
156
|
-
return () =>
|
|
157
|
-
listeners.delete(listener);
|
|
158
|
-
};
|
|
154
|
+
return () => listeners.delete(listener);
|
|
159
155
|
};
|
|
160
156
|
return {
|
|
161
157
|
config,
|
package/dist/index.mjs
CHANGED
|
@@ -111,7 +111,7 @@ const kotori = (config) => {
|
|
|
111
111
|
* )
|
|
112
112
|
* }
|
|
113
113
|
*/
|
|
114
|
-
const t = (dictionary, ...args) => (dictionary().d[snapshot.language]
|
|
114
|
+
const t = (dictionary, ...args) => (dictionary().d[snapshot.language] + "").replace(/\{\{\s*([\w-]+)\s*\}\}/g, (_, key) => args[0]?.[key] + "");
|
|
115
115
|
let snapshot = {
|
|
116
116
|
language: config.primary,
|
|
117
117
|
t
|
|
@@ -146,15 +146,11 @@ const kotori = (config) => {
|
|
|
146
146
|
language,
|
|
147
147
|
t: (...args) => t(...args)
|
|
148
148
|
};
|
|
149
|
-
listeners.forEach((listener) =>
|
|
150
|
-
listener();
|
|
151
|
-
});
|
|
149
|
+
listeners.forEach((listener) => listener());
|
|
152
150
|
};
|
|
153
151
|
const subscribe = (listener) => {
|
|
154
152
|
listeners.add(listener);
|
|
155
|
-
return () =>
|
|
156
|
-
listeners.delete(listener);
|
|
157
|
-
};
|
|
153
|
+
return () => listeners.delete(listener);
|
|
158
154
|
};
|
|
159
155
|
return {
|
|
160
156
|
config,
|
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.
|
|
4
|
+
"version": "6.1.4",
|
|
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",
|