react-intlayer 2.0.11 → 2.0.12

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 +67 -9
  2. package/package.json +26 -16
package/README.md CHANGED
@@ -1,25 +1,64 @@
1
1
  <div align="center">
2
- <a href="https://www.npmjs.com/package/intlayer">
2
+ <a href="https://www.npmjs.com/package/react-intlayer">
3
3
  <img src="docs/assets/logo.png" width="500" alt="intlayer" />
4
4
  </a>
5
5
  </div>
6
6
 
7
7
  <div align="center">
8
- <a href="https://www.npmjs.com/package/intlayer">
9
- <img alt="npm" src="https://img.shields.io/npm/v/intlayer.svg?labelColor=49516F&color=8994BC" />
8
+ <a href="https://www.npmjs.com/package/react-intlayer">
9
+ <img alt="npm" src="https://img.shields.io/npm/v/react-intlayer.svg?labelColor=49516F&color=8994BC" />
10
10
  </a>
11
- <a href="https://npmjs.org/package/intlayer">
12
- <img alt="downloads" src="https://badgen.net/npm/dm/intlayer?labelColor=49516F&color=8994BC" />
11
+ <a href="https://npmjs.org/package/react-intlayer">
12
+ <img alt="downloads" src="https://badgen.net/npm/dm/react-intlayer?labelColor=49516F&color=8994BC" />
13
13
  </a>
14
- <a href="https://npmjs.org/package/intlayer">
15
- <img alt="types included" src="https://badgen.net/npm/types/intlayer?labelColor=49516F&color=8994BC"
14
+ <a href="https://npmjs.org/package/react-intlayer">
15
+ <img alt="types included" src="https://badgen.net/npm/types/react-intlayer?labelColor=49516F&color=8994BC"
16
16
  />
17
17
  </a>
18
18
  </div>
19
19
 
20
20
  # Intlayer: Next-Level Content Management in JavaScript
21
21
 
22
- **Intlayer** is an innovative Content Management System (CMS) designed specifically for JavaScript developers. It enables seamless transpilation of JavaScript content into structured dictionaries, making integration into your codebase straightforward and efficient.
22
+ **Intlayer** is an internationalization library designed specifically for JavaScript developers. It allow the declaration of your content everywhere in your code. It converts declaration of multilingual content into structured dictionaries to integrate easily in your code. Using TypeScript, **Intlayer** make your development stronger and more efficient.
23
+
24
+ ## Example of usage
25
+
26
+ ```bash
27
+ .
28
+ ├── Component1
29
+ │   ├── index.content.ts
30
+ │   └── index.tsx
31
+ └── Component2
32
+    ├── index.tsx
33
+    └── index.content.ts
34
+ ```
35
+
36
+ ```tsx
37
+ // ./Component1/index.content.ts
38
+
39
+ import { DeclarationContent, t } from "intlayer";
40
+
41
+ const component1Content: DeclarationContent = {
42
+ id: "component1",
43
+ myTranslatedContent: t({
44
+ en: "Hello World",
45
+ fr: "Bonjour le monde",
46
+ es: "Hola Mundo",
47
+ }),
48
+ };
49
+ ```
50
+
51
+ ```tsx
52
+ // ./Component1/index.tsx
53
+
54
+ import { useIntlayer } from "react-intlayer";
55
+
56
+ export const Component1 = () => {
57
+ const { myTranslatedContent } = useIntlayer("component1");
58
+
59
+ return <span>{myTranslatedContent}</span>;
60
+ };
61
+ ```
23
62
 
24
63
  ## Why Choose Intlayer?
25
64
 
@@ -137,7 +176,7 @@ export default appContent;
137
176
 
138
177
  [See how to declare your Intlayer declaration files](https://github.com/aypineau/intlayer/blob/main/docs/docs/content_declaration/get_started_en.md).
139
178
 
140
- ### Step 5: Utilize Intlayer in Your Code
179
+ ## Step 5: Utilize Intlayer in Your Code
141
180
 
142
181
  Access your content dictionaries throughout your application:
143
182
 
@@ -190,6 +229,25 @@ export default App;
190
229
  > <img src={content.image.src.value} alt={content.image.value} />
191
230
  > ```
192
231
 
232
+ ## (Optional) Step 6: Change the language of your content
233
+
234
+ To change the language of your content, you can use the `setLocale` function provided by the `useLocale` hook. This function allows you to set the locale of the application and update the content accordingly.
235
+
236
+ ```tsx
237
+ import { Locales } from "intlayer";
238
+ import { useLocale } from "react-intlayer";
239
+
240
+ const MyComponent = () => {
241
+ const { setLocale } = useLocale();
242
+
243
+ return (
244
+ <button onClick={() => setLocale(Locales.English)}>
245
+ Change Language to English
246
+ </button>
247
+ );
248
+ };
249
+ ```
250
+
193
251
  ## Configure TypeScript
194
252
 
195
253
  Intlayer use module augmentation to get benefits of TypeScript and make your codebase stronger.
package/package.json CHANGED
@@ -1,31 +1,39 @@
1
1
  {
2
2
  "name": "react-intlayer",
3
- "version": "2.0.11",
3
+ "version": "2.0.12",
4
4
  "private": false,
5
- "description": "Internationalization layer for React applications - Layer of abstraction between the business logic and the data access layer. Manage internationalization in a simple way, through TypeScript, JavaScript or JSON declaration file.",
5
+ "description": "Internationalization layer for React applications. Declare your multilingual contant in the same lever than your component. Powered by TypeScript, declaration files.",
6
6
  "keywords": [
7
7
  "intlayer",
8
- "layer",
9
- "abstraction",
10
8
  "data",
11
9
  "internationalization",
10
+ "multilingual",
12
11
  "i18n",
13
12
  "typescript",
14
- "javascript",
15
13
  "react",
16
- "json",
17
- "file"
14
+ "vite",
15
+ "json"
18
16
  ],
19
- "homepage": "https://github.com/aypineau/intlayer",
17
+ "homepage": "https://intlayer.org",
18
+ "bugs": {
19
+ "url": "https://github.com/aypineau/intlayer/issues"
20
+ },
20
21
  "repository": {
21
22
  "type": "git",
22
23
  "url": "git+https://github.com/aypineau/intlayer.git"
23
24
  },
24
- "license": "MIT",
25
+ "license": "Apache-2.0",
25
26
  "author": {
26
27
  "name": "Aymeric PINEAU",
27
28
  "url": "https://github.com/aypineau"
28
29
  },
30
+ "contributors": [
31
+ {
32
+ "name": "Aymeric Pineau",
33
+ "email": "ay.pineau@gmail.com",
34
+ "url": "https://github.com/aypineau"
35
+ }
36
+ ],
29
37
  "exports": {
30
38
  ".": {
31
39
  "types": "./dist/esm/index.d.mts",
@@ -54,6 +62,8 @@
54
62
  },
55
63
  "./package.json": "./package.json"
56
64
  },
65
+ "main": "dist/cjs/index.cjs",
66
+ "module": "dist/esm/index.mjs",
57
67
  "typesVersions": {
58
68
  "*": {
59
69
  "package.json": [
@@ -75,13 +85,13 @@
75
85
  "react-cookie": "^7.1.4",
76
86
  "vite": "^5.3.1",
77
87
  "webpack": "^5.92.1",
78
- "@intlayer/config": "^2.0.11",
79
- "@intlayer/dictionaries-entry": "^2.0.11",
80
- "@intlayer/core": "^2.0.11",
81
- "@intlayer/webpack": "^2.0.11",
82
- "intlayer": "^2.0.11",
83
- "@intlayer/chokidar": "^2.0.11",
84
- "intlayer-editor": "^2.1.10"
88
+ "@intlayer/chokidar": "^2.0.12",
89
+ "@intlayer/config": "^2.0.12",
90
+ "@intlayer/core": "^2.0.12",
91
+ "@intlayer/dictionaries-entry": "^2.0.12",
92
+ "@intlayer/webpack": "^2.0.12",
93
+ "intlayer": "^2.0.12",
94
+ "intlayer-editor": "^2.1.11"
85
95
  },
86
96
  "devDependencies": {
87
97
  "@craco/types": "^7.1.0",