next-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 -8
  2. package/package.json +28 -17
package/README.md CHANGED
@@ -1,25 +1,67 @@
1
1
  <div align="center">
2
- <a href="https://www.npmjs.com/package/intlayer">
2
+ <a href="https://www.npmjs.com/package/next-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/next-intlayer">
9
+ <img alt="npm" src="https://img.shields.io/npm/v/next-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/next-intlayer">
12
+ <img alt="downloads" src="https://badgen.net/npm/dm/next-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/next-intlayer">
15
+ <img alt="types included" src="https://badgen.net/npm/types/next-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
+ ├── ClientComponent
29
+ │   ├── index.content.ts
30
+ │   └── index.tsx
31
+ └── ServerComponent
32
+    ├── index.tsx
33
+    └── index.content.ts
34
+ ```
35
+
36
+ ```tsx
37
+ // ./ClientComponent/index.content.ts
38
+
39
+ import { DeclarationContent, t } from "intlayer";
40
+
41
+ const clientComponentContent: DeclarationContent = {
42
+ id: "client-component",
43
+ myTranslatedContent: t({
44
+ en: "Hello World",
45
+ fr: "Bonjour le monde",
46
+ es: "Hola Mundo",
47
+ }),
48
+ };
49
+
50
+ export default clientComponentContent;
51
+ ```
52
+
53
+ ```tsx
54
+ // ./ClientComponent/index.tsx
55
+ "use client";
56
+
57
+ import { useIntlayer } from "next-intlayer";
58
+
59
+ export const ClientComponent = () => {
60
+ const { myTranslatedContent } = useIntlayer("client-component");
61
+
62
+ return <span>{myTranslatedContent}</span>;
63
+ };
64
+ ```
23
65
 
24
66
  ## Why Choose Intlayer?
25
67
 
@@ -294,6 +336,23 @@ export const generateMetadata = ({
294
336
  };
295
337
  ```
296
338
 
339
+ ## (Optional) Step 9: Change the language of your content
340
+
341
+ 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.
342
+
343
+ ```tsx
344
+ import { Locales } from "intlayer";
345
+ import { useLocale } from "next-intlayer";
346
+
347
+ const MyComponent = () => {
348
+ const { setLocale } = useLocale();
349
+
350
+ return (
351
+ <button onClick={() => setLocale(Locales.English)}>Change Language</button>
352
+ );
353
+ };
354
+ ```
355
+
297
356
  ## Configure TypeScript
298
357
 
299
358
  Intlayer use module augmentation to get benefits of TypeScript and make your codebase stronger.
package/package.json CHANGED
@@ -1,29 +1,38 @@
1
1
  {
2
2
  "name": "next-intlayer",
3
- "version": "2.0.11",
3
+ "version": "2.0.12",
4
4
  "private": false,
5
- "description": "Webpack configuration for IntLayer using NextJS",
5
+ "description": "Internationalisation tool for Next.js applications. Declare your multilingual contant in the same lever than your component. Powered by TypeScript, declaration files.",
6
6
  "keywords": [
7
7
  "intlayer",
8
- "webpack",
9
- "application",
10
- "transpile",
8
+ "multilingual",
9
+ "i18n",
10
+ "internationalization",
11
11
  "nextjs",
12
12
  "typescript",
13
- "javascript",
14
- "json",
15
- "file"
13
+ "react",
14
+ "json"
16
15
  ],
17
- "homepage": "https://github.com/aypineau/intlayer",
16
+ "homepage": "https://intlayer.org",
17
+ "bugs": {
18
+ "url": "https://github.com/aypineau/intlayer/issues"
19
+ },
18
20
  "repository": {
19
21
  "type": "git",
20
22
  "url": "git+https://github.com/aypineau/intlayer.git"
21
23
  },
22
- "license": "MIT",
24
+ "license": "Apache-2.0",
23
25
  "author": {
24
26
  "name": "Aymeric PINEAU",
25
27
  "url": "https://github.com/aypineau"
26
28
  },
29
+ "contributors": [
30
+ {
31
+ "name": "Aymeric Pineau",
32
+ "email": "ay.pineau@gmail.com",
33
+ "url": "https://github.com/aypineau"
34
+ }
35
+ ],
27
36
  "exports": {
28
37
  ".": {
29
38
  "types": "./dist/esm/index.d.mts",
@@ -47,6 +56,8 @@
47
56
  },
48
57
  "./package.json": "./package.json"
49
58
  },
59
+ "main": "dist/cjs/index.cjs",
60
+ "module": "dist/esm/index.mjs",
50
61
  "typesVersions": {
51
62
  "*": {
52
63
  "package.json": [
@@ -63,13 +74,13 @@
63
74
  "negotiator": "^0.6.3",
64
75
  "next": "14.1.4",
65
76
  "webpack": "^5.92.1",
66
- "@intlayer/chokidar": "^2.0.11",
67
- "@intlayer/core": "^2.0.11",
68
- "@intlayer/dictionaries-entry": "^2.0.11",
69
- "@intlayer/webpack": "^2.0.11",
70
- "intlayer": "^2.0.11",
71
- "@intlayer/config": "^2.0.11",
72
- "react-intlayer": "^2.0.11"
77
+ "@intlayer/chokidar": "^2.0.12",
78
+ "@intlayer/config": "^2.0.12",
79
+ "@intlayer/core": "^2.0.12",
80
+ "@intlayer/dictionaries-entry": "^2.0.12",
81
+ "@intlayer/webpack": "^2.0.12",
82
+ "intlayer": "^2.0.12",
83
+ "react-intlayer": "^2.0.12"
73
84
  },
74
85
  "devDependencies": {
75
86
  "@types/negotiator": "^0.6.3",