@intlayer/ngx-translate 9.5.10
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 +329 -0
- package/dist/esm/esbuild/index.mjs +43 -0
- package/dist/esm/esbuild/index.mjs.map +1 -0
- package/dist/esm/handlers.mjs +116 -0
- package/dist/esm/handlers.mjs.map +1 -0
- package/dist/esm/index.mjs +11 -0
- package/dist/esm/partialDeclarations.mjs +0 -0
- package/dist/esm/plugin/index.mjs +49 -0
- package/dist/esm/plugin/index.mjs.map +1 -0
- package/dist/esm/providers.mjs +53 -0
- package/dist/esm/providers.mjs.map +1 -0
- package/dist/esm/registryLookup.mjs +52 -0
- package/dist/esm/registryLookup.mjs.map +1 -0
- package/dist/esm/standalone.mjs +27 -0
- package/dist/esm/standalone.mjs.map +1 -0
- package/dist/esm/translateBlockDirective.mjs +47 -0
- package/dist/esm/translateBlockDirective.mjs.map +1 -0
- package/dist/esm/translateDirective.mjs +66 -0
- package/dist/esm/translateDirective.mjs.map +1 -0
- package/dist/esm/translatePipe.mjs +60 -0
- package/dist/esm/translatePipe.mjs.map +1 -0
- package/dist/esm/translateService.mjs +224 -0
- package/dist/esm/translateService.mjs.map +1 -0
- package/dist/esm/translateStore.mjs +53 -0
- package/dist/esm/translateStore.mjs.map +1 -0
- package/dist/esm/types.mjs +0 -0
- package/dist/esm/util.mjs +44 -0
- package/dist/esm/util.mjs.map +1 -0
- package/dist/types/esbuild/index.d.ts +23 -0
- package/dist/types/esbuild/index.d.ts.map +1 -0
- package/dist/types/handlers.d.ts +52 -0
- package/dist/types/handlers.d.ts.map +1 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/partialDeclarations.d.ts +18 -0
- package/dist/types/partialDeclarations.d.ts.map +1 -0
- package/dist/types/plugin/index.d.ts +25 -0
- package/dist/types/plugin/index.d.ts.map +1 -0
- package/dist/types/providers.d.ts +22 -0
- package/dist/types/providers.d.ts.map +1 -0
- package/dist/types/registryLookup.d.ts +13 -0
- package/dist/types/registryLookup.d.ts.map +1 -0
- package/dist/types/standalone.d.ts +24 -0
- package/dist/types/standalone.d.ts.map +1 -0
- package/dist/types/translateBlockDirective.d.ts +23 -0
- package/dist/types/translateBlockDirective.d.ts.map +1 -0
- package/dist/types/translateDirective.d.ts +33 -0
- package/dist/types/translateDirective.d.ts.map +1 -0
- package/dist/types/translatePipe.d.ts +21 -0
- package/dist/types/translatePipe.d.ts.map +1 -0
- package/dist/types/translateService.d.ts +106 -0
- package/dist/types/translateService.d.ts.map +1 -0
- package/dist/types/translateStore.d.ts +21 -0
- package/dist/types/translateStore.d.ts.map +1 -0
- package/dist/types/types.d.ts +56 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/util.d.ts +22 -0
- package/dist/types/util.d.ts.map +1 -0
- package/package.json +115 -0
package/README.md
ADDED
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://intlayer.org" rel="">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/aymericzip/intlayer/main/docs/assets/cover.webp" width="60%" alt="Intlayer Logo" />
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<h1 align="center">
|
|
8
|
+
<strong>Per-component i18n</strong>
|
|
9
|
+
</h1>
|
|
10
|
+
|
|
11
|
+
<h2 align="center">
|
|
12
|
+
<strong>AI-powered translation. Visual Editor. Multilingual CMS.</strong>
|
|
13
|
+
</h2>
|
|
14
|
+
|
|
15
|
+
<br />
|
|
16
|
+
|
|
17
|
+
<p align="center">
|
|
18
|
+
<a href="https://intlayer.org/doc/concept/content" rel="">Docs</a> •
|
|
19
|
+
<a href="https://intlayer.org/doc/environment/nextjs" rel="">Next.js</a> •
|
|
20
|
+
<a href="https://intlayer.org/doc/environment/vite-and-react" rel="">React + Vite</a> •
|
|
21
|
+
<a href="https://intlayer.org/doc/concept/cms" rel="">CMS</a> •
|
|
22
|
+
<a href="https://discord.gg/7uxamYVeCk" rel="noopener noreferrer nofollow">Discord</a>
|
|
23
|
+
</p>
|
|
24
|
+
<p align="center" style="margin-top:15px;">
|
|
25
|
+
<a href="https://www.npmjs.com/package/intlayer" target="_blank" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/npm/v/intlayer?style=for-the-badge&labelColor=FFFFFF&color=000000&logoColor=FFFFFF" alt="npm version" height="24"/></a>
|
|
26
|
+
<a href="https://github.com/aymericzip/intlayer/stargazers" target="_blank" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/github/stars/aymericzip/intlayer?style=for-the-badge&labelColor=000000&color=FFFFFF&logo=github&logoColor=FFD700" alt="GitHub Stars" height="24"/></a>
|
|
27
|
+
<a href="https://www.npmjs.org/package/intlayer" target="_blank" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/npm/dm/intlayer?style=for-the-badge&labelColor=000000&color=FFFFFF&logoColor=000000&cacheSeconds=86400" alt="monthly downloads" height="24"/></a>
|
|
28
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/LICENSE" target="_blank" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/github/license/aymericzip/intlayer?style=for-the-badge&labelColor=000000&color=FFFFFF&logoColor=000000&cacheSeconds=86400" alt="license"/></a>
|
|
29
|
+
<a href="https://github.com/aymericzip/intlayer/commits/main" target="_blank" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/github/last-commit/aymericzip/intlayer?style=for-the-badge&labelColor=000000&color=FFFFFF&logoColor=000000&cacheSeconds=86400" alt="last commit"/>
|
|
30
|
+
</a>
|
|
31
|
+
</p>
|
|
32
|
+
|
|
33
|
+

|
|
34
|
+
|
|
35
|
+
<a href="https://intlayer.org/doc/concept/content" rel="">
|
|
36
|
+
<img src="https://img.shields.io/badge/Get_Started-FFFFFF?style=for-the-badge&logo=rocket&logoColor=black" />
|
|
37
|
+
</a>
|
|
38
|
+
|
|
39
|
+
## What is Intlayer?
|
|
40
|
+
|
|
41
|
+
Most i18n libraries are either too complex, too rigid, or not built for modern frameworks.
|
|
42
|
+
|
|
43
|
+
Intlayer is a **modern i18n solution** for web and mobile apps.
|
|
44
|
+
It’s framework-agnostic, **AI-powered**, and includes a free **CMS & visual editor**.
|
|
45
|
+
|
|
46
|
+
With **per-locale content files**, **TypeScript autocompletion**, **tree-shakable dictionaries**, and **CI/CD integration**, Intlayer makes internationalization **faster, cleaner, and smarter**.
|
|
47
|
+
|
|
48
|
+
## Keys benefits of Intlayer:
|
|
49
|
+
|
|
50
|
+
| Feature | Description |
|
|
51
|
+
| --------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
52
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/frameworks.webp?raw=true" alt="Feature" width="700"> | **Cross-Frameworks Support**<br><br>Intlayer is compatible with all major frameworks and libraries, including Next.js, React, Vite, Vue.js, Nuxt, Preact, Express, and more. |
|
|
53
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/javascript_content_management.jpg?raw=true" alt="Feature" width="700"> | **JavaScript-Powered Content Management**<br><br>Harness the flexibility of JavaScript to define and manage your content efficiently. <br><br> - [Content declaration](https://intlayer.org/doc/concept/content) |
|
|
54
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/per_locale_content_declaration_file.png?raw=true" alt="Feature" width="700"> | **Per-Locale Content Declaration File**<br><br>Speed up your development by declaring your content once, before auto generation.<br><br> - [Per-Locale Content Declaration File](https://intlayer.org/doc/concept/per-locale-file) |
|
|
55
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/compiler.webp?raw=true" alt="Feature" width="700"> | **Compiler**<br><br>The Intlayer Compiler extract automatically the content from the components and generate the dictionary files.<br><br> - [Compiler](https://intlayer.org/doc/compiler) |
|
|
56
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true" alt="Feature" width="700"> | **Type-Safe Environment**<br><br>Leverage TypeScript to ensure your content definitions and code are error-free, while also benefiting from IDE autocompletion.<br><br> - [TypeScript configuration](https://intlayer.org/doc/environment/vite-and-react#configure-typescript) |
|
|
57
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/config_file.png?raw=true" alt="Feature" width="700"> | **Simplified Setup**<br><br>Get up and running quickly with minimal configuration. Adjust settings for internationalization, routing, AI, build, and content handling with ease. <br><br> - [Explore Next.js integration](https://intlayer.org/doc/environment/nextjs) |
|
|
58
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/content_retrieval.png?raw=true" alt="Feature" width="700"> | **Simplified Content Retrieval**<br><br>No need to call your `t` function for each piece of content. Retrieve all your content directly using a single hook.<br><br> - [React integration](https://intlayer.org/doc/environment/create-react-app) |
|
|
59
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/server_component.png?raw=true" alt="Feature" width="700"> | **Consistent Server Component Implementation**<br><br>Perfectly suited for Next.js server components, use the same implementation for both client and server components, no need to pass your `t` function across each server component. <br><br> - [Server Components](https://intlayer.org/doc/environment/nextjs#step-7-utilize-content-in-your-code) |
|
|
60
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/file_tree.png?raw=true" alt="Feature" width="700"> | **Organized Codebase**<br><br>Keep your codebase more organized: 1 component = 1 dictionary in the same folder. Translations close to their respective components, enhance maintainability and clarity. <br><br> - [How Intlayer works](https://intlayer.org/doc/concept/how-works-intlayer) |
|
|
61
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/url_routing.png?raw=true" alt="Feature" width="700"> | **Enhanced Routing**<br><br>Full support of app routing, adapting seamlessly to complex application structures, for Next.js, React, Vite, Vue.js, etc.<br><br> - [Explore Next.js integration](https://intlayer.org/doc/environment/nextjs) |
|
|
62
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/markdown.png?raw=true" alt="Feature" width="700"> | **Markdown Support**<br><br>Import and interpret, locale files and remote Markdown for multilingual content like privacy policies, documentation, etc. Interpret and make Markdown metadata accessible in your code.<br><br> - [Content files](https://intlayer.org/doc/concept/content/file) |
|
|
63
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/visual_editor.webp?raw=true" alt="Feature" width="700"> | **Free Visual Editor & CMS**<br><br>A free visual editor and CMS are available for content writers, removing the need for a localization platform. Keep your content synchronized using Git, or externalize it totally or partially with the CMS.<br><br> - [Intlayer Editor](https://intlayer.org/doc/concept/editor) <br> - [Intlayer CMS](https://intlayer.org/doc/concept/cms) |
|
|
64
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/bundle.webp?raw=true" alt="Feature" width="700"> | **Tree-shakable Content**<br><br>Tree-shakable content, reducing the size of the final bundle. Loads content per component, excluding any unused content from your bundle. Supports lazy loading to enhance app loading efficiency. <br><br> - [App build optimization](https://intlayer.org/doc/concept/how-works-intlayer#app-build-optimization) |
|
|
65
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/static_rendering.webp?raw=true" alt="Feature" width="700"> | **Static Rendering**<br><br>Doesn't block Static Rendering. <br><br> - [Next.js integration](https://intlayer.org/doc/environment/nextjs) |
|
|
66
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/AI_translation.png?raw=true" alt="Feature" width="700"> | **AI-Powered Translation**<br><br>Transform your website into 231 languages with just one click using Intlayer's advanced AI-powered translation tools using your own AI provider / API key. <br><br> - [CI/CD integration](https://intlayer.org/doc/concept/ci-cd) <br> - [Intlayer CLI](https://intlayer.org/doc/concept/cli) <br> - [Auto fill](https://intlayer.org/doc/concept/auto-fill) |
|
|
67
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/mcp.png?raw=true" alt="Feature" width="700"> | **MCP Server Integration**<br><br>Provides an MCP (Model Context Protocol) server for IDE automation, enabling seamless content management and i18n workflows directly within your development environment. <br><br> - [MCP Server](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/mcp_server.md) |
|
|
68
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/vscode_extension.webp?raw=true" alt="Feature" width="700"> | **VSCode Extension**<br><br>Intlayer provides a VSCode extension to help you manage your content and translations, building your dictionaries, translating your content, and more. <br><br> - [VSCode Extension](https://intlayer.org/doc/vs-code-extension) |
|
|
69
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/interoperability.png?raw=true" alt="Feature" width="700"> | **Interoperability**<br><br>Allow interoperability with react-i18next, next-i18next, next-intl, react-intl, vue-i18n. <br><br> - [Intlayer and react-intl](https://intlayer.org/blog/intlayer-with-react-intl) <br> - [Intlayer and next-intl](https://intlayer.org/blog/intlayer-with-next-intl) <br> - [Intlayer and next-i18next](https://intlayer.org/blog/intlayer-with-next-i18next) <br> - [Intlayer and vue-i18n](https://intlayer.org/blog/intlayer-with-vue-i18n) <br> - [Intlayer compat adapters](https://intlayer.org/doc/compatibility) |
|
|
70
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/benchmark.png?raw=true" alt="Feature" width="700"> | **Performances & Benchmark**<br><br>Uses advanced tree-shaking and dynamic loading to boost performances and keep the solution as light as possible. <br><br> - [Performances & Benchmark](https://intlayer.org/doc/benchmark) |
|
|
71
|
+
|
|
72
|
+
## 📦 Installation
|
|
73
|
+
|
|
74
|
+
Start your journey with Intlayer today and experience a smoother, more powerful approach to internationalization.
|
|
75
|
+
|
|
76
|
+
<a href="https://intlayer.org/doc/concept/content" rel="">
|
|
77
|
+
<img src="https://img.shields.io/badge/Get_Started-FFFFFF?style=for-the-badge&logo=rocket&logoColor=black" />
|
|
78
|
+
</a>
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
npm install intlayer react-intlayer
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
⚡ Quick Start (Next.js)
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
// intlayer.config.ts
|
|
88
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
89
|
+
|
|
90
|
+
const config: IntlayerConfig = {
|
|
91
|
+
internationalization: {
|
|
92
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
93
|
+
defaultLocale: Locales.ENGLISH,
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export default config;
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
// app/home.content.ts
|
|
102
|
+
import { t, type Dictionary } from "intlayer";
|
|
103
|
+
|
|
104
|
+
const content = {
|
|
105
|
+
key: "home",
|
|
106
|
+
content: {
|
|
107
|
+
title: t({
|
|
108
|
+
en: "Home",
|
|
109
|
+
fr: "Accueil",
|
|
110
|
+
es: "Inicio",
|
|
111
|
+
}),
|
|
112
|
+
},
|
|
113
|
+
} satisfies Dictionary;
|
|
114
|
+
|
|
115
|
+
export default content;
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
// app/page.tsx
|
|
120
|
+
import { useIntlayer } from "react-intlayer";
|
|
121
|
+
|
|
122
|
+
const HomePage = () => {
|
|
123
|
+
const { title } = useIntlayer("home");
|
|
124
|
+
|
|
125
|
+
return <h1>{title}</h1>;
|
|
126
|
+
};
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
<a href="https://intlayer.org/doc/environment/nextjs"> Get the full guide → </a>
|
|
130
|
+
|
|
131
|
+
## 🎥 Live tutorial on YouTube
|
|
132
|
+
|
|
133
|
+
[](https://youtu.be/e_PPG7PTqGU?si=GyU_KpVhr61razRw)
|
|
134
|
+
|
|
135
|
+
<a href="https://intlayer.org/doc/concept/content" rel="">
|
|
136
|
+
<img src="https://img.shields.io/badge/Get_Started-FFFFFF?style=for-the-badge&logo=rocket&logoColor=black" />
|
|
137
|
+
</a>
|
|
138
|
+
|
|
139
|
+
## Table of Contents
|
|
140
|
+
|
|
141
|
+
Explore our comprehensive documentation to get started with Intlayer and learn how to integrate it into your projects.
|
|
142
|
+
|
|
143
|
+
<details open>
|
|
144
|
+
<summary style="font-size:16px; font-weight:bold;">📘 Get Started</summary>
|
|
145
|
+
<ul>
|
|
146
|
+
<li><a href="https://intlayer.org/doc/why" rel=''>Why Intlayer?</a></li>
|
|
147
|
+
<li><a href="https://intlayer.org/doc" rel=''>Introduction</a></li>
|
|
148
|
+
</ul>
|
|
149
|
+
</details>
|
|
150
|
+
|
|
151
|
+
<details>
|
|
152
|
+
<summary style="font-size:16px; font-weight:bold;">⚙️ Concept</summary>
|
|
153
|
+
<ul>
|
|
154
|
+
<li><a href="https://intlayer.org/doc/concept/how-works-intlayer" rel=''>How Intlayer Works</a></li>
|
|
155
|
+
<li><a href="https://intlayer.org/doc/concept/configuration" rel=''>Configuration</a></li>
|
|
156
|
+
<li><a href="https://intlayer.org/doc/concept/cli" rel=''>Intlayer CLI</a></li>
|
|
157
|
+
<li><a href="https://intlayer.org/doc/compiler" rel=''>Compiler</a></li>
|
|
158
|
+
|
|
159
|
+
<li><a href="https://intlayer.org/doc/concept/editor" rel=''>Intlayer Editor</a></li>
|
|
160
|
+
<li><a href="https://intlayer.org/doc/concept/cms" rel=''>Intlayer CMS</a></li>
|
|
161
|
+
<li><a href="https://intlayer.org/doc/concept/content" rel=''>Dictionary</a>
|
|
162
|
+
<ul>
|
|
163
|
+
<li><a href="https://intlayer.org/doc/concept/per-locale-file" rel=''>Per-Locale Content Declaration File</a></li>
|
|
164
|
+
<li><a href="https://intlayer.org/doc/concept/content/translation" rel=''>Translation</a></li>
|
|
165
|
+
<li><a href="https://intlayer.org/doc/concept/content/enumeration" rel=''>Enumeration</a></li>
|
|
166
|
+
<li><a href="https://intlayer.org/doc/concept/content/condition" rel=''>Condition</a></li>
|
|
167
|
+
<li><a href="https://intlayer.org/doc/concept/content/nesting" rel=''>Nesting</a></li>
|
|
168
|
+
<li><a href="https://intlayer.org/doc/concept/content/markdown" rel=''>Markdown</a></li>
|
|
169
|
+
<li><a href="https://intlayer.org/doc/concept/content/function-fetching" rel=''>Function Fetching</a></li>
|
|
170
|
+
<li><a href="https://intlayer.org/doc/concept/content/insertion" rel=''>Insertion</a></li>
|
|
171
|
+
<li><a href="https://intlayer.org/doc/concept/content/file" rel=''>File</a></li>
|
|
172
|
+
</ul>
|
|
173
|
+
</li>
|
|
174
|
+
</ul>
|
|
175
|
+
</details>
|
|
176
|
+
|
|
177
|
+
<details open>
|
|
178
|
+
<summary style="font-size:16px; font-weight:bold;">🌐 Environment</summary>
|
|
179
|
+
<ul>
|
|
180
|
+
<li><a href="https://intlayer.org/doc/environment/nextjs" rel=''>Intlayer with Next.js 16</a>
|
|
181
|
+
<ul>
|
|
182
|
+
<li><a href="https://intlayer.org/doc/environment/nextjs/15" rel=''>Next.js 15</a></li>
|
|
183
|
+
<li><a href="https://intlayer.org/doc/environment/nextjs/14" rel=''>Next.js 14 (App Router)</a></li>
|
|
184
|
+
<li><a href="https://intlayer.org/doc/environment/nextjs/next-with-page-router" rel=''>Next.js Page Router</a></li>
|
|
185
|
+
<li><a href="https://intlayer.org/doc/environment/nextjs/compiler" rel=''>Next.js using Compiler</a></li>
|
|
186
|
+
</ul>
|
|
187
|
+
</li>
|
|
188
|
+
<li><a href="https://intlayer.org/doc/environment/create-react-app" rel=''>React CRA</a></li>
|
|
189
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-react" rel=''>Vite + React</a></li>
|
|
190
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-react" rel=''>Vite + React using Compiler</a></li>
|
|
191
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-react/react-router-v7" rel=''>React-router-v7</a></li>
|
|
192
|
+
<li><a href="https://intlayer.org/doc/environment/remix-3" rel=''>Remix 3</a></li>
|
|
193
|
+
<li><a href="https://intlayer.org/doc/environment/tanstack-start" rel=''>Tanstack start</a>
|
|
194
|
+
<ul>
|
|
195
|
+
<li><a href="https://intlayer.org/doc/environment/tanstack-start/solid" rel=''>Solid</a></li>
|
|
196
|
+
</ul>
|
|
197
|
+
</li>
|
|
198
|
+
<li><a href="https://intlayer.org/doc/environment/astro" rel=''>Astro</a>
|
|
199
|
+
<ul>
|
|
200
|
+
<li><a href="https://intlayer.org/doc/environment/astro/react" rel=''>React</a></li>
|
|
201
|
+
<li><a href="https://intlayer.org/doc/environment/astro/vue" rel=''>Vue</a></li>
|
|
202
|
+
<li><a href="https://intlayer.org/doc/environment/astro/svelte" rel=''>Svelte</a></li>
|
|
203
|
+
<li><a href="https://intlayer.org/doc/environment/astro/solid" rel=''>Solid</a></li>
|
|
204
|
+
<li><a href="https://intlayer.org/doc/environment/astro/lit" rel=''>Lit</a></li>
|
|
205
|
+
</ul>
|
|
206
|
+
</li>
|
|
207
|
+
|
|
208
|
+
<li><a href="https://intlayer.org/doc/environment/react-native-and-expo" rel=''>React Native</a></li>
|
|
209
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-svelte" rel=''>Vite + Svelte</a></li>
|
|
210
|
+
<li><a href="https://intlayer.org/doc/environment/sveltekit" rel=''>SvelteKit</a></li>
|
|
211
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-preact" rel=''>Vite + Preact</a></li>
|
|
212
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-vue" rel=''>Vite + Vue</a></li>
|
|
213
|
+
<li><a href="https://intlayer.org/doc/environment/nuxt-and-vue" rel=''>Vite + Nuxt</a></li>
|
|
214
|
+
<li><a href="https://intlayer.org/doc/environment/vite-and-solid" rel=''>Vite + Solid</a></li>
|
|
215
|
+
<li><a href="https://intlayer.org/doc/environment/solid-start" rel=''>Solid Start</a></li>
|
|
216
|
+
<li><a href="https://intlayer.org/doc/environment/angular" rel=''>Angular</a></li> <li>
|
|
217
|
+
<a href="https://intlayer.org/doc/environment/express" rel=''>Backend</a>
|
|
218
|
+
<ul>
|
|
219
|
+
<li><a href="https://intlayer.org/doc/environment/express" rel=''>Express</a></li>
|
|
220
|
+
<li><a href="https://intlayer.org/doc/environment/nest" rel=''>NestJS</a></li>
|
|
221
|
+
<li><a href="https://intlayer.org/doc/environment/fastify" rel=''>Fastify</a></li>
|
|
222
|
+
<li><a href="https://intlayer.org/doc/environment/adonisjs" rel=''>AdonisJS</a></li>
|
|
223
|
+
<li><a href="https://intlayer.org/doc/environment/hono" rel=''>Hono</a></li>
|
|
224
|
+
<li><a href="https://intlayer.org/doc/environment/elysia" rel=''>Elysia</a></li>
|
|
225
|
+
</ul>
|
|
226
|
+
</li>
|
|
227
|
+
</ul>
|
|
228
|
+
</details>
|
|
229
|
+
|
|
230
|
+
<details>
|
|
231
|
+
<summary style="font-size:16px; font-weight:bold;">📊 Benchmark</summary>
|
|
232
|
+
<ul>
|
|
233
|
+
<li><a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/benchmark/nextjs.md" rel=''>Next.js</a></li>
|
|
234
|
+
<li><a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/benchmark/tanstack.md" rel=''>TanStack Start</a></li>
|
|
235
|
+
<li><a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/benchmark/vue.md" rel=''>Vue</a></li>
|
|
236
|
+
<li><a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/benchmark/solid.md" rel=''>Solid</a></li>
|
|
237
|
+
<li><a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/benchmark/svelte.md" rel=''>Svelte</a></li>
|
|
238
|
+
</ul>
|
|
239
|
+
</details>
|
|
240
|
+
|
|
241
|
+
<details>
|
|
242
|
+
<summary style="font-size:16px; font-weight:bold;">📰 Blog</summary>
|
|
243
|
+
<ul>
|
|
244
|
+
<li><a href="https://github.com/aymericzip/intlayer/blob/main/docs/blog/en/what_is_internationalization.md" rel=''>What is i18n</a></li>
|
|
245
|
+
<li><a href="https://intlayer.org/blog/SEO-and-i18n" rel=''>i18n and SEO</a></li>
|
|
246
|
+
<li><a href="https://intlayer.org/blog/intlayer-with-next-i18next" rel=''>Intlayer and i18next</a></li>
|
|
247
|
+
<li><a href="https://intlayer.org/blog/intlayer-with-react-i18next" rel=''>Intlayer and react-intl</a></li>
|
|
248
|
+
<li><a href="https://intlayer.org/blog/intlayer-with-next-intl" rel=''>Intlayer and next-intl</a></li>
|
|
249
|
+
</ul>
|
|
250
|
+
</details>
|
|
251
|
+
|
|
252
|
+
## Multilingual content management system
|
|
253
|
+
|
|
254
|
+
More than an i18n library, Intlayer is a complete **multilingual content management system**. A full CMS is available for free at [app.intlayer.org](https://app.intlayer.org).
|
|
255
|
+
|
|
256
|
+
Intlayer connects **developers**, **copywriters**, and **AI agents** in one workflow for creating and maintaining multilingual websites effortlessly.Intlayer replaces the following stack in a single solution:
|
|
257
|
+
|
|
258
|
+
- i18n solutions (e.g. `i18next`, `next-intl`, `vue-i18n`)
|
|
259
|
+
- TMSs (Translation Management Systems) (e.g. Crowdin, Phrase, Lokalise)
|
|
260
|
+
- Feature flags
|
|
261
|
+
- Headless CMSs (e.g. Contentful, Strapi, Sanity)
|
|
262
|
+
|
|
263
|
+

|
|
264
|
+
|
|
265
|
+
## 🌐 Readme in other languages
|
|
266
|
+
|
|
267
|
+
<p align="center">
|
|
268
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/readme.md">English</a> •
|
|
269
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh/readme.md">简体中文</a> •
|
|
270
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/ru/readme.md">Русский</a> •
|
|
271
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/readme.md">日本語</a> •
|
|
272
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/readme.md">Français</a> •
|
|
273
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/ko/readme.md">한국어</a> •
|
|
274
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/readme.md">Español</a> •
|
|
275
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/de/readme.md">Deutsch</a> •
|
|
276
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/readme.md">العربية</a> •
|
|
277
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/readme.md">Italiano</a> •
|
|
278
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/readme.md">English (UK)</a> •
|
|
279
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/readme.md">Português</a> •
|
|
280
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/readme.md">हिन्दी</a> •
|
|
281
|
+
<a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/tr/readme.md">Türkçe</a>
|
|
282
|
+
</p>
|
|
283
|
+
|
|
284
|
+
## 🤝 Community
|
|
285
|
+
|
|
286
|
+
Intlayer is built with and for the community and we’d love your input!
|
|
287
|
+
|
|
288
|
+
- Have a suggestion? [Open an issue](https://github.com/aymericzip/intlayer/issues)
|
|
289
|
+
- Found a bug or improvement? [Submit a PR](https://github.com/aymericzip/intlayer/pulls)
|
|
290
|
+
- Need help or want to connect? [Join our Discord](https://discord.gg/7uxamYVeCk)
|
|
291
|
+
|
|
292
|
+
You can also follow us on :
|
|
293
|
+
|
|
294
|
+
<div>
|
|
295
|
+
<br/>
|
|
296
|
+
<p align="center">
|
|
297
|
+
<a href="https://discord.gg/528mBV4N" target="blank" rel='noopener noreferrer nofollow'><img align="center"
|
|
298
|
+
src="https://img.shields.io/badge/discord-5865F2.svg?style=for-the-badge&logo=discord&logoColor=white"
|
|
299
|
+
alt="Intlayer Discord" height="30"/></a>
|
|
300
|
+
<a href="https://www.linkedin.com/company/intlayerorg" target="blank" rel='noopener noreferrer nofollow'><img align="center"
|
|
301
|
+
src="https://img.shields.io/badge/linkedin-%231DA1F2.svg?style=for-the-badge&logo=linkedin&logoColor=white"
|
|
302
|
+
alt="Intlayer LinkedIn" height="30"/></a>
|
|
303
|
+
<a href="https://www.instagram.com/intlayer/" target="blank" rel='noopener noreferrer nofollow'><img align="center"
|
|
304
|
+
src="https://img.shields.io/badge/instagram-%23E4405F.svg?style=for-the-badge&logo=Instagram&logoColor=white"
|
|
305
|
+
alt="Intlayer Instagram" height="30"/></a>
|
|
306
|
+
<a href="https://x.com/Intlayer183096" target="blank" rel='noopener noreferrer nofollow'><img align="center"
|
|
307
|
+
src="https://img.shields.io/badge/x-1DA1F2.svg?style=for-the-badge&logo=x&logoColor=white"
|
|
308
|
+
alt="Intlayer X" height="30"/></a>
|
|
309
|
+
<a href="https://www.youtube.com/@intlayer" target="blank" rel='noopener noreferrer nofollow'><img align="center"
|
|
310
|
+
src="https://img.shields.io/badge/youtube-FF0000.svg?style=for-the-badge&logo=youtube&logoColor=white"
|
|
311
|
+
alt="Intlayer YouTube" height="30"/></a>
|
|
312
|
+
<a href="https://www.tiktok.com/@intlayer" target="blank" rel='noopener noreferrer nofollow'><img align="center"
|
|
313
|
+
src="https://img.shields.io/badge/tiktok-000000.svg?style=for-the-badge&logo=tiktok&logoColor=white"
|
|
314
|
+
alt="Intlayer TikTok" height="30"/></a>
|
|
315
|
+
<br>
|
|
316
|
+
</p>
|
|
317
|
+
</div>
|
|
318
|
+
|
|
319
|
+
### Contribution
|
|
320
|
+
|
|
321
|
+
For more detailed guidelines on contributing to this project, please refer to the [`CONTRIBUTING.md`](https://github.com/aymericzip/intlayer/blob/main/CONTRIBUTING.md) file. It contains essential information on our development process, commit message conventions, and release procedures. Your contributions are valuable to us, and we appreciate your efforts in making this project better!
|
|
322
|
+
|
|
323
|
+
Contribute on [GitHub](https://github.com/aymericzip/intlayer), [GitLab](https://gitlab.com/ay.pineau/intlayer), or [Bitbucket](https://bitbucket.org/intlayer/intlayer/).
|
|
324
|
+
|
|
325
|
+
### Thank You for the Support
|
|
326
|
+
|
|
327
|
+
If you like Intlayer, give us a ⭐ on GitHub. It helps others discover the project! [See why GitHub Stars matter](https://github.com/aymericzip/intlayer/blob/main/CONTRIBUTING.md#why-github-stars-matter-).
|
|
328
|
+
|
|
329
|
+
[](https://star-history.com/#aymericzip/intlayer&Date)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { intlayerEsbuildPlugin } from "angular-intlayer/esbuild";
|
|
2
|
+
|
|
3
|
+
//#region src/esbuild/index.ts
|
|
4
|
+
/** Imports rewritten to the adapter. */
|
|
5
|
+
const NGX_TRANSLATE_IMPORT_FILTER = /^@ngx-translate\/core$/;
|
|
6
|
+
/** The adapter module every `@ngx-translate/core` import resolves to. */
|
|
7
|
+
const ADAPTER_MODULE = "@intlayer/ngx-translate";
|
|
8
|
+
/**
|
|
9
|
+
* esbuild plugin for the Angular CLI (`@angular-builders/custom-esbuild`):
|
|
10
|
+
* sets up angular-intlayer's build integration and resolves
|
|
11
|
+
* `@ngx-translate/core` to `@intlayer/ngx-translate`.
|
|
12
|
+
*
|
|
13
|
+
* The redirect goes through `build.resolve`, so the adapter takes the same
|
|
14
|
+
* path as any intlayer package — including angular-intlayer's handling of
|
|
15
|
+
* the dev server, which would otherwise externalize it to Vite's
|
|
16
|
+
* pre-bundler.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* // esbuild/plugins.ts (referenced from angular.json "plugins")
|
|
21
|
+
* import { ngxTranslateEsbuildPlugin } from '@intlayer/ngx-translate/esbuild';
|
|
22
|
+
* export default [ngxTranslateEsbuildPlugin()];
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
const ngxTranslateEsbuildPlugin = (options) => {
|
|
26
|
+
const intlayerPlugin = intlayerEsbuildPlugin(options);
|
|
27
|
+
return {
|
|
28
|
+
name: "intlayer-ngx-translate",
|
|
29
|
+
async setup(build) {
|
|
30
|
+
await intlayerPlugin.setup(build);
|
|
31
|
+
build.onResolve({ filter: NGX_TRANSLATE_IMPORT_FILTER }, (args) => build.resolve(ADAPTER_MODULE, {
|
|
32
|
+
kind: args.kind,
|
|
33
|
+
importer: args.importer,
|
|
34
|
+
resolveDir: args.resolveDir,
|
|
35
|
+
pluginData: args.pluginData
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { ngxTranslateEsbuildPlugin as default, ngxTranslateEsbuildPlugin };
|
|
43
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/esbuild/index.ts"],"sourcesContent":["import {\n type EsbuildPlugin,\n type IntlayerEsbuildPluginOptions,\n intlayerEsbuildPlugin,\n} from 'angular-intlayer/esbuild';\n\n/** Imports rewritten to the adapter. */\nconst NGX_TRANSLATE_IMPORT_FILTER = /^@ngx-translate\\/core$/;\n\n/** The adapter module every `@ngx-translate/core` import resolves to. */\nconst ADAPTER_MODULE = '@intlayer/ngx-translate';\n\n/**\n * esbuild plugin for the Angular CLI (`@angular-builders/custom-esbuild`):\n * sets up angular-intlayer's build integration and resolves\n * `@ngx-translate/core` to `@intlayer/ngx-translate`.\n *\n * The redirect goes through `build.resolve`, so the adapter takes the same\n * path as any intlayer package — including angular-intlayer's handling of\n * the dev server, which would otherwise externalize it to Vite's\n * pre-bundler.\n *\n * @example\n * ```ts\n * // esbuild/plugins.ts (referenced from angular.json \"plugins\")\n * import { ngxTranslateEsbuildPlugin } from '@intlayer/ngx-translate/esbuild';\n * export default [ngxTranslateEsbuildPlugin()];\n * ```\n */\nexport const ngxTranslateEsbuildPlugin = (\n options?: IntlayerEsbuildPluginOptions\n): EsbuildPlugin => {\n const intlayerPlugin = intlayerEsbuildPlugin(options);\n\n return {\n name: 'intlayer-ngx-translate',\n\n async setup(build) {\n await intlayerPlugin.setup(build);\n\n build.onResolve({ filter: NGX_TRANSLATE_IMPORT_FILTER }, (args) =>\n build.resolve(ADAPTER_MODULE, {\n kind: args.kind,\n importer: args.importer,\n resolveDir: args.resolveDir,\n pluginData: args.pluginData,\n })\n );\n },\n };\n};\n\nexport default ngxTranslateEsbuildPlugin;\n"],"mappings":";;;;AAOA,MAAM,8BAA8B;;AAGpC,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;AAmBvB,MAAa,6BACX,YACkB;CAClB,MAAM,iBAAiB,sBAAsB,OAAO;CAEpD,OAAO;EACL,MAAM;EAEN,MAAM,MAAM,OAAO;GACjB,MAAM,eAAe,MAAM,KAAK;GAEhC,MAAM,UAAU,EAAE,QAAQ,4BAA4B,IAAI,SACxD,MAAM,QAAQ,gBAAgB;IAC5B,MAAM,KAAK;IACX,UAAU,KAAK;IACf,YAAY,KAAK;IACjB,YAAY,KAAK;GACnB,CAAC,CACH;EACF;CACF;AACF"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { getValue, isDefinedAndNotNull, isFunction, isString } from "./util.mjs";
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import { of } from "rxjs";
|
|
4
|
+
|
|
5
|
+
//#region src/handlers.ts
|
|
6
|
+
/** Handles a key missing from every translation source. */
|
|
7
|
+
var MissingTranslationHandler = class {};
|
|
8
|
+
/** Returns the key itself, ngx-translate's default. */
|
|
9
|
+
var DefaultMissingTranslationHandler = class DefaultMissingTranslationHandler {
|
|
10
|
+
handle(params) {
|
|
11
|
+
return params.key;
|
|
12
|
+
}
|
|
13
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
14
|
+
minVersion: "12.0.0",
|
|
15
|
+
version: "17.0.0",
|
|
16
|
+
ngImport: i0,
|
|
17
|
+
type: DefaultMissingTranslationHandler,
|
|
18
|
+
deps: [],
|
|
19
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
20
|
+
});
|
|
21
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
22
|
+
minVersion: "12.0.0",
|
|
23
|
+
version: "17.0.0",
|
|
24
|
+
ngImport: i0,
|
|
25
|
+
type: DefaultMissingTranslationHandler
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
/** Compiles runtime translations registered through `setTranslation()`. */
|
|
29
|
+
var TranslateCompiler = class {};
|
|
30
|
+
var TranslateNoOpCompiler = class TranslateNoOpCompiler extends TranslateCompiler {
|
|
31
|
+
compile(value, _lang) {
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
compileTranslations(translations, _lang) {
|
|
35
|
+
return translations;
|
|
36
|
+
}
|
|
37
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
38
|
+
minVersion: "12.0.0",
|
|
39
|
+
version: "17.0.0",
|
|
40
|
+
ngImport: i0,
|
|
41
|
+
type: TranslateNoOpCompiler,
|
|
42
|
+
deps: [],
|
|
43
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
44
|
+
});
|
|
45
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
46
|
+
minVersion: "12.0.0",
|
|
47
|
+
version: "17.0.0",
|
|
48
|
+
ngImport: i0,
|
|
49
|
+
type: TranslateNoOpCompiler
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Loads runtime translations for a language. Intlayer dictionaries need no
|
|
54
|
+
* loader; one is only called for catalogs kept outside intlayer.
|
|
55
|
+
*/
|
|
56
|
+
var TranslateLoader = class {};
|
|
57
|
+
var TranslateNoOpLoader = class TranslateNoOpLoader extends TranslateLoader {
|
|
58
|
+
getTranslation(_lang) {
|
|
59
|
+
return of({});
|
|
60
|
+
}
|
|
61
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
62
|
+
minVersion: "12.0.0",
|
|
63
|
+
version: "17.0.0",
|
|
64
|
+
ngImport: i0,
|
|
65
|
+
type: TranslateNoOpLoader,
|
|
66
|
+
deps: [],
|
|
67
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
68
|
+
});
|
|
69
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
70
|
+
minVersion: "12.0.0",
|
|
71
|
+
version: "17.0.0",
|
|
72
|
+
ngImport: i0,
|
|
73
|
+
type: TranslateNoOpLoader
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
/** Interpolates parameters into a translation. */
|
|
77
|
+
var TranslateParser = class {};
|
|
78
|
+
/** `{{ name }}` / `{{ user.name }}` interpolation, like ngx-translate. */
|
|
79
|
+
var TranslateDefaultParser = class TranslateDefaultParser extends TranslateParser {
|
|
80
|
+
templateMatcher = /{{\s?([^{}\s]*)\s?}}/g;
|
|
81
|
+
interpolate(expression, params) {
|
|
82
|
+
if (isString(expression)) return this.interpolateString(expression, params);
|
|
83
|
+
if (isFunction(expression)) return expression(params);
|
|
84
|
+
}
|
|
85
|
+
interpolateString(expression, params) {
|
|
86
|
+
if (!params) return expression;
|
|
87
|
+
return expression.replace(this.templateMatcher, (substring, key) => {
|
|
88
|
+
return this.formatValue(getValue(params, key)) ?? substring;
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
formatValue(value) {
|
|
92
|
+
if (isString(value)) return value;
|
|
93
|
+
if (typeof value === "number" || typeof value === "boolean") return value.toString();
|
|
94
|
+
if (!isDefinedAndNotNull(value)) return void 0;
|
|
95
|
+
const text = String(value);
|
|
96
|
+
return text === "[object Object]" ? JSON.stringify(value) : text;
|
|
97
|
+
}
|
|
98
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
99
|
+
minVersion: "12.0.0",
|
|
100
|
+
version: "17.0.0",
|
|
101
|
+
ngImport: i0,
|
|
102
|
+
type: TranslateDefaultParser,
|
|
103
|
+
deps: [],
|
|
104
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
105
|
+
});
|
|
106
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
107
|
+
minVersion: "12.0.0",
|
|
108
|
+
version: "17.0.0",
|
|
109
|
+
ngImport: i0,
|
|
110
|
+
type: TranslateDefaultParser
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
//#endregion
|
|
115
|
+
export { DefaultMissingTranslationHandler, MissingTranslationHandler, TranslateCompiler, TranslateDefaultParser, TranslateLoader, TranslateNoOpCompiler, TranslateNoOpLoader, TranslateParser };
|
|
116
|
+
//# sourceMappingURL=handlers.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handlers.mjs","names":[],"sources":["../../src/handlers.ts"],"sourcesContent":["import * as i0 from '@angular/core';\nimport { type Observable, of } from 'rxjs';\nimport type {\n FactoryDeclaration,\n InjectableDeclaration,\n} from './partialDeclarations';\nimport type {\n InterpolatableTranslation,\n InterpolatableTranslationObject,\n InterpolateFunction,\n InterpolationParameters,\n MissingTranslationHandlerParams,\n StrictTranslation,\n TranslationObject,\n} from './types';\nimport { getValue, isDefinedAndNotNull, isFunction, isString } from './util';\n\n/*\n * Angular metadata is written as partial declarations (`ɵɵngDeclare*`), the\n * format ngx-translate itself ships: the application build links them to the\n * user's Angular version, so no JIT compiler is needed at runtime.\n */\n\n/** Handles a key missing from every translation source. */\nexport abstract class MissingTranslationHandler {\n abstract handle(\n params: MissingTranslationHandlerParams\n ): StrictTranslation | Observable<StrictTranslation> | undefined;\n}\n\n/** Returns the key itself, ngx-translate's default. */\nexport class DefaultMissingTranslationHandler\n implements MissingTranslationHandler\n{\n handle(params: MissingTranslationHandlerParams): string {\n return params.key;\n }\n\n static ɵfac: i0.ɵɵFactoryDeclaration<\n DefaultMissingTranslationHandler,\n never\n > = i0.ɵɵngDeclareFactory({\n minVersion: '12.0.0',\n version: '17.0.0',\n ngImport: i0,\n type: DefaultMissingTranslationHandler,\n deps: [],\n target: i0.ɵɵFactoryTarget.Injectable,\n } as FactoryDeclaration) as never;\n static ɵprov: i0.ɵɵInjectableDeclaration<DefaultMissingTranslationHandler> =\n i0.ɵɵngDeclareInjectable({\n minVersion: '12.0.0',\n version: '17.0.0',\n ngImport: i0,\n type: DefaultMissingTranslationHandler,\n } as InjectableDeclaration) as never;\n}\n\n/** Compiles runtime translations registered through `setTranslation()`. */\nexport abstract class TranslateCompiler {\n abstract compile(value: string, lang: string): InterpolatableTranslation;\n abstract compileTranslations(\n translations: TranslationObject,\n lang: string\n ): InterpolatableTranslationObject;\n}\n\nexport class TranslateNoOpCompiler extends TranslateCompiler {\n compile(value: string, _lang: string): string {\n return value;\n }\n\n compileTranslations(\n translations: TranslationObject,\n _lang: string\n ): InterpolatableTranslationObject {\n return translations as InterpolatableTranslationObject;\n }\n\n static ɵfac: i0.ɵɵFactoryDeclaration<TranslateNoOpCompiler, never> =\n i0.ɵɵngDeclareFactory({\n minVersion: '12.0.0',\n version: '17.0.0',\n ngImport: i0,\n type: TranslateNoOpCompiler,\n deps: [],\n target: i0.ɵɵFactoryTarget.Injectable,\n } as FactoryDeclaration) as never;\n static ɵprov: i0.ɵɵInjectableDeclaration<TranslateNoOpCompiler> =\n i0.ɵɵngDeclareInjectable({\n minVersion: '12.0.0',\n version: '17.0.0',\n ngImport: i0,\n type: TranslateNoOpCompiler,\n } as InjectableDeclaration) as never;\n}\n\n/**\n * Loads runtime translations for a language. Intlayer dictionaries need no\n * loader; one is only called for catalogs kept outside intlayer.\n */\nexport abstract class TranslateLoader {\n abstract getTranslation(lang: string): Observable<TranslationObject>;\n}\n\nexport class TranslateNoOpLoader extends TranslateLoader {\n getTranslation(_lang: string): Observable<TranslationObject> {\n return of({});\n }\n\n static ɵfac: i0.ɵɵFactoryDeclaration<TranslateNoOpLoader, never> =\n i0.ɵɵngDeclareFactory({\n minVersion: '12.0.0',\n version: '17.0.0',\n ngImport: i0,\n type: TranslateNoOpLoader,\n deps: [],\n target: i0.ɵɵFactoryTarget.Injectable,\n } as FactoryDeclaration) as never;\n static ɵprov: i0.ɵɵInjectableDeclaration<TranslateNoOpLoader> =\n i0.ɵɵngDeclareInjectable({\n minVersion: '12.0.0',\n version: '17.0.0',\n ngImport: i0,\n type: TranslateNoOpLoader,\n } as InjectableDeclaration) as never;\n}\n\n/** Interpolates parameters into a translation. */\nexport abstract class TranslateParser {\n abstract interpolate(\n expression: InterpolatableTranslation,\n params?: InterpolationParameters\n ): string | undefined;\n}\n\n/** `{{ name }}` / `{{ user.name }}` interpolation, like ngx-translate. */\nexport class TranslateDefaultParser extends TranslateParser {\n templateMatcher = /{{\\s?([^{}\\s]*)\\s?}}/g;\n\n interpolate(\n expression: InterpolatableTranslation,\n params?: InterpolationParameters\n ): string | undefined {\n if (isString(expression)) {\n return this.interpolateString(expression, params);\n }\n if (isFunction(expression)) {\n return (expression as InterpolateFunction)(params);\n }\n return undefined;\n }\n\n protected interpolateString(\n expression: string,\n params?: InterpolationParameters\n ): string {\n if (!params) return expression;\n\n return expression.replace(\n this.templateMatcher,\n (substring, key: string) => {\n const replacement = this.formatValue(getValue(params, key));\n return replacement ?? substring;\n }\n );\n }\n\n protected formatValue(value: unknown): string | undefined {\n if (isString(value)) return value;\n if (typeof value === 'number' || typeof value === 'boolean') {\n return value.toString();\n }\n if (!isDefinedAndNotNull(value)) return undefined;\n\n const text = String(value);\n return text === '[object Object]' ? JSON.stringify(value) : text;\n }\n\n static ɵfac: i0.ɵɵFactoryDeclaration<TranslateDefaultParser, never> =\n i0.ɵɵngDeclareFactory({\n minVersion: '12.0.0',\n version: '17.0.0',\n ngImport: i0,\n type: TranslateDefaultParser,\n deps: [],\n target: i0.ɵɵFactoryTarget.Injectable,\n } as FactoryDeclaration) as never;\n static ɵprov: i0.ɵɵInjectableDeclaration<TranslateDefaultParser> =\n i0.ɵɵngDeclareInjectable({\n minVersion: '12.0.0',\n version: '17.0.0',\n ngImport: i0,\n type: TranslateDefaultParser,\n } as InjectableDeclaration) as never;\n}\n"],"mappings":";;;;;;AAwBA,IAAsB,4BAAtB,MAAgD,CAIhD;;AAGA,IAAa,mCAAb,MAAa,iCAEb;CACE,OAAO,QAAiD;EACtD,OAAO,OAAO;CAChB;CAEA,OAAO,OAGH,GAAG,mBAAmB;EACxB,YAAY;EACZ,SAAS;EACT,UAAU;EACV,MAAM;EACN,MAAM,CAAC;EACP,QAAQ,GAAG,gBAAgB;CAC7B,CAAuB;CACvB,OAAO,QACL,GAAG,sBAAsB;EACvB,YAAY;EACZ,SAAS;EACT,UAAU;EACV,MAAM;CACR,CAA0B;AAC9B;;AAGA,IAAsB,oBAAtB,MAAwC,CAMxC;AAEA,IAAa,wBAAb,MAAa,8BAA8B,kBAAkB;CAC3D,QAAQ,OAAe,OAAuB;EAC5C,OAAO;CACT;CAEA,oBACE,cACA,OACiC;EACjC,OAAO;CACT;CAEA,OAAO,OACL,GAAG,mBAAmB;EACpB,YAAY;EACZ,SAAS;EACT,UAAU;EACV,MAAM;EACN,MAAM,CAAC;EACP,QAAQ,GAAG,gBAAgB;CAC7B,CAAuB;CACzB,OAAO,QACL,GAAG,sBAAsB;EACvB,YAAY;EACZ,SAAS;EACT,UAAU;EACV,MAAM;CACR,CAA0B;AAC9B;;;;;AAMA,IAAsB,kBAAtB,MAAsC,CAEtC;AAEA,IAAa,sBAAb,MAAa,4BAA4B,gBAAgB;CACvD,eAAe,OAA8C;EAC3D,OAAO,GAAG,CAAC,CAAC;CACd;CAEA,OAAO,OACL,GAAG,mBAAmB;EACpB,YAAY;EACZ,SAAS;EACT,UAAU;EACV,MAAM;EACN,MAAM,CAAC;EACP,QAAQ,GAAG,gBAAgB;CAC7B,CAAuB;CACzB,OAAO,QACL,GAAG,sBAAsB;EACvB,YAAY;EACZ,SAAS;EACT,UAAU;EACV,MAAM;CACR,CAA0B;AAC9B;;AAGA,IAAsB,kBAAtB,MAAsC,CAKtC;;AAGA,IAAa,yBAAb,MAAa,+BAA+B,gBAAgB;CAC1D,kBAAkB;CAElB,YACE,YACA,QACoB;EACpB,IAAI,SAAS,UAAU,GACrB,OAAO,KAAK,kBAAkB,YAAY,MAAM;EAElD,IAAI,WAAW,UAAU,GACvB,OAAQ,WAAmC,MAAM;CAGrD;CAEA,AAAU,kBACR,YACA,QACQ;EACR,IAAI,CAAC,QAAQ,OAAO;EAEpB,OAAO,WAAW,QAChB,KAAK,kBACJ,WAAW,QAAgB;GAE1B,OADoB,KAAK,YAAY,SAAS,QAAQ,GAAG,CACxC,KAAK;EACxB,CACF;CACF;CAEA,AAAU,YAAY,OAAoC;EACxD,IAAI,SAAS,KAAK,GAAG,OAAO;EAC5B,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,WAChD,OAAO,MAAM,SAAS;EAExB,IAAI,CAAC,oBAAoB,KAAK,GAAG,OAAO;EAExC,MAAM,OAAO,OAAO,KAAK;EACzB,OAAO,SAAS,oBAAoB,KAAK,UAAU,KAAK,IAAI;CAC9D;CAEA,OAAO,OACL,GAAG,mBAAmB;EACpB,YAAY;EACZ,SAAS;EACT,UAAU;EACV,MAAM;EACN,MAAM,CAAC;EACP,QAAQ,GAAG,gBAAgB;CAC7B,CAAuB;CACzB,OAAO,QACL,GAAG,sBAAsB;EACvB,YAAY;EACZ,SAAS;EACT,UAAU;EACV,MAAM;CACR,CAA0B;AAC9B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { equals, getValue, insertValue, isArray, isDefined, isDefinedAndNotNull, isDict, isFunction, isObject, isString, mergeDeep } from "./util.mjs";
|
|
2
|
+
import { DefaultMissingTranslationHandler, MissingTranslationHandler, TranslateCompiler, TranslateDefaultParser, TranslateLoader, TranslateNoOpCompiler, TranslateNoOpLoader, TranslateParser } from "./handlers.mjs";
|
|
3
|
+
import { TranslateStore } from "./translateStore.mjs";
|
|
4
|
+
import { ITranslateService, TRANSLATE_SERVICE_CONFIG, TranslateService } from "./translateService.mjs";
|
|
5
|
+
import { provideChildTranslateService, provideMissingTranslationHandler, provideTranslateCompiler, provideTranslateLoader, provideTranslateParser, provideTranslateService } from "./providers.mjs";
|
|
6
|
+
import { _, translate } from "./standalone.mjs";
|
|
7
|
+
import { TranslateBlockContext, TranslateBlockDirective } from "./translateBlockDirective.mjs";
|
|
8
|
+
import { TranslateDirective } from "./translateDirective.mjs";
|
|
9
|
+
import { TranslatePipe } from "./translatePipe.mjs";
|
|
10
|
+
|
|
11
|
+
export { DefaultMissingTranslationHandler, ITranslateService, MissingTranslationHandler, TRANSLATE_SERVICE_CONFIG, TranslateBlockContext, TranslateBlockDirective, TranslateCompiler, TranslateDefaultParser, TranslateDirective, TranslateLoader, TranslateNoOpCompiler, TranslateNoOpLoader, TranslateParser, TranslatePipe, TranslateService, TranslateStore, _, equals, getValue, insertValue, isArray, isDefined, isDefinedAndNotNull, isDict, isFunction, isObject, isString, mergeDeep, provideChildTranslateService, provideMissingTranslationHandler, provideTranslateCompiler, provideTranslateLoader, provideTranslateParser, provideTranslateService, translate };
|
|
File without changes
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { NGX_TRANSLATE_CALLERS } from "@intlayer/config/callers";
|
|
3
|
+
import * as ANSIColors from "@intlayer/config/colors";
|
|
4
|
+
import { colorize, getAppLogger } from "@intlayer/config/logger";
|
|
5
|
+
import { getConfiguration } from "@intlayer/config/node";
|
|
6
|
+
import { runOnce } from "@intlayer/engine/utils";
|
|
7
|
+
import { intlayer } from "vite-intlayer";
|
|
8
|
+
|
|
9
|
+
//#region src/plugin/index.ts
|
|
10
|
+
/**
|
|
11
|
+
* ngx-translate callers as the field-usage analysis must see them.
|
|
12
|
+
*
|
|
13
|
+
* The `| translate` pipe and `[translate]` directive read keys from Angular
|
|
14
|
+
* templates that no JS analyser parses, so a `translate('home.title')` call
|
|
15
|
+
* in a component class cannot prove which other fields of `home` its
|
|
16
|
+
* template needs. Every dictionary reached from ngx-translate is therefore
|
|
17
|
+
* kept whole (`'all'`); dictionaries only read through `useIntlayer` still
|
|
18
|
+
* get pruned.
|
|
19
|
+
*/
|
|
20
|
+
const NGX_TRANSLATE_BUILD_CALLERS = NGX_TRANSLATE_CALLERS.map((descriptor) => ({
|
|
21
|
+
...descriptor,
|
|
22
|
+
translationFunction: "all"
|
|
23
|
+
}));
|
|
24
|
+
/**
|
|
25
|
+
* Vite plugin for Angular apps built with Vite (Analog): wraps vite-intlayer
|
|
26
|
+
* and aliases `@ngx-translate/core` to `@intlayer/ngx-translate`.
|
|
27
|
+
*
|
|
28
|
+
* Angular CLI apps use `@intlayer/ngx-translate/esbuild` instead.
|
|
29
|
+
*/
|
|
30
|
+
const ngxTranslateVitePlugin = (options) => {
|
|
31
|
+
const intlayerConfig = getConfiguration();
|
|
32
|
+
const appLogger = getAppLogger(intlayerConfig);
|
|
33
|
+
runOnce(join(intlayerConfig.system.baseDir, ".intlayer", "cache", "intlayer-issues-invitation.lock"), () => {
|
|
34
|
+
appLogger([colorize("Please report any issues you met on GitHub:", ANSIColors.GREY), colorize("https://github.com/aymericzip/intlayer/issues", ANSIColors.GREY_LIGHT)]);
|
|
35
|
+
}, { cacheTimeoutMs: 36e5 });
|
|
36
|
+
const basePlugins = intlayer({
|
|
37
|
+
...options,
|
|
38
|
+
compatCallers: [...options?.compatCallers ?? [], ...NGX_TRANSLATE_BUILD_CALLERS]
|
|
39
|
+
});
|
|
40
|
+
const compatPlugin = {
|
|
41
|
+
name: "vite-ngx-translate-compat-plugin",
|
|
42
|
+
config: () => ({ resolve: { alias: { "@ngx-translate/core": "@intlayer/ngx-translate" } } })
|
|
43
|
+
};
|
|
44
|
+
return [...Array.isArray(basePlugins) ? basePlugins : [basePlugins], compatPlugin];
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
export { NGX_TRANSLATE_BUILD_CALLERS, ngxTranslateVitePlugin as default, ngxTranslateVitePlugin };
|
|
49
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/plugin/index.ts"],"sourcesContent":["import { join } from 'node:path';\nimport {\n type CallerDescriptor,\n NGX_TRANSLATE_CALLERS,\n} from '@intlayer/config/callers';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { runOnce } from '@intlayer/engine/utils';\nimport type { PluginOption } from 'vite';\nimport { intlayer } from 'vite-intlayer';\n\n/**\n * ngx-translate callers as the field-usage analysis must see them.\n *\n * The `| translate` pipe and `[translate]` directive read keys from Angular\n * templates that no JS analyser parses, so a `translate('home.title')` call\n * in a component class cannot prove which other fields of `home` its\n * template needs. Every dictionary reached from ngx-translate is therefore\n * kept whole (`'all'`); dictionaries only read through `useIntlayer` still\n * get pruned.\n */\nexport const NGX_TRANSLATE_BUILD_CALLERS: CallerDescriptor[] =\n NGX_TRANSLATE_CALLERS.map((descriptor) => ({\n ...descriptor,\n translationFunction: 'all',\n }));\n\n/**\n * Vite plugin for Angular apps built with Vite (Analog): wraps vite-intlayer\n * and aliases `@ngx-translate/core` to `@intlayer/ngx-translate`.\n *\n * Angular CLI apps use `@intlayer/ngx-translate/esbuild` instead.\n */\nexport const ngxTranslateVitePlugin = (\n options?: Parameters<typeof intlayer>[0]\n): PluginOption[] => {\n const intlayerConfig = getConfiguration();\n const appLogger = getAppLogger(intlayerConfig);\n\n runOnce(\n join(\n intlayerConfig.system.baseDir,\n '.intlayer',\n 'cache',\n 'intlayer-issues-invitation.lock'\n ),\n () => {\n appLogger([\n colorize(\n 'Please report any issues you met on GitHub:',\n ANSIColors.GREY\n ),\n colorize(\n 'https://github.com/aymericzip/intlayer/issues',\n ANSIColors.GREY_LIGHT\n ),\n ]);\n },\n {\n cacheTimeoutMs: 1000 * 60 * 60, // 1 hour\n }\n );\n\n const basePlugins = intlayer({\n ...options,\n compatCallers: [\n ...(options?.compatCallers ?? []),\n ...NGX_TRANSLATE_BUILD_CALLERS,\n ],\n });\n\n const compatPlugin: PluginOption = {\n name: 'vite-ngx-translate-compat-plugin',\n config: () => ({\n resolve: {\n alias: {\n '@ngx-translate/core': '@intlayer/ngx-translate',\n },\n },\n }),\n };\n\n return [\n ...(Array.isArray(basePlugins) ? basePlugins : [basePlugins]),\n compatPlugin,\n ];\n};\n\nexport default ngxTranslateVitePlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsBA,MAAa,8BACX,sBAAsB,KAAK,gBAAgB;CACzC,GAAG;CACH,qBAAqB;AACvB,EAAE;;;;;;;AAQJ,MAAa,0BACX,YACmB;CACnB,MAAM,iBAAiB,iBAAiB;CACxC,MAAM,YAAY,aAAa,cAAc;CAE7C,QACE,KACE,eAAe,OAAO,SACtB,aACA,SACA,iCACF,SACM;EACJ,UAAU,CACR,SACE,+CACA,WAAW,IACb,GACA,SACE,iDACA,WAAW,UACb,CACF,CAAC;CACH,GACA,EACE,gBAAgB,KAClB,CACF;CAEA,MAAM,cAAc,SAAS;EAC3B,GAAG;EACH,eAAe,CACb,GAAI,SAAS,iBAAiB,CAAC,GAC/B,GAAG,2BACL;CACF,CAAC;CAED,MAAM,eAA6B;EACjC,MAAM;EACN,eAAe,EACb,SAAS,EACP,OAAO,EACL,uBAAuB,0BACzB,EACF,EACF;CACF;CAEA,OAAO,CACL,GAAI,MAAM,QAAQ,WAAW,IAAI,cAAc,CAAC,WAAW,GAC3D,YACF;AACF"}
|