@intlayer/engine 9.5.6 → 9.5.8
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/dist/assets/installSkills/skills/angular.md +19 -68
- package/dist/assets/installSkills/skills/astro.md +38 -4
- package/dist/assets/installSkills/skills/backend.md +113 -0
- package/dist/assets/installSkills/skills/cli.md +29 -25
- package/dist/assets/installSkills/skills/compat.md +87 -0
- package/dist/assets/installSkills/skills/compiler.md +14 -4
- package/dist/assets/installSkills/skills/config.md +15 -5
- package/dist/assets/installSkills/skills/content.md +80 -6
- package/dist/assets/installSkills/skills/dev-tools.md +82 -0
- package/dist/assets/installSkills/skills/lit.md +115 -0
- package/dist/assets/installSkills/skills/markdown.md +96 -0
- package/dist/assets/installSkills/skills/next-js.md +21 -38
- package/dist/assets/installSkills/skills/preact.md +18 -0
- package/dist/assets/installSkills/skills/react.md +21 -4
- package/dist/assets/installSkills/skills/remix.md +95 -0
- package/dist/assets/installSkills/skills/remote-content.md +1 -1
- package/dist/assets/installSkills/skills/solid.md +21 -1
- package/dist/assets/installSkills/skills/svelte.md +22 -1
- package/dist/assets/installSkills/skills/usage.md +28 -0
- package/dist/assets/installSkills/skills/vanilla.md +108 -0
- package/dist/assets/installSkills/skills/vue.md +22 -0
- package/dist/cjs/cli.cjs +2 -0
- package/dist/cjs/init/index.cjs +305 -300
- package/dist/cjs/init/index.cjs.map +1 -1
- package/dist/cjs/init/upgradeIntlayerPackages.cjs +60 -0
- package/dist/cjs/init/upgradeIntlayerPackages.cjs.map +1 -0
- package/dist/cjs/init/utils/index.cjs +13 -4
- package/dist/cjs/init/utils/intlayerDependencies.cjs +119 -0
- package/dist/cjs/init/utils/intlayerDependencies.cjs.map +1 -0
- package/dist/cjs/init/utils/packageManager.cjs +145 -94
- package/dist/cjs/init/utils/packageManager.cjs.map +1 -1
- package/dist/cjs/installSkills/index.cjs +110 -19
- package/dist/cjs/installSkills/index.cjs.map +1 -1
- package/dist/cjs/utils/runOnce.cjs +66 -15
- package/dist/cjs/utils/runOnce.cjs.map +1 -1
- package/dist/esm/cli.mjs +2 -1
- package/dist/esm/init/index.mjs +306 -301
- package/dist/esm/init/index.mjs.map +1 -1
- package/dist/esm/init/upgradeIntlayerPackages.mjs +57 -0
- package/dist/esm/init/upgradeIntlayerPackages.mjs.map +1 -0
- package/dist/esm/init/utils/index.mjs +3 -2
- package/dist/esm/init/utils/intlayerDependencies.mjs +110 -0
- package/dist/esm/init/utils/intlayerDependencies.mjs.map +1 -0
- package/dist/esm/init/utils/packageManager.mjs +143 -93
- package/dist/esm/init/utils/packageManager.mjs.map +1 -1
- package/dist/esm/installSkills/index.mjs +110 -19
- package/dist/esm/installSkills/index.mjs.map +1 -1
- package/dist/esm/utils/runOnce.mjs +67 -16
- package/dist/esm/utils/runOnce.mjs.map +1 -1
- package/dist/types/cli.d.ts +2 -1
- package/dist/types/init/index.d.ts +9 -6
- package/dist/types/init/index.d.ts.map +1 -1
- package/dist/types/init/upgradeIntlayerPackages.d.ts +26 -0
- package/dist/types/init/upgradeIntlayerPackages.d.ts.map +1 -0
- package/dist/types/init/utils/index.d.ts +3 -2
- package/dist/types/init/utils/intlayerDependencies.d.ts +66 -0
- package/dist/types/init/utils/intlayerDependencies.d.ts.map +1 -0
- package/dist/types/init/utils/packageManager.d.ts +44 -19
- package/dist/types/init/utils/packageManager.d.ts.map +1 -1
- package/dist/types/installSkills/index.d.ts +16 -3
- package/dist/types/installSkills/index.d.ts.map +1 -1
- package/dist/types/utils/runOnce.d.ts.map +1 -1
- package/package.json +7 -7
|
@@ -51,19 +51,10 @@ export default content;
|
|
|
51
51
|
## Setup
|
|
52
52
|
|
|
53
53
|
- [Angular](https://intlayer.org/doc/environment/angular.md)
|
|
54
|
+
- [Angular 19](https://intlayer.org/doc/environment/angular/19.md)
|
|
55
|
+
- [Analog](https://intlayer.org/doc/environment/analog.md)
|
|
54
56
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
To use Intlayer in your Angular application, you need to add the `provideIntlayer` provider to your application configuration.
|
|
58
|
-
|
|
59
|
-
```typescript
|
|
60
|
-
import { ApplicationConfig } from "@angular/core";
|
|
61
|
-
import { provideIntlayer } from "angular-intlayer";
|
|
62
|
-
|
|
63
|
-
export const appConfig: ApplicationConfig = {
|
|
64
|
-
providers: [provideIntlayer()],
|
|
65
|
-
};
|
|
66
|
-
```
|
|
57
|
+
Register `provideIntlayer()` in the `providers` of your `ApplicationConfig` (see the [Angular guide](https://intlayer.org/doc/environment/angular.md)).
|
|
67
58
|
|
|
68
59
|
## useIntlayer Hook
|
|
69
60
|
|
|
@@ -90,70 +81,30 @@ export class MyComponent {
|
|
|
90
81
|
}
|
|
91
82
|
```
|
|
92
83
|
|
|
93
|
-
##
|
|
94
|
-
|
|
95
|
-
To change the language, use the `setLocale` function from the `useLocale` hook.
|
|
96
|
-
|
|
97
|
-
```typescript
|
|
98
|
-
import { Component } from "@angular/core";
|
|
99
|
-
import { useLocale } from "angular-intlayer";
|
|
100
|
-
import { Locales } from "intlayer";
|
|
101
|
-
|
|
102
|
-
@Component({
|
|
103
|
-
selector: "app-locale-switcher",
|
|
104
|
-
standalone: true,
|
|
105
|
-
template: `
|
|
106
|
-
<button (click)="setLocale(Locales.FRENCH)">
|
|
107
|
-
Change Language to French
|
|
108
|
-
</button>
|
|
109
|
-
`,
|
|
110
|
-
})
|
|
111
|
-
export class LocaleSwitcherComponent {
|
|
112
|
-
Locales = Locales;
|
|
113
|
-
private localeCtx = useLocale();
|
|
114
|
-
setLocale = this.localeCtx.setLocale;
|
|
115
|
-
}
|
|
116
|
-
```
|
|
84
|
+
## Compiler
|
|
117
85
|
|
|
118
|
-
|
|
86
|
+
The [Intlayer Compiler](https://intlayer.org/doc/compiler.md) can extract all your content keys from your components, using one CLI command (`npx intlayer extract`) or automatically at app build.
|
|
119
87
|
|
|
120
|
-
|
|
88
|
+
## References
|
|
121
89
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
import { RouterModule } from "@angular/router";
|
|
125
|
-
import { useLocale } from "angular-intlayer";
|
|
126
|
-
import { getLocalizedUrl } from "intlayer";
|
|
90
|
+
- [Website](https://intlayer.org)
|
|
91
|
+
- [Doc](https://intlayer.org/doc)
|
|
127
92
|
|
|
128
|
-
|
|
129
|
-
selector: "app-link",
|
|
130
|
-
standalone: true,
|
|
131
|
-
imports: [RouterModule],
|
|
132
|
-
template: `
|
|
133
|
-
<a [routerLink]="localizedHref()" [replaceUrl]="false">
|
|
134
|
-
<ng-content></ng-content>
|
|
135
|
-
</a>
|
|
136
|
-
`,
|
|
137
|
-
})
|
|
138
|
-
export class LinkComponent {
|
|
139
|
-
@Input() href: string = "";
|
|
93
|
+
### Environments
|
|
140
94
|
|
|
141
|
-
|
|
142
|
-
|
|
95
|
+
- [Angular](https://intlayer.org/doc/environment/angular.md)
|
|
96
|
+
- [Angular 19](https://intlayer.org/doc/environment/angular/19.md)
|
|
97
|
+
- [Analog](https://intlayer.org/doc/environment/analog.md)
|
|
143
98
|
|
|
144
|
-
|
|
145
|
-
return this.href.startsWith("http")
|
|
146
|
-
? this.href
|
|
147
|
-
: getLocalizedUrl(this.href, this.locale());
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
```
|
|
99
|
+
### Concepts
|
|
151
100
|
|
|
152
|
-
|
|
101
|
+
- [Variants](https://intlayer.org/doc/concept/variants.md)
|
|
102
|
+
- [Collections](https://intlayer.org/doc/concept/collections.md)
|
|
103
|
+
- [Compiler](https://intlayer.org/doc/compiler.md)
|
|
104
|
+
- [Formatters (number, currency, date, …)](https://intlayer.org/doc/formatters.md)
|
|
153
105
|
|
|
154
|
-
|
|
155
|
-
- [Doc](https://intlayer.org/doc)
|
|
106
|
+
### Packages
|
|
156
107
|
|
|
157
|
-
- [Angular](https://intlayer.org/doc/environment/angular.md)
|
|
158
108
|
- [Angular Intlayer Exports](https://intlayer.org/doc/packages/angular-intlayer/exports.md)
|
|
159
109
|
- [Intlayer Exports](https://intlayer.org/doc/packages/intlayer/exports.md)
|
|
110
|
+
- [angular-intlayer usePathname](https://intlayer.org/doc/packages/angular-intlayer/usePathname.md)
|
|
@@ -18,23 +18,57 @@ metadata:
|
|
|
18
18
|
|
|
19
19
|
- [Astro](https://intlayer.org/doc/environment/astro.md)
|
|
20
20
|
|
|
21
|
+
The `intlayer()` integration in `astro.config.ts` builds the dictionaries and adds a middleware that resolves the locale of every request into `Astro.locals.intlayer`.
|
|
22
|
+
|
|
21
23
|
## Server-side (Astro Components)
|
|
22
24
|
|
|
23
25
|
```astro
|
|
24
26
|
---
|
|
25
|
-
import {
|
|
26
|
-
|
|
27
|
+
import { useIntlayer, useLocale } from "astro-intlayer";
|
|
28
|
+
|
|
29
|
+
// Locale resolved by the middleware (e.g. /es/about -> 'es')
|
|
30
|
+
const { locale } = useLocale();
|
|
31
|
+
const content = useIntlayer("my-dictionary-key");
|
|
27
32
|
---
|
|
28
33
|
<h1>{content.title}</h1>
|
|
29
34
|
```
|
|
30
35
|
|
|
31
|
-
|
|
36
|
+
## Framework Islands
|
|
37
|
+
|
|
38
|
+
Islands use their framework package (`react-intlayer`, `vue-intlayer`, `svelte-intlayer`, `solid-intlayer`, `preact-intlayer`, `lit-intlayer`) and receive the server-detected locale as a prop.
|
|
39
|
+
|
|
40
|
+
## Compiler
|
|
41
|
+
|
|
42
|
+
The [Intlayer Compiler](https://intlayer.org/doc/compiler.md) can extract all your content keys from your components, using one CLI command (`npx intlayer extract`) or automatically at app build.
|
|
32
43
|
|
|
33
44
|
## References
|
|
34
45
|
|
|
35
46
|
- [Website](https://intlayer.org)
|
|
36
|
-
- [Doc](https://intlayer.org/doc
|
|
47
|
+
- [Doc](https://intlayer.org/doc)
|
|
48
|
+
|
|
49
|
+
### Environments
|
|
37
50
|
|
|
38
51
|
- [Astro](https://intlayer.org/doc/environment/astro.md)
|
|
52
|
+
- [Astro and React](https://intlayer.org/doc/environment/astro/react.md)
|
|
53
|
+
- [Astro and Vue](https://intlayer.org/doc/environment/astro/vue.md)
|
|
54
|
+
- [Astro and Svelte](https://intlayer.org/doc/environment/astro/svelte.md)
|
|
55
|
+
- [Astro and Solid](https://intlayer.org/doc/environment/astro/solid.md)
|
|
56
|
+
- [Astro and Preact](https://intlayer.org/doc/environment/astro/preact.md)
|
|
57
|
+
- [Astro and Lit](https://intlayer.org/doc/environment/astro/lit.md)
|
|
58
|
+
|
|
59
|
+
### Concepts
|
|
60
|
+
|
|
61
|
+
- [Variants](https://intlayer.org/doc/concept/variants.md)
|
|
62
|
+
- [Collections](https://intlayer.org/doc/concept/collections.md)
|
|
63
|
+
- [Compiler](https://intlayer.org/doc/compiler.md)
|
|
64
|
+
- [Formatters (number, currency, date, …)](https://intlayer.org/doc/formatters.md)
|
|
65
|
+
|
|
66
|
+
### Packages
|
|
67
|
+
|
|
39
68
|
- [Intlayer Exports](https://intlayer.org/doc/packages/intlayer/exports.md)
|
|
40
69
|
- [Astro Intlayer Exports](https://intlayer.org/doc/packages/astro-intlayer/exports.md)
|
|
70
|
+
- [astro-intlayer intlayer](https://intlayer.org/doc/packages/astro-intlayer/intlayer.md)
|
|
71
|
+
- [astro-intlayer onRequest](https://intlayer.org/doc/packages/astro-intlayer/onRequest.md)
|
|
72
|
+
- [astro-intlayer useDictionary](https://intlayer.org/doc/packages/astro-intlayer/useDictionary.md)
|
|
73
|
+
- [astro-intlayer useIntlayer](https://intlayer.org/doc/packages/astro-intlayer/useIntlayer.md)
|
|
74
|
+
- [astro-intlayer useLocale](https://intlayer.org/doc/packages/astro-intlayer/useLocale.md)
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: intlayer-backend
|
|
3
|
+
description: Integrates Intlayer internationalization with Node.js / Bun backends (Express, Fastify, Hono, NestJS, AdonisJS, Elysia, HTMX). Use when the user asks to "translate API responses", "setup server-side i18n", register the Intlayer middleware, or use "t" / "getIntlayer" in a route handler.
|
|
4
|
+
metadata:
|
|
5
|
+
author: Intlayer
|
|
6
|
+
url: https://intlayer.org
|
|
7
|
+
license: Apache-2.0
|
|
8
|
+
mcp-server: "@intlayer/mcp"
|
|
9
|
+
category: productivity
|
|
10
|
+
tags: [i18n, backend, express, fastify, hono, nestjs, adonisjs, elysia]
|
|
11
|
+
documentation: https://intlayer.org/doc
|
|
12
|
+
support: contact@intlayer.org
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# Intlayer Backend Usage
|
|
16
|
+
|
|
17
|
+
## Core Philosophy
|
|
18
|
+
|
|
19
|
+
Every backend integration works the same way:
|
|
20
|
+
|
|
21
|
+
1. A **middleware / plugin** (`intlayer()`) resolves the locale of each request (cookie, header, `Accept-Language`) and scopes it to that request.
|
|
22
|
+
2. **Helpers** (`t`, `getIntlayer`, `getDictionary`) read that request locale, so they are safe to call from services without threading a locale argument through every function.
|
|
23
|
+
|
|
24
|
+
| Framework | Package | Registration |
|
|
25
|
+
| --------- | ------------------ | ------------------------------------------------------ |
|
|
26
|
+
| Express | `express-intlayer` | `app.use(intlayer())` |
|
|
27
|
+
| NestJS | `express-intlayer` | `consumer.apply(intlayer()).forRoutes("*")` |
|
|
28
|
+
| Fastify | `fastify-intlayer` | `await fastify.register(intlayer)` |
|
|
29
|
+
| Hono | `hono-intlayer` | `app.use("*", intlayer())` |
|
|
30
|
+
| Elysia | `elysia-intlayer` | `.use(intlayer())`, helpers read from route `intlayer` |
|
|
31
|
+
| AdonisJS | `adonis-intlayer` | Registered middleware (see the AdonisJS guide) |
|
|
32
|
+
|
|
33
|
+
### Declare Content
|
|
34
|
+
|
|
35
|
+
**File:** `src/index.content.ts`
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { t, type Dictionary } from "intlayer";
|
|
39
|
+
|
|
40
|
+
const content = {
|
|
41
|
+
key: "index",
|
|
42
|
+
content: {
|
|
43
|
+
exampleOfContent: t({
|
|
44
|
+
en: "Example of returned content in English",
|
|
45
|
+
fr: "Exemple de contenu renvoyé en français",
|
|
46
|
+
}),
|
|
47
|
+
},
|
|
48
|
+
} satisfies Dictionary;
|
|
49
|
+
|
|
50
|
+
export default content;
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Usage
|
|
54
|
+
|
|
55
|
+
Register the middleware / plugin from the table above **before** the routes that read content (see the [Express guide](https://intlayer.org/doc/environment/express.md)), then call the helpers in any handler:
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import { t, getIntlayer, getDictionary } from "express-intlayer";
|
|
59
|
+
import dictionaryExample from "./index.content";
|
|
60
|
+
|
|
61
|
+
app.get("/", (_req, res) => {
|
|
62
|
+
res.send(t({ en: "Hello", fr: "Bonjour" })); // Inline translation
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
app.get("/by-key", (_req, res) => {
|
|
66
|
+
res.send(getIntlayer("index").exampleOfContent); // Dictionary by key
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
app.get("/by-import", (_req, res) => {
|
|
70
|
+
res.send(getDictionary(dictionaryExample).exampleOfContent); // Imported dictionary
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The same helpers are exported by `fastify-intlayer`, `hono-intlayer` and `adonis-intlayer`. On Elysia, read them from the route context: `({ intlayer }) => intlayer!.getIntlayer("index")`.
|
|
75
|
+
|
|
76
|
+
> For jobs, queues or emails (no incoming request), resolve content for the recipient's stored locale: `getIntlayer("index", user.locale)`.
|
|
77
|
+
|
|
78
|
+
## References
|
|
79
|
+
|
|
80
|
+
- [Website](https://intlayer.org)
|
|
81
|
+
- [Doc](https://intlayer.org/doc)
|
|
82
|
+
|
|
83
|
+
### Environments
|
|
84
|
+
|
|
85
|
+
- [Express](https://intlayer.org/doc/environment/express.md)
|
|
86
|
+
- [Fastify](https://intlayer.org/doc/environment/fastify.md)
|
|
87
|
+
- [Hono](https://intlayer.org/doc/environment/hono.md)
|
|
88
|
+
- [NestJS](https://intlayer.org/doc/environment/nest.md)
|
|
89
|
+
- [AdonisJS](https://intlayer.org/doc/environment/adonisjs.md)
|
|
90
|
+
- [Elysia](https://intlayer.org/doc/environment/elysia.md)
|
|
91
|
+
- [HTMX](https://intlayer.org/doc/environment/htmx.md)
|
|
92
|
+
|
|
93
|
+
### Concepts
|
|
94
|
+
|
|
95
|
+
- [Variants](https://intlayer.org/doc/concept/variants.md)
|
|
96
|
+
- [Collections](https://intlayer.org/doc/concept/collections.md)
|
|
97
|
+
|
|
98
|
+
### Packages
|
|
99
|
+
|
|
100
|
+
- [Intlayer Exports](https://intlayer.org/doc/packages/intlayer/exports.md)
|
|
101
|
+
- [Express Intlayer Exports](https://intlayer.org/doc/packages/express-intlayer/exports.md)
|
|
102
|
+
- [Fastify Intlayer Exports](https://intlayer.org/doc/packages/fastify-intlayer/exports.md)
|
|
103
|
+
- [Hono Intlayer Exports](https://intlayer.org/doc/packages/hono-intlayer/exports.md)
|
|
104
|
+
- [Adonis Intlayer Exports](https://intlayer.org/doc/packages/adonis-intlayer/exports.md)
|
|
105
|
+
- [Elysia Intlayer Exports](https://intlayer.org/doc/packages/elysia-intlayer/exports.md)
|
|
106
|
+
- [adonis-intlayer intlayer](https://intlayer.org/doc/packages/adonis-intlayer/intlayer.md)
|
|
107
|
+
- [adonis-intlayer t](https://intlayer.org/doc/packages/adonis-intlayer/t.md)
|
|
108
|
+
- [elysia-intlayer intlayer](https://intlayer.org/doc/packages/elysia-intlayer/intlayer.md)
|
|
109
|
+
- [express-intlayer intlayer](https://intlayer.org/doc/packages/express-intlayer/intlayer.md)
|
|
110
|
+
- [express-intlayer t](https://intlayer.org/doc/packages/express-intlayer/t.md)
|
|
111
|
+
- [fastify-intlayer intlayer](https://intlayer.org/doc/packages/fastify-intlayer/intlayer.md)
|
|
112
|
+
- [hono-intlayer intlayer](https://intlayer.org/doc/packages/hono-intlayer/intlayer.md)
|
|
113
|
+
- [hono-intlayer t](https://intlayer.org/doc/packages/hono-intlayer/t.md)
|
|
@@ -33,36 +33,40 @@ npm install intlayer-cli
|
|
|
33
33
|
| `npx intlayer push` | Pushes dictionaries to a remote source. |
|
|
34
34
|
| `npx intlayer test` | Runs tests on dictionaries. |
|
|
35
35
|
| `npx intlayer extract` | Extract content from component to create dictionary. |
|
|
36
|
+
| `npx intlayer upgrade` | Upgrades every Intlayer package of the repo to latest. |
|
|
36
37
|
|
|
37
38
|
## References
|
|
38
39
|
|
|
39
|
-
|
|
40
|
+
- [Website](https://intlayer.org)
|
|
41
|
+
- [Doc](https://intlayer.org/doc)
|
|
42
|
+
|
|
43
|
+
### Commands
|
|
40
44
|
|
|
41
|
-
- [Build](https://intlayer.org/doc/concept/cli/build.md)
|
|
42
|
-
- [
|
|
43
|
-
- [
|
|
44
|
-
- [
|
|
45
|
-
- [
|
|
46
|
-
- [
|
|
47
|
-
- [
|
|
48
|
-
- [Fill](https://intlayer.org/doc/concept/cli/fill.md)
|
|
49
|
-
- [
|
|
50
|
-
- [
|
|
51
|
-
- [
|
|
52
|
-
- [
|
|
45
|
+
- [Build Dictionaries](https://intlayer.org/doc/concept/cli/build.md)
|
|
46
|
+
- [Manage Configuration](https://intlayer.org/doc/concept/cli/configuration.md)
|
|
47
|
+
- [Debug Intlayer Command](https://intlayer.org/doc/concept/cli/debug.md)
|
|
48
|
+
- [Review Document](https://intlayer.org/doc/concept/cli/doc-review.md)
|
|
49
|
+
- [Translate Document](https://intlayer.org/doc/concept/cli/doc-translate.md)
|
|
50
|
+
- [Editor Commands](https://intlayer.org/doc/concept/cli/editor.md)
|
|
51
|
+
- [Extract strings](https://intlayer.org/doc/concept/cli/extract.md)
|
|
52
|
+
- [Fill Dictionaries](https://intlayer.org/doc/concept/cli/fill.md)
|
|
53
|
+
- [CLI Overview](https://intlayer.org/doc/concept/cli.md)
|
|
54
|
+
- [Init Infra](https://intlayer.org/doc/concept/cli/infra.md)
|
|
55
|
+
- [Initialize Intlayer](https://intlayer.org/doc/concept/cli/init.md)
|
|
56
|
+
- [List Content Declaration Files](https://intlayer.org/doc/concept/cli/list.md)
|
|
57
|
+
- [List Intlayer Projects](https://intlayer.org/doc/concept/cli/list-projects.md)
|
|
58
|
+
- [Live Sync Commands](https://intlayer.org/doc/concept/cli/live.md)
|
|
53
59
|
- [Login](https://intlayer.org/doc/concept/cli/login.md)
|
|
54
|
-
- [Pull](https://intlayer.org/doc/concept/cli/pull.md)
|
|
55
|
-
- [Push](https://intlayer.org/doc/concept/cli/push.md)
|
|
56
|
-
- [
|
|
57
|
-
- [
|
|
58
|
-
- [
|
|
59
|
-
- [
|
|
60
|
-
- [
|
|
60
|
+
- [Pull Dictionaries](https://intlayer.org/doc/concept/cli/pull.md)
|
|
61
|
+
- [Push Dictionaries](https://intlayer.org/doc/concept/cli/push.md)
|
|
62
|
+
- [Scan Website](https://intlayer.org/doc/concept/cli/scan.md)
|
|
63
|
+
- [CLI SDK](https://intlayer.org/doc/concept/cli/sdk.md)
|
|
64
|
+
- [Standalone Bundle](https://intlayer.org/doc/concept/cli/standalone.md)
|
|
65
|
+
- [Test Missing Translations](https://intlayer.org/doc/concept/cli/test.md)
|
|
66
|
+
- [Upgrade Intlayer Packages](https://intlayer.org/doc/concept/cli/upgrade.md)
|
|
67
|
+
- [Check CLI Version](https://intlayer.org/doc/concept/cli/version.md)
|
|
68
|
+
- [Watch Dictionaries](https://intlayer.org/doc/concept/cli/watch.md)
|
|
61
69
|
|
|
62
70
|
### Packages
|
|
63
71
|
|
|
64
|
-
- [
|
|
65
|
-
- [Doc](https://intlayer.org/doc/concept/cli.md)
|
|
66
|
-
|
|
67
|
-
- [Intlayer CLI](https://intlayer.org/doc/packages/intlayer-cli/exports.md)
|
|
68
|
-
- [Intlayer CLI Exports](https://intlayer.org/doc/packages/intlayer-cli/exports.md)
|
|
72
|
+
- [intlayer-cli Exports](https://intlayer.org/doc/packages/intlayer-cli/exports.md)
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: intlayer-compat
|
|
3
|
+
description: Migrates an existing i18n library (i18next, react-i18next, next-intl, next-i18next, react-intl, vue-i18n, Lingui…) to Intlayer through compat adapters that keep the original API. Use when the user asks to "migrate from i18next / next-intl / vue-i18n", "keep useTranslation working", or adopt Intlayer without rewriting translation calls.
|
|
4
|
+
metadata:
|
|
5
|
+
author: Intlayer
|
|
6
|
+
url: https://intlayer.org
|
|
7
|
+
license: Apache-2.0
|
|
8
|
+
mcp-server: "@intlayer/mcp"
|
|
9
|
+
category: productivity
|
|
10
|
+
tags: [i18n, migration, i18next, next-intl, react-intl, vue-i18n, lingui]
|
|
11
|
+
documentation: https://intlayer.org/doc
|
|
12
|
+
support: contact@intlayer.org
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# Intlayer Compat Adapters
|
|
16
|
+
|
|
17
|
+
Compat adapters expose the **exact same public API** as an existing i18n library, but serve translations from Intlayer dictionaries. Application code keeps calling `useTranslation`, `useTranslations`, `useIntl`, `$t`… with keys typed against the Intlayer dictionaries.
|
|
18
|
+
|
|
19
|
+
## How it works
|
|
20
|
+
|
|
21
|
+
1. Run `npx intlayer init --interactive`: it creates `intlayer.config.ts`, installs the adapter and can keep existing JSON catalogs as the source of truth via a sync plugin.
|
|
22
|
+
2. Register the adapter's bundler plugin (`<adapter>/plugin`). It aliases the original imports to the adapter at build time, so no import is rewritten by hand.
|
|
23
|
+
|
|
24
|
+
## Adapters
|
|
25
|
+
|
|
26
|
+
| Existing library | Adapter | Bundler plugin (`<adapter>/plugin`) |
|
|
27
|
+
| ------------------------------- | ------------------------- | ----------------------------------- |
|
|
28
|
+
| `i18next` | `@intlayer/i18next` | `i18nextVitePlugin` |
|
|
29
|
+
| `react-i18next` | `@intlayer/react-i18next` | `reactI18nextVitePlugin` |
|
|
30
|
+
| `next-i18next` | `@intlayer/next-i18next` | `createNextI18nPlugin` |
|
|
31
|
+
| `next-intl` | `@intlayer/next-intl` | `createNextIntlPlugin` |
|
|
32
|
+
| `use-intl` | `@intlayer/use-intl` | `useIntlVitePlugin` |
|
|
33
|
+
| `react-intl` | `@intlayer/react-intl` | `reactIntlVitePlugin` |
|
|
34
|
+
| `vue-i18n` | `@intlayer/vue-i18n` | `vueI18nVitePlugin` |
|
|
35
|
+
| `@lingui/core`, `@lingui/react` | `@intlayer/lingui` | `linguiVitePlugin` |
|
|
36
|
+
|
|
37
|
+
> Lingui: keep the Lingui macro plugin (`@lingui/babel-plugin-lingui-macro` / `@lingui/swc-plugin`) running before the Intlayer compiler.
|
|
38
|
+
|
|
39
|
+
> Features outside translation stay with the original library, e.g. `next-intl/navigation` (`Link`, `redirect`, `usePathname`). ICU messages (plural, select, `#`, formatted arguments) and rich formatting (`t.rich`, `<Trans>`) are resolved by Intlayer.
|
|
40
|
+
|
|
41
|
+
Migration guides also exist for Nuxt I18n, NGX Translate, Transloco, Svelte I18n, Next Translate, Polyglot.js and i18n-js.
|
|
42
|
+
|
|
43
|
+
## Keep Existing Catalogs: Sync Plugins
|
|
44
|
+
|
|
45
|
+
To keep the current library **and** its message files, register a sync plugin in the `plugins` of `intlayer.config.ts` instead of (or alongside) an adapter. Intlayer then manages the catalogs (AI fill, CI tests, CMS) without changing the rendering runtime.
|
|
46
|
+
|
|
47
|
+
| Catalog format | Package | Plugins |
|
|
48
|
+
| -------------- | ---------------------------- | ---------------------- |
|
|
49
|
+
| JSON | `@intlayer/sync-json-plugin` | `syncJSON`, `loadJSON` |
|
|
50
|
+
| Gettext PO | `@intlayer/sync-po-plugin` | `syncPO`, `loadPO` |
|
|
51
|
+
|
|
52
|
+
- `sync*` reads **and writes back** the files, keeping them in sync with the dictionaries.
|
|
53
|
+
- `load*` only loads the files into dictionaries (never writes back), e.g. for catalogs fetched from a remote source.
|
|
54
|
+
- `syncJSON` accepts `format: 'intlayer' | 'icu' | 'i18next' | 'vue-i18n'` to match the message syntax of the existing library.
|
|
55
|
+
- Current scope: plain text and translations; insertions, plurals/ICU and the visual editor are not supported yet for synced files.
|
|
56
|
+
|
|
57
|
+
## After migrating
|
|
58
|
+
|
|
59
|
+
Once the app runs on Intlayer, components can be moved progressively to the native API (`useIntlayer` + `.content` files) and the adapter removed.
|
|
60
|
+
|
|
61
|
+
## References
|
|
62
|
+
|
|
63
|
+
- [Website](https://intlayer.org)
|
|
64
|
+
- [Doc](https://intlayer.org/doc)
|
|
65
|
+
|
|
66
|
+
### Plugins
|
|
67
|
+
|
|
68
|
+
- [Sync JSON](https://intlayer.org/doc/plugin/sync-json.md)
|
|
69
|
+
- [Sync PO](https://intlayer.org/doc/plugin/sync-po.md)
|
|
70
|
+
|
|
71
|
+
### Migration Guides
|
|
72
|
+
|
|
73
|
+
- [Compat Adapters Overview](https://intlayer.org/doc/compatibility.md)
|
|
74
|
+
- [i18next](https://intlayer.org/doc/compatibility/i18next.md)
|
|
75
|
+
- [react-i18next](https://intlayer.org/doc/compatibility/react-i18next.md)
|
|
76
|
+
- [next-i18next](https://intlayer.org/doc/compatibility/next-i18next.md)
|
|
77
|
+
- [next-intl](https://intlayer.org/doc/compatibility/next-intl.md)
|
|
78
|
+
- [React Intl](https://intlayer.org/doc/compatibility/react-intl.md)
|
|
79
|
+
- [Vue I18n](https://intlayer.org/doc/compatibility/vue-i18n.md)
|
|
80
|
+
- [Lingui](https://intlayer.org/doc/compatibility/lingui.md)
|
|
81
|
+
- [NuxtJS I18n](https://intlayer.org/doc/compatibility/nuxtjs-i18n.md)
|
|
82
|
+
- [NGX Translate](https://intlayer.org/doc/compatibility/ngx-translate.md)
|
|
83
|
+
- [Transloco](https://intlayer.org/doc/compatibility/transloco.md)
|
|
84
|
+
- [Svelte I18n](https://intlayer.org/doc/compatibility/svelte-i18n.md)
|
|
85
|
+
- [Next Translate](https://intlayer.org/doc/compatibility/next-translate.md)
|
|
86
|
+
- [Polyglot.js](https://intlayer.org/doc/compatibility/polyglot.md)
|
|
87
|
+
- [i18n-js](https://intlayer.org/doc/compatibility/i18n-js.md)
|
|
@@ -22,11 +22,21 @@ The **Intlayer Compiler Skill** provides instructions on how to set up and use t
|
|
|
22
22
|
|
|
23
23
|
## Setup and Usage
|
|
24
24
|
|
|
25
|
-
To set up the Intlayer compiler for your project, refer to the documentation
|
|
25
|
+
To set up the Intlayer compiler for your project (Vite, Next.js, Babel, Webpack), refer to the documentation:
|
|
26
26
|
|
|
27
|
-
- [
|
|
28
|
-
|
|
27
|
+
- [Intlayer Compiler](https://intlayer.org/doc/compiler.md)
|
|
28
|
+
|
|
29
|
+
- **Vite** (React, Preact, Solid, Lit, Vue, Svelte, Astro): bundled into the `intlayer()` plugin of `vite-intlayer`.
|
|
30
|
+
- **Next.js**: install `@intlayer/babel`; `withIntlayer` registers the extractor loader on Turbopack and webpack.
|
|
31
|
+
- **Babel / Webpack**: add `intlayerExtractBabelPlugin` from `@intlayer/babel`.
|
|
32
|
+
- `.vue` and `.svelte` files additionally require `@intlayer/vue-compiler` / `@intlayer/svelte-compiler`.
|
|
33
|
+
- Not using a supported bundler? Run `npx intlayer extract` instead.
|
|
29
34
|
|
|
30
35
|
Once the compiler plugins are properly configured, simply write your translatable strings inline according to the framework's specifics, and the Intlayer compiler will automatically generate the dictionaries.
|
|
31
36
|
|
|
32
|
-
For more information, visit the [Intlayer Compiler Architecture Documentation](https://intlayer.org/doc/compiler).
|
|
37
|
+
For more information, visit the [Intlayer Compiler Architecture Documentation](https://intlayer.org/doc/compiler.md).
|
|
38
|
+
|
|
39
|
+
### Packages
|
|
40
|
+
|
|
41
|
+
- [vite-intlayer intlayerCompiler](https://intlayer.org/doc/packages/vite-intlayer/intlayerCompiler.md)
|
|
42
|
+
- [@intlayer/babel Exports](https://intlayer.org/doc/packages/@intlayer/babel/export.md)
|
|
@@ -18,7 +18,7 @@ Configure Intlayer project settings and environment variables. Check these files
|
|
|
18
18
|
|
|
19
19
|
Supported configuration files:
|
|
20
20
|
|
|
21
|
-
- `intlayer.config.{ts|js|json|json5|jsonc
|
|
21
|
+
- `intlayer.config.{ts|js|cjs|mjs|json|json5|jsonc}`
|
|
22
22
|
- `.intlayerrc`
|
|
23
23
|
|
|
24
24
|
It acts as the central brain for your application's internationalization strategy. It is divided into several specialized sections that control everything from language support to AI-powered translations.
|
|
@@ -49,6 +49,20 @@ Manages how and where your translation files are handled.
|
|
|
49
49
|
|
|
50
50
|
Settings for the visual workflow and internal plumbing.
|
|
51
51
|
|
|
52
|
+
## Retrieving configuration into your app
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
import { defaultLocale, getConfiguration, locales } from "intlayer";
|
|
56
|
+
|
|
57
|
+
console.log(locales); // ['en', 'fr', ...]
|
|
58
|
+
console.log(defaultLocale); // 'en'
|
|
59
|
+
|
|
60
|
+
// Other sections: internationalization, routing, editor, content, log
|
|
61
|
+
const { routing } = getConfiguration();
|
|
62
|
+
|
|
63
|
+
console.log(routing.mode); // 'prefix-no-default'
|
|
64
|
+
```
|
|
65
|
+
|
|
52
66
|
## References
|
|
53
67
|
|
|
54
68
|
- [Website](https://intlayer.org)
|
|
@@ -57,7 +71,3 @@ Settings for the visual workflow and internal plumbing.
|
|
|
57
71
|
### Concepts
|
|
58
72
|
|
|
59
73
|
- [Configuration](https://intlayer.org/doc/concept/configuration.md)
|
|
60
|
-
|
|
61
|
-
### Packages
|
|
62
|
-
|
|
63
|
-
- [Intlayer getConfiguration](https://intlayer.org/doc/packages/intlayer/getConfiguration.md)
|
|
@@ -34,12 +34,12 @@ const content = t({
|
|
|
34
34
|
|
|
35
35
|
Find locales to declare in config file. Supported configuration files:
|
|
36
36
|
|
|
37
|
-
- `intlayer.config.{ts|js|json|json5|jsonc|
|
|
37
|
+
- `intlayer.config.{ts|js|cjs|mjs|json|json5|jsonc|md|mdx|yml|yaml}`
|
|
38
38
|
- `.intlayerrc`
|
|
39
39
|
|
|
40
40
|
## Enumeration (`enu`)
|
|
41
41
|
|
|
42
|
-
Map content to
|
|
42
|
+
Map content to custom numeric values or ranges (`<5`, `>=10`). For grammatical plural forms, use `plural` instead.
|
|
43
43
|
|
|
44
44
|
[Doc](https://intlayer.org/doc/concept/content/enumeration.md)
|
|
45
45
|
|
|
@@ -54,6 +54,33 @@ const carCount = enu({
|
|
|
54
54
|
});
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
+
## Plural (`plural`)
|
|
58
|
+
|
|
59
|
+
Select the grammatical plural form from a count, using the CLDR categories (`zero`, `one`, `two`, `few`, `many`, `other`) of the active locale. `other` is required and used as fallback.
|
|
60
|
+
|
|
61
|
+
[Doc](https://intlayer.org/doc/concept/content/plural.md)
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
import { plural, t } from "intlayer";
|
|
65
|
+
|
|
66
|
+
const totalOpenings = t({
|
|
67
|
+
en: plural({
|
|
68
|
+
one: "{{count}} opening",
|
|
69
|
+
other: "{{count}} openings",
|
|
70
|
+
}),
|
|
71
|
+
ru: plural({
|
|
72
|
+
one: "{{count}} вакансия",
|
|
73
|
+
few: "{{count}} вакансии",
|
|
74
|
+
many: "{{count}} вакансий",
|
|
75
|
+
other: "{{count}} вакансий",
|
|
76
|
+
}),
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// Usage: totalOpenings(3) or totalOpenings({ count: 3, name: "Alice" })
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
> `plural` must be the leaf: wrap it in `t()`, never put `t()` inside `plural()`.
|
|
83
|
+
|
|
57
84
|
## Condition (`cond`)
|
|
58
85
|
|
|
59
86
|
Define content based on a boolean condition.
|
|
@@ -165,7 +192,37 @@ const greeting = gender({
|
|
|
165
192
|
});
|
|
166
193
|
```
|
|
167
194
|
|
|
168
|
-
|
|
195
|
+
## Select (`select`)
|
|
196
|
+
|
|
197
|
+
Map any string value (status, plan, role…) to content: the equivalent of an ICU `select` or a `switch`. Without `fallback`, only the declared cases are type-accepted.
|
|
198
|
+
|
|
199
|
+
[Doc](https://intlayer.org/doc/concept/content/select.md)
|
|
200
|
+
|
|
201
|
+
```typescript
|
|
202
|
+
import { select } from "intlayer";
|
|
203
|
+
|
|
204
|
+
const publishStatus = select({
|
|
205
|
+
draft: "This post is a draft",
|
|
206
|
+
published: "This post is live",
|
|
207
|
+
fallback: "Unknown status", // Optional
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
// Usage: publishStatus(post.status)
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
> Prefer `select()` over indexing a plain object (`content[status]`): dynamic property access prevents the compiler from pruning and minifying the content.
|
|
214
|
+
|
|
215
|
+
### Choosing a node by discriminant
|
|
216
|
+
|
|
217
|
+
| Discriminant | Node |
|
|
218
|
+
| ------------------------ | ---------- |
|
|
219
|
+
| A count (grammar) | `plural()` |
|
|
220
|
+
| A number / custom ranges | `enu()` |
|
|
221
|
+
| A boolean | `cond()` |
|
|
222
|
+
| A gender | `gender()` |
|
|
223
|
+
| Any other string value | `select()` |
|
|
224
|
+
|
|
225
|
+
## Example Directory Structure (react)
|
|
169
226
|
|
|
170
227
|
```
|
|
171
228
|
src/
|
|
@@ -357,14 +414,14 @@ Core Metadata
|
|
|
357
414
|
|
|
358
415
|
Content & Localization
|
|
359
416
|
|
|
360
|
-
- locale: Specifies the language of the content for
|
|
417
|
+
- locale: Specifies the language of the content for a [per-locale file](https://intlayer.org/doc/concept/per-locale-file.md)
|
|
361
418
|
- contentAutoTransformation: A toggle to automatically convert raw strings into specialized formats like Markdown, HTML, or Insertions (variables).
|
|
362
419
|
- fill: An instruction indicating whether the dictionary should be automatically populated by AI/automation tools.
|
|
363
420
|
|
|
364
421
|
Behaviorals Settings
|
|
365
422
|
|
|
366
423
|
- priority: A numeric value used to resolve conflicts during merge of dictionaries under a same key.
|
|
367
|
-
- importMode: Defines how content is loaded (`static`, `dynamic`, or `
|
|
424
|
+
- importMode: Defines how content is loaded (`static`, `dynamic`, or `fetch`). AI can recommend the best mode based on performance needs.
|
|
368
425
|
- location: Controls CMS synchronization (`hybrid`, `remote`, `local`). AI can manage where the source of truth resides.
|
|
369
426
|
- schema: string that use zod schema declared in config file to validate data
|
|
370
427
|
|
|
@@ -373,5 +430,22 @@ Behaviorals Settings
|
|
|
373
430
|
- [Website](https://intlayer.org)
|
|
374
431
|
- [Doc](https://intlayer.org/doc)
|
|
375
432
|
|
|
376
|
-
|
|
433
|
+
### Content Nodes
|
|
434
|
+
|
|
435
|
+
- [Content File](https://intlayer.org/doc/concept/content.md)
|
|
436
|
+
- [Translation](https://intlayer.org/doc/concept/content/translation.md)
|
|
437
|
+
- [Enumeration](https://intlayer.org/doc/concept/content/enumeration.md)
|
|
438
|
+
- [Plural](https://intlayer.org/doc/concept/content/plural.md)
|
|
439
|
+
- [Condition](https://intlayer.org/doc/concept/content/condition.md)
|
|
440
|
+
- [Gender](https://intlayer.org/doc/concept/content/gender.md)
|
|
441
|
+
- [Select](https://intlayer.org/doc/concept/content/select.md)
|
|
442
|
+
- [Insertion](https://intlayer.org/doc/concept/content/insertion.md)
|
|
443
|
+
- [Markdown](https://intlayer.org/doc/concept/content/markdown.md)
|
|
444
|
+
- [HTML](https://intlayer.org/doc/concept/content/html.md)
|
|
445
|
+
- [Nesting](https://intlayer.org/doc/concept/content/nesting.md)
|
|
446
|
+
- [File](https://intlayer.org/doc/concept/content/file.md)
|
|
447
|
+
- [Function Fetching](https://intlayer.org/doc/concept/content/function-fetching.md)
|
|
448
|
+
|
|
449
|
+
### Packages
|
|
450
|
+
|
|
377
451
|
- [Exports intlayer package](https://intlayer.org/doc/packages/intlayer/exports.md)
|