svelte-intlayer 5.3.11 → 5.3.13
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 +69 -29
- package/package.json +10 -9
package/README.md
CHANGED
|
@@ -5,70 +5,110 @@
|
|
|
5
5
|
</div>
|
|
6
6
|
|
|
7
7
|
<div align="center">
|
|
8
|
-
<a href="https://www.npmjs.com/package/
|
|
9
|
-
<img alt="npm" src="https://img.shields.io/npm/v/
|
|
8
|
+
<a href="https://www.npmjs.com/package/svelte-intlayer">
|
|
9
|
+
<img alt="npm" src="https://img.shields.io/npm/v/svelte-intlayer.svg?labelColor=49516F&color=8994BC" />
|
|
10
10
|
</a>
|
|
11
|
-
<a href="https://npmjs.org/package/
|
|
12
|
-
<img alt="downloads" src="https://badgen.net/npm/dm/
|
|
11
|
+
<a href="https://npmjs.org/package/svelte-intlayer">
|
|
12
|
+
<img alt="downloads" src="https://badgen.net/npm/dm/svelte-intlayer?labelColor=49516F&color=8994BC" />
|
|
13
13
|
</a>
|
|
14
|
-
<a href="https://npmjs.org/package/
|
|
15
|
-
<img alt="types included" src="https://badgen.net/npm/types/
|
|
14
|
+
<a href="https://npmjs.org/package/svelte-intlayer">
|
|
15
|
+
<img alt="types included" src="https://badgen.net/npm/types/svelte-intlayer?labelColor=49516F&color=8994BC"
|
|
16
16
|
/>
|
|
17
17
|
</div>
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
> This package is in development.
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
# svelte-intlayer: Internationalize (i18n) an Svelte application
|
|
22
22
|
|
|
23
|
-
**
|
|
23
|
+
**Intlayer** is a suite of packages designed specifically for JavaScript developers. It is compatible with frameworks like Svelte, React, and Express.js.
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
**The `svelte-intlayer` package** allows you to internationalize your Svelte application. It provides context providers and hooks for Svelte internationalization.
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
## Why Internationalize Your Svelte Application?
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
Internationalizing your Svelte application is essential for serving a global audience effectively. It allows your application to deliver content and messages in the preferred language of each user. This capability enhances user experience and broadens your application's reach by making it more accessible and relevant to people from different linguistic backgrounds.
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
## Why to integrate Intlayer?
|
|
32
|
+
|
|
33
|
+
- **JavaScript-Powered Content Management**: Harness the flexibility of JavaScript to define and manage your content efficiently.
|
|
34
|
+
- **Type-Safe Environment**: Leverage TypeScript to ensure all your content definitions are precise and error-free.
|
|
35
|
+
- **Integrated Content Files**: Keep your translations close to their respective components, enhancing maintainability and clarity.
|
|
32
36
|
|
|
33
37
|
## Installation
|
|
34
38
|
|
|
35
39
|
Install the necessary package using your preferred package manager:
|
|
36
40
|
|
|
37
41
|
```bash packageManager="npm"
|
|
38
|
-
npm install
|
|
42
|
+
npm install svelte-intlayer
|
|
39
43
|
```
|
|
40
44
|
|
|
41
45
|
```bash packageManager="yarn"
|
|
42
|
-
yarn add
|
|
46
|
+
yarn add svelte-intlayer
|
|
43
47
|
```
|
|
44
48
|
|
|
45
49
|
```bash packageManager="pnpm"
|
|
46
|
-
pnpm add
|
|
50
|
+
pnpm add svelte-intlayer
|
|
47
51
|
```
|
|
48
52
|
|
|
49
53
|
## Example of usage
|
|
50
54
|
|
|
51
|
-
|
|
55
|
+
With Intlayer, you can declare your content in a structured way anywhere in your codebase.
|
|
56
|
+
|
|
57
|
+
By default, Intlayer scans for files with the extension `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`.
|
|
52
58
|
|
|
53
|
-
|
|
54
|
-
import { defineConfig } from "vite";
|
|
55
|
-
import { intlayerPlugin, intLayerMiddlewarePlugin } from "vite-intlayer";
|
|
59
|
+
> You can modify the default extension by setting the `contentDir` property in the [configuration file](https://intlayer.org/doc/concept/configuration).
|
|
56
60
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
```bash codeFormat="typescript"
|
|
62
|
+
.
|
|
63
|
+
├── intlayer.config.ts
|
|
64
|
+
└── src
|
|
65
|
+
└── components
|
|
66
|
+
├── Component1
|
|
67
|
+
│ ├── index.content.ts
|
|
68
|
+
│ └── index.svelte
|
|
69
|
+
└── Component2
|
|
70
|
+
├── index.content.ts
|
|
71
|
+
└── index.svelte
|
|
61
72
|
```
|
|
62
73
|
|
|
63
|
-
|
|
74
|
+
### Declare your content
|
|
75
|
+
|
|
76
|
+
`svelte-intlayer` is made to work with the [`intlayer` package](https://github.com/aymericzip/intlayer/blob/main/docs/en/packages/intlayer/index.md).`intlayer` is a package that allows you to declare your content anywhere in your code. It converts multilingual content declarations into structured dictionaries that integrate seamlessly into your application.
|
|
77
|
+
|
|
78
|
+
Here’s an example of content declaration:
|
|
79
|
+
|
|
80
|
+
```tsx filePath="src/Component1/index.content.ts" codeFormat="typescript"
|
|
81
|
+
import { t, type Dictionary } from "intlayer";
|
|
82
|
+
|
|
83
|
+
const component1Content = {
|
|
84
|
+
key: "component-1",
|
|
85
|
+
content: {
|
|
86
|
+
myTranslatedContent: t({
|
|
87
|
+
en: "Hello World",
|
|
88
|
+
fr: "Bonjour le monde",
|
|
89
|
+
es: "Hola Mundo",
|
|
90
|
+
}),
|
|
91
|
+
numberOfCar: enu({
|
|
92
|
+
"<-1": "Less than minus one car",
|
|
93
|
+
"-1": "Minus one car",
|
|
94
|
+
"0": "No cars",
|
|
95
|
+
"1": "One car",
|
|
96
|
+
">5": "Some cars",
|
|
97
|
+
">19": "Many cars",
|
|
98
|
+
}),
|
|
99
|
+
},
|
|
100
|
+
} satisfies Dictionary;
|
|
101
|
+
|
|
102
|
+
export default component1Content;
|
|
103
|
+
```
|
|
64
104
|
|
|
65
|
-
|
|
105
|
+
### Utilize Content in Your Code
|
|
66
106
|
|
|
67
|
-
|
|
107
|
+
...
|
|
68
108
|
|
|
69
|
-
|
|
109
|
+
## Functions provided by `svelte-intlayer` package
|
|
70
110
|
|
|
71
|
-
|
|
111
|
+
The `svelte-intlayer` package also provides some functions to help you to internationalize your application.
|
|
72
112
|
|
|
73
113
|
## Read about Intlayer
|
|
74
114
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-intlayer",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.13",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Easily internationalize i18n your Svelte applications with type-safe multilingual content management.",
|
|
6
6
|
"keywords": [
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
"./package.json"
|
|
57
57
|
],
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@intlayer/
|
|
60
|
-
"@intlayer/
|
|
61
|
-
"@intlayer/core": "5.3.
|
|
59
|
+
"@intlayer/chokidar": "5.3.13",
|
|
60
|
+
"@intlayer/config": "5.3.13",
|
|
61
|
+
"@intlayer/core": "5.3.13"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@types/node": "^22.13.10",
|
|
@@ -71,14 +71,15 @@
|
|
|
71
71
|
"tsup": "^8.4.0",
|
|
72
72
|
"typescript": "^5.8.2",
|
|
73
73
|
"@utils/eslint-config": "1.0.4",
|
|
74
|
-
"@utils/ts-config
|
|
74
|
+
"@utils/ts-config": "1.0.4",
|
|
75
75
|
"@utils/tsup-config": "1.0.4",
|
|
76
|
-
"@utils/ts-config": "1.0.4"
|
|
76
|
+
"@utils/ts-config-types": "1.0.4"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
|
-
"
|
|
80
|
-
"@intlayer/
|
|
81
|
-
"@intlayer/
|
|
79
|
+
"svelte": "^5.23.1",
|
|
80
|
+
"@intlayer/chokidar": "5.3.13",
|
|
81
|
+
"@intlayer/config": "5.3.13",
|
|
82
|
+
"@intlayer/core": "5.3.13"
|
|
82
83
|
},
|
|
83
84
|
"engines": {
|
|
84
85
|
"node": ">=14.18"
|