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.
Files changed (2) hide show
  1. package/README.md +69 -29
  2. 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/vite-intlayer">
9
- <img alt="npm" src="https://img.shields.io/npm/v/vite-intlayer.svg?labelColor=49516F&color=8994BC" />
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/vite-intlayer">
12
- <img alt="downloads" src="https://badgen.net/npm/dm/vite-intlayer?labelColor=49516F&color=8994BC" />
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/vite-intlayer">
15
- <img alt="types included" src="https://badgen.net/npm/types/vite-intlayer?labelColor=49516F&color=8994BC"
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
- # vite-intlayer: Internationalize (i18n) an Vite application
19
+ > This package is in development.
20
20
 
21
- **Intlayer** is a suite of packages designed specifically for JavaScript developers. It is compatible with frameworks like React, React, and Express.js.
21
+ # svelte-intlayer: Internationalize (i18n) an Svelte application
22
22
 
23
- **The `vite-intlayer` package** allows you to internationalize your Vite application. It includes the Vite plugin to set the configuration through environment variables into the [Vite bundler](https://vitejs.dev/guide/why.html#why-bundle-for-production). It also provides middleware to detect the user's preferred locale, and redirect the user to the appropriate URL as specified in the [configuration](https://intlayer.org/doc/concept/configuration).
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
- ## Why Internationalize Your Vite Application?
25
+ **The `svelte-intlayer` package** allows you to internationalize your Svelte application. It provides context providers and hooks for Svelte internationalization.
26
26
 
27
- Internationalizing your Vite 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.
27
+ ## Why Internationalize Your Svelte Application?
28
28
 
29
- ## Configuration
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
- The `vite-intlayer` package works seamlessly with the [`react-intlayer` package](https://github.com/aymericzip/intlayer/blob/main/docs/en/packages/react-intlayer/index.md), and the [`intlayer` package](https://github.com/aymericzip/intlayer/blob/main/docs/en/packages/intlayer/index.md). Have a look at the relevant documentation for more information.
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 vite-intlayer
42
+ npm install svelte-intlayer
39
43
  ```
40
44
 
41
45
  ```bash packageManager="yarn"
42
- yarn add vite-intlayer
46
+ yarn add svelte-intlayer
43
47
  ```
44
48
 
45
49
  ```bash packageManager="pnpm"
46
- pnpm add vite-intlayer
50
+ pnpm add svelte-intlayer
47
51
  ```
48
52
 
49
53
  ## Example of usage
50
54
 
51
- See an example of how to include the plugins into your vite configuration.
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
- ```typescript fileName="vite.config.ts"
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
- // https://vitejs.dev/config/
58
- export default defineConfig({
59
- plugins: [intlayerPlugin(), intLayerMiddlewarePlugin()],
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
- > The `intlayerPlugin()` Vite plugin is used to integrate Intlayer with Vite. It ensures the building of content declaration files and monitors them in development mode. It defines Intlayer environment variables within the Vite application. Additionally, it provides aliases to optimize performance.
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
- > The `intLayerMiddlewarePlugin()` add server-side routing to your application. This plugin will automatically detect the current locale based on the URL and set the appropriate locale cookie. If no locale is specified, the plugin will determine the most appropriate locale based on the user's browser language preferences. If no locale is detected, it will redirect to the default locale.
105
+ ### Utilize Content in Your Code
66
106
 
67
- ## Mastering the internationalization of your Vite application
107
+ ...
68
108
 
69
- Intlayer provides a lot of features to help you internationalize your Vite application.
109
+ ## Functions provided by `svelte-intlayer` package
70
110
 
71
- **To learn more about these features, refer to the [React Internationalization (i18n) with Intlayer and Vite and React](https://github.com/aymericzip/intlayer/blob/main/docs/en/intlayer_with_vite+react.md) guide for Vite and React Application.**
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.11",
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/config": "5.3.11",
60
- "@intlayer/chokidar": "5.3.11",
61
- "@intlayer/core": "5.3.11"
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-types": "1.0.4",
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
- "@intlayer/chokidar": "5.3.11",
80
- "@intlayer/config": "5.3.11",
81
- "@intlayer/core": "5.3.11"
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"