@intlayer/lingui 8.12.5-canary.0

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 (60) hide show
  1. package/README.md +330 -0
  2. package/dist/cjs/I18nClass.cjs +127 -0
  3. package/dist/cjs/I18nClass.cjs.map +1 -0
  4. package/dist/cjs/I18nProvider.cjs +64 -0
  5. package/dist/cjs/I18nProvider.cjs.map +1 -0
  6. package/dist/cjs/LinguiContext.cjs +23 -0
  7. package/dist/cjs/LinguiContext.cjs.map +1 -0
  8. package/dist/cjs/Trans.cjs +71 -0
  9. package/dist/cjs/Trans.cjs.map +1 -0
  10. package/dist/cjs/_virtual/_rolldown/runtime.cjs +29 -0
  11. package/dist/cjs/eventEmitter.cjs +37 -0
  12. package/dist/cjs/eventEmitter.cjs.map +1 -0
  13. package/dist/cjs/formats.cjs +66 -0
  14. package/dist/cjs/formats.cjs.map +1 -0
  15. package/dist/cjs/index.cjs +19 -0
  16. package/dist/cjs/plugin/index.cjs +64 -0
  17. package/dist/cjs/plugin/index.cjs.map +1 -0
  18. package/dist/cjs/setupI18n.cjs +33 -0
  19. package/dist/cjs/setupI18n.cjs.map +1 -0
  20. package/dist/cjs/useLingui.cjs +40 -0
  21. package/dist/cjs/useLingui.cjs.map +1 -0
  22. package/dist/esm/I18nClass.mjs +126 -0
  23. package/dist/esm/I18nClass.mjs.map +1 -0
  24. package/dist/esm/I18nProvider.mjs +63 -0
  25. package/dist/esm/I18nProvider.mjs.map +1 -0
  26. package/dist/esm/LinguiContext.mjs +22 -0
  27. package/dist/esm/LinguiContext.mjs.map +1 -0
  28. package/dist/esm/Trans.mjs +70 -0
  29. package/dist/esm/Trans.mjs.map +1 -0
  30. package/dist/esm/eventEmitter.mjs +35 -0
  31. package/dist/esm/eventEmitter.mjs.map +1 -0
  32. package/dist/esm/formats.mjs +64 -0
  33. package/dist/esm/formats.mjs.map +1 -0
  34. package/dist/esm/index.mjs +11 -0
  35. package/dist/esm/plugin/index.mjs +60 -0
  36. package/dist/esm/plugin/index.mjs.map +1 -0
  37. package/dist/esm/setupI18n.mjs +31 -0
  38. package/dist/esm/setupI18n.mjs.map +1 -0
  39. package/dist/esm/useLingui.mjs +39 -0
  40. package/dist/esm/useLingui.mjs.map +1 -0
  41. package/dist/types/I18nClass.d.ts +92 -0
  42. package/dist/types/I18nClass.d.ts.map +1 -0
  43. package/dist/types/I18nProvider.d.ts +39 -0
  44. package/dist/types/I18nProvider.d.ts.map +1 -0
  45. package/dist/types/LinguiContext.d.ts +21 -0
  46. package/dist/types/LinguiContext.d.ts.map +1 -0
  47. package/dist/types/Trans.d.ts +38 -0
  48. package/dist/types/Trans.d.ts.map +1 -0
  49. package/dist/types/eventEmitter.d.ts +24 -0
  50. package/dist/types/eventEmitter.d.ts.map +1 -0
  51. package/dist/types/formats.d.ts +32 -0
  52. package/dist/types/formats.d.ts.map +1 -0
  53. package/dist/types/index.d.ts +10 -0
  54. package/dist/types/plugin/index.d.ts +25 -0
  55. package/dist/types/plugin/index.d.ts.map +1 -0
  56. package/dist/types/setupI18n.d.ts +37 -0
  57. package/dist/types/setupI18n.d.ts.map +1 -0
  58. package/dist/types/useLingui.d.ts +21 -0
  59. package/dist/types/useLingui.d.ts.map +1 -0
  60. package/package.json +115 -0
package/README.md ADDED
@@ -0,0 +1,330 @@
1
+ <p align="center">
2
+ <a href="https://intlayer.org" rel="">
3
+ <img src="https://raw.githubusercontent.com/aymericzip/intlayer/main/docs/assets/cover.png" 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
+ ![Watch the video](https://github.com/aymericzip/intlayer/blob/main/docs/assets/demo_video.gif)
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.png?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.jpg?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.png?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.png?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.png?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.png?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) |
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
+ ---
73
+
74
+ ## 📦 Installation
75
+
76
+ Start your journey with Intlayer today and experience a smoother, more powerful approach to internationalization.
77
+
78
+ <a href="https://intlayer.org/doc/concept/content" rel="">
79
+ <img src="https://img.shields.io/badge/Get_Started-FFFFFF?style=for-the-badge&logo=rocket&logoColor=black" />
80
+ </a>
81
+
82
+ ```bash
83
+ npm install intlayer react-intlayer
84
+ ```
85
+
86
+ ⚡ Quick Start (Next.js)
87
+
88
+ ```ts
89
+ // intlayer.config.ts
90
+ import { Locales, type IntlayerConfig } from "intlayer";
91
+
92
+ const config: IntlayerConfig = {
93
+ internationalization: {
94
+ locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
95
+ defaultLocale: Locales.ENGLISH,
96
+ },
97
+ };
98
+
99
+ export default config;
100
+ ```
101
+
102
+ ```ts
103
+ // app/home.content.ts
104
+ import { t, type Dictionary } from "intlayer";
105
+
106
+ const content = {
107
+ key: "home",
108
+ content: {
109
+ title: t({
110
+ en: "Home",
111
+ fr: "Accueil",
112
+ es: "Inicio",
113
+ }),
114
+ },
115
+ } satisfies Dictionary;
116
+
117
+ export default content;
118
+ ```
119
+
120
+ ```tsx
121
+ // app/page.tsx
122
+ import { useIntlayer } from "react-intlayer";
123
+
124
+ const HomePage = () => {
125
+ const { title } = useIntlayer("home");
126
+
127
+ return <h1>{title}</h1>;
128
+ };
129
+ ```
130
+
131
+ <a href="https://intlayer.org/doc/environment/nextjs"> Get the full guide → </a>
132
+
133
+ ## 🎥 Live tutorial on YouTube
134
+
135
+ [![How to Internationalize your application using Intlayer](https://i.ytimg.com/vi/e_PPG7PTqGU/hqdefault.jpg?sqp=-oaymwEcCNACELwBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLDtyJ4uYotEjl12nZ_gZKZ_kjEgOQ)](https://youtu.be/e_PPG7PTqGU?si=GyU_KpVhr61razRw)
136
+
137
+ <a href="https://intlayer.org/doc/concept/content" rel="">
138
+ <img src="https://img.shields.io/badge/Get_Started-FFFFFF?style=for-the-badge&logo=rocket&logoColor=black" />
139
+ </a>
140
+
141
+ ## Table of Contents
142
+
143
+ Explore our comprehensive documentation to get started with Intlayer and learn how to integrate it into your projects.
144
+
145
+ <details open>
146
+ <summary style="font-size:16px; font-weight:bold;">📘 Get Started</summary>
147
+ <ul>
148
+ <li><a href="https://intlayer.org/doc/why" rel=''>Why Intlayer?</a></li>
149
+ <li><a href="https://intlayer.org/doc" rel=''>Introduction</a></li>
150
+ </ul>
151
+ </details>
152
+
153
+ <details>
154
+ <summary style="font-size:16px; font-weight:bold;">⚙️ Concept</summary>
155
+ <ul>
156
+ <li><a href="https://intlayer.org/doc/concept/how-works-intlayer" rel=''>How Intlayer Works</a></li>
157
+ <li><a href="https://intlayer.org/doc/concept/configuration" rel=''>Configuration</a></li>
158
+ <li><a href="https://intlayer.org/doc/concept/cli" rel=''>Intlayer CLI</a></li>
159
+ <li><a href="https://intlayer.org/doc/compiler" rel=''>Compiler</a></li>
160
+
161
+ <li><a href="https://intlayer.org/doc/concept/editor" rel=''>Intlayer Editor</a></li>
162
+ <li><a href="https://intlayer.org/doc/concept/cms" rel=''>Intlayer CMS</a></li>
163
+ <li><a href="https://intlayer.org/doc/concept/content" rel=''>Dictionary</a>
164
+ <ul>
165
+ <li><a href="https://intlayer.org/doc/concept/content/per-locale-file" rel=''>Per-Locale Content Declaration File</a></li>
166
+ <li><a href="https://intlayer.org/doc/concept/content/translation" rel=''>Translation</a></li>
167
+ <li><a href="https://intlayer.org/doc/concept/content/enumeration" rel=''>Enumeration</a></li>
168
+ <li><a href="https://intlayer.org/doc/concept/content/condition" rel=''>Condition</a></li>
169
+ <li><a href="https://intlayer.org/doc/concept/content/nesting" rel=''>Nesting</a></li>
170
+ <li><a href="https://intlayer.org/doc/concept/content/markdown" rel=''>Markdown</a></li>
171
+ <li><a href="https://intlayer.org/doc/concept/content/function-fetching" rel=''>Function Fetching</a></li>
172
+ <li><a href="https://intlayer.org/doc/concept/content/insertion" rel=''>Insertion</a></li>
173
+ <li><a href="https://intlayer.org/doc/concept/content/file" rel=''>File</a></li>
174
+ </ul>
175
+ </li>
176
+ </ul>
177
+ </details>
178
+
179
+ <details open>
180
+ <summary style="font-size:16px; font-weight:bold;">🌐 Environment</summary>
181
+ <ul>
182
+ <li><a href="https://intlayer.org/doc/environment/nextjs" rel=''>Intlayer with Next.js 16</a>
183
+ <ul>
184
+ <li><a href="https://intlayer.org/doc/environment/nextjs/15" rel=''>Next.js 15</a></li>
185
+ <li><a href="https://intlayer.org/doc/environment/nextjs/14" rel=''>Next.js 14 (App Router)</a></li>
186
+ <li><a href="https://intlayer.org/doc/environment/nextjs/next-with-Page-Router" rel=''>Next.js Page Router</a></li>
187
+ <li><a href="https://intlayer.org/doc/environment/nextjs/compiler" rel=''>Next.js using Compiler</a></li>
188
+ </ul>
189
+ </li>
190
+ <li><a href="https://intlayer.org/doc/environment/create-react-app" rel=''>React CRA</a></li>
191
+ <li><a href="https://intlayer.org/doc/environment/vite-and-react" rel=''>Vite + React</a></li>
192
+ <li><a href="https://intlayer.org/doc/environment/vite-and-react" rel=''>Vite + React using Compiler</a></li>
193
+ <li><a href="https://intlayer.org/doc/environment/vite-and-react/compiler" rel=''>React-router-v7</a></li>
194
+ <li><a href="https://intlayer.org/doc/environment/tanstack-start" rel=''>Tanstack start</a>
195
+ <ul>
196
+ <li><a href="https://intlayer.org/doc/environment/tanstack-start/solid" rel=''>Solid</a></li>
197
+ </ul>
198
+ </li>
199
+ <li><a href="https://intlayer.org/doc/environment/astro" rel=''>Astro</a>
200
+ <ul>
201
+ <li><a href="https://intlayer.org/doc/environment/astro/react" rel=''>React</a></li>
202
+ <li><a href="https://intlayer.org/doc/environment/astro/vue" rel=''>Vue</a></li>
203
+ <li><a href="https://intlayer.org/doc/environment/astro/svelte" rel=''>Svelte</a></li>
204
+ <li><a href="https://intlayer.org/doc/environment/astro/solid" rel=''>Solid</a></li>
205
+ <li><a href="https://intlayer.org/doc/environment/astro/vanilla" rel=''>Vanilla JS</a></li>
206
+ <li><a href="https://intlayer.org/doc/environment/astro/lit" rel=''>Lit</a></li>
207
+ </ul>
208
+ </li>
209
+
210
+ <li><a href="https://intlayer.org/doc/environment/react-native-and-expo" rel=''>React Native</a></li>
211
+ <li><a href="https://intlayer.org/doc/environment/vite-and-svelte" rel=''>Vite + Svelte</a></li>
212
+ <li><a href="https://intlayer.org/doc/environment/sveltekit" rel=''>SvelteKit</a></li>
213
+ <li><a href="https://intlayer.org/doc/environment/vite-and-preact" rel=''>Vite + Preact</a></li>
214
+ <li><a href="https://intlayer.org/doc/environment/vite-and-vue" rel=''>Vite + Vue</a></li>
215
+ <li><a href="https://intlayer.org/doc/environment/vite-and-nuxt" rel=''>Vite + Nuxt</a></li>
216
+ <li><a href="https://intlayer.org/doc/environment/vite-and-solid" rel=''>Vite + Solid</a></li>
217
+ <li><a href="https://intlayer.org/doc/environment/angular" rel=''>Angular</a></li>
218
+ <li>
219
+ <a href="https://intlayer.org/doc/environment/express" rel=''>Backend</a>
220
+ <ul>
221
+ <li><a href="https://intlayer.org/doc/environment/express" rel=''>Express</a></li>
222
+ <li><a href="https://intlayer.org/doc/environment/nest" rel=''>NestJS</a></li>
223
+ <li><a href="https://intlayer.org/doc/environment/fastify" rel=''>Fastify</a></li>
224
+ <li><a href="https://intlayer.org/doc/environment/adonisjs" rel=''>AdonisJS</a></li>
225
+ <li><a href="https://intlayer.org/doc/environment/hono" rel=''>Hono</a></li>
226
+ </ul>
227
+ </li>
228
+ </ul>
229
+ </details>
230
+
231
+ <details>
232
+ <summary style="font-size:16px; font-weight:bold;">📊 Benchmark</summary>
233
+ <ul>
234
+ <li><a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/benchmark/nextjs.md" rel=''>Next.js</a></li>
235
+ <li><a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/benchmark/tanstack.md" rel=''>TanStack Start</a></li>
236
+ <li><a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/benchmark/vue.md" rel=''>Vue</a></li>
237
+ <li><a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/benchmark/solid.md" rel=''>Solid</a></li>
238
+ <li><a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/benchmark/svelte.md" rel=''>Svelte</a></li>
239
+ </ul>
240
+ </details>
241
+
242
+ <details>
243
+ <summary style="font-size:16px; font-weight:bold;">📰 Blog</summary>
244
+ <ul>
245
+ <li><a href="https://github.com/aymericzip/intlayer/blob/main/docs/blog/en/what_is_internationalization.md" rel=''>What is i18n</a></li>
246
+ <li><a href="https://intlayer.org/blog/SEO-and-i18n" rel=''>i18n and SEO</a></li>
247
+ <li><a href="https://intlayer.org/blog/intlayer-with-next-i18next" rel=''>Intlayer and i18next</a></li>
248
+ <li><a href="https://intlayer.org/blog/intlayer-with-react-i18next" rel=''>Intlayer and react-intl</a></li>
249
+ <li><a href="https://intlayer.org/blog/intlayer-with-next-intl" rel=''>Intlayer and next-intl</a></li>
250
+ </ul>
251
+ </details>
252
+
253
+ ## Multilingual content management system
254
+
255
+ 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).
256
+
257
+ 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:
258
+
259
+ - i18n solutions (e.g. `i18next`, `next-intl`, `vue-i18n`)
260
+ - TMSs (Translation Management Systems) (e.g. Crowdin, Phrase, Lokalise)
261
+ - Feature flags
262
+ - Headless CMSs (e.g. Contentful, Strapi, Sanity)
263
+
264
+ ![CMS Preview](https://github.com/aymericzip/intlayer/blob/main/docs/assets/CMS.png?raw=true)
265
+
266
+ ## 🌐 Readme in other languages
267
+
268
+ <p align="center">
269
+ <a href="https://github.com/aymericzip/intlayer/blob/main/readme.md">English</a> •
270
+ <a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh/readme.md">简体中文</a> •
271
+ <a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/ru/readme.md">Русский</a> •
272
+ <a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/readme.md">日本語</a> •
273
+ <a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/readme.md">Français</a> •
274
+ <a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/ko/readme.md">한국어</a> •
275
+ <a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/readme.md">Español</a> •
276
+ <a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/de/readme.md">Deutsch</a> •
277
+ <a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/ar/readme.md">العربية</a> •
278
+ <a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/readme.md">Italiano</a> •
279
+ <a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/readme.md">English (UK)</a> •
280
+ <a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/readme.md">Português</a> •
281
+ <a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/hi/readme.md">हिन्दी</a> •
282
+ <a href="https://github.com/aymericzip/intlayer/blob/main/docs/docs/tr/readme.md">Türkçe</a>
283
+ </p>
284
+
285
+ ## 🤝 Community
286
+
287
+ Intlayer is built with and for the community and we’d love your input!
288
+
289
+ - Have a suggestion? [Open an issue](https://github.com/aymericzip/intlayer/issues)
290
+ - Found a bug or improvement? [Submit a PR](https://github.com/aymericzip/intlayer/pulls)
291
+ - Need help or want to connect? [Join our Discord](https://discord.gg/7uxamYVeCk)
292
+
293
+ You can also follow us on :
294
+
295
+ <div>
296
+ <br/>
297
+ <p align="center">
298
+ <a href="https://discord.gg/528mBV4N" target="blank" rel='noopener noreferrer nofollow'><img align="center"
299
+ src="https://img.shields.io/badge/discord-5865F2.svg?style=for-the-badge&logo=discord&logoColor=white"
300
+ alt="Intlayer Discord" height="30"/></a>
301
+ <a href="https://www.linkedin.com/company/intlayerorg" target="blank" rel='noopener noreferrer nofollow'><img align="center"
302
+ src="https://img.shields.io/badge/linkedin-%231DA1F2.svg?style=for-the-badge&logo=linkedin&logoColor=white"
303
+ alt="Intlayer LinkedIn" height="30"/></a>
304
+ <a href="https://www.instagram.com/intlayer/" target="blank" rel='noopener noreferrer nofollow'><img align="center"
305
+ src="https://img.shields.io/badge/instagram-%23E4405F.svg?style=for-the-badge&logo=Instagram&logoColor=white"
306
+ alt="Intlayer Instagram" height="30"/></a>
307
+ <a href="https://x.com/Intlayer183096" target="blank" rel='noopener noreferrer nofollow'><img align="center"
308
+ src="https://img.shields.io/badge/x-1DA1F2.svg?style=for-the-badge&logo=x&logoColor=white"
309
+ alt="Intlayer X" height="30"/></a>
310
+ <a href="https://www.youtube.com/@intlayer" target="blank" rel='noopener noreferrer nofollow'><img align="center"
311
+ src="https://img.shields.io/badge/youtube-FF0000.svg?style=for-the-badge&logo=youtube&logoColor=white"
312
+ alt="Intlayer YouTube" height="30"/></a>
313
+ <a href="https://www.tiktok.com/@intlayer" target="blank" rel='noopener noreferrer nofollow'><img align="center"
314
+ src="https://img.shields.io/badge/tiktok-000000.svg?style=for-the-badge&logo=tiktok&logoColor=white"
315
+ alt="Intlayer TikTok" height="30"/></a>
316
+ <br>
317
+ </p>
318
+ </div>
319
+
320
+ ### Contribution
321
+
322
+ 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!
323
+
324
+ Contribute on [GitHub](https://github.com/aymericzip/intlayer), [GitLab](https://gitlab.com/ay.pineau/intlayer), or [Bitbucket](https://bitbucket.org/intlayer/intlayer/).
325
+
326
+ ### Thank You for the Support
327
+
328
+ 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-).
329
+
330
+ [![Star History Chart](https://api.star-history.com/svg?repos=aymericzip/intlayer&type=Date)](https://star-history.com/#aymericzip/intlayer&Date)
@@ -0,0 +1,127 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_eventEmitter = require('./eventEmitter.cjs');
3
+ let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
4
+ let _intlayer_core_messageFormat = require("@intlayer/core/messageFormat");
5
+
6
+ //#region src/I18nClass.ts
7
+ /**
8
+ * Navigates a nested object by a dot-separated path.
9
+ *
10
+ * Example: `navigatePath({home: {title: 'Hello'}}, 'home.title')` → `'Hello'`
11
+ */
12
+ const navigatePath = (object, path) => {
13
+ if (!path) return object;
14
+ const parts = path.split(".");
15
+ let current = object;
16
+ for (const part of parts) {
17
+ if (current === null || current === void 0 || typeof current !== "object") return;
18
+ current = current[part];
19
+ }
20
+ return current;
21
+ };
22
+ /**
23
+ * Looks up a lingui message from the `messages` intlayer dictionary.
24
+ *
25
+ * The entire lingui catalog is stored in a single `messages` dictionary.
26
+ * Dotted IDs (e.g. `'home.title'`) are resolved as nested paths within that
27
+ * dictionary. Hash-style IDs (no dots) are direct top-level keys.
28
+ */
29
+ const lookupMessage = (id, locale) => {
30
+ try {
31
+ const value = navigatePath((0, _intlayer_core_interpreter.getIntlayer)("messages", locale), id);
32
+ return typeof value === "string" ? value : void 0;
33
+ } catch {
34
+ return;
35
+ }
36
+ };
37
+ /**
38
+ * Intlayer-backed implementation of `@lingui/core`'s `I18n` class.
39
+ *
40
+ * - Messages are read from the `messages` intlayer dictionary.
41
+ * - ICU MessageFormat syntax is resolved via `@intlayer/core/messageFormat`.
42
+ * - `load()` / `loadAndActivate()` / `setMessagesCompiler()` are no-ops —
43
+ * messages are served by intlayer's compiled dictionaries.
44
+ * - `activate(locale)` emits `'change'` so that React consumers re-render.
45
+ */
46
+ var I18nClass = class extends require_eventEmitter.EventEmitter {
47
+ _locale;
48
+ _locales;
49
+ constructor({ locale = "en", locales } = {}) {
50
+ super();
51
+ this._locale = typeof locale === "string" ? locale : "en";
52
+ this._locales = locales;
53
+ }
54
+ get locale() {
55
+ return this._locale;
56
+ }
57
+ get locales() {
58
+ return this._locales;
59
+ }
60
+ get messages() {
61
+ try {
62
+ return (0, _intlayer_core_interpreter.getIntlayer)("messages", this._locale);
63
+ } catch {
64
+ return {};
65
+ }
66
+ }
67
+ /**
68
+ * No-op: intlayer handles message compilation at build time.
69
+ */
70
+ setMessagesCompiler(_compiler) {
71
+ if (process.env.NODE_ENV === "development") console.warn("@intlayer/lingui: i18n.setMessagesCompiler() is a no-op — message compilation is handled at build time by intlayer.");
72
+ return this;
73
+ }
74
+ /**
75
+ * No-op: messages are loaded automatically via intlayer dictionaries.
76
+ */
77
+ load(_localeOrAll, _messages) {
78
+ if (process.env.NODE_ENV === "development") console.warn("@intlayer/lingui: i18n.load() is a no-op — messages are loaded automatically via intlayer dictionaries.");
79
+ }
80
+ /**
81
+ * Activates the given locale (emits `'change'`).
82
+ * The `messages` argument is ignored — intlayer handles the catalog.
83
+ */
84
+ loadAndActivate({ locale, locales }) {
85
+ this.activate(locale, locales);
86
+ }
87
+ /**
88
+ * Sets the active locale and emits `'change'` to notify React consumers.
89
+ */
90
+ activate(locale, locales) {
91
+ this._locale = locale;
92
+ this._locales = locales;
93
+ this.emit("change");
94
+ }
95
+ _(descriptorOrId, values, options) {
96
+ const isDescriptor = typeof descriptorOrId === "object" && descriptorOrId !== null;
97
+ const id = isDescriptor ? descriptorOrId.id : descriptorOrId;
98
+ const defaultMessage = isDescriptor ? descriptorOrId.message ?? options?.message : options?.message;
99
+ const resolvedValues = isDescriptor ? {
100
+ ...descriptorOrId.values ?? {},
101
+ ...values ?? {}
102
+ } : values ?? {};
103
+ return (0, _intlayer_core_messageFormat.resolveMessage)(lookupMessage(id, this._locale) ?? defaultMessage ?? id, resolvedValues, this._locale, "icu") ?? id;
104
+ }
105
+ /**
106
+ * Alias for `_`. Provided for lingui API compatibility.
107
+ */
108
+ t = (descriptorOrId, values, options) => this._(descriptorOrId, values, options);
109
+ /**
110
+ * @deprecated Use `Intl.DateTimeFormat` directly.
111
+ */
112
+ date(value, format) {
113
+ if (value === void 0 || value === null) return "";
114
+ const dateValue = value instanceof Date ? value : new Date(typeof value === "string" ? value : value);
115
+ return new Intl.DateTimeFormat(this._locale, format).format(dateValue);
116
+ }
117
+ /**
118
+ * @deprecated Use `Intl.NumberFormat` directly.
119
+ */
120
+ number(value, format) {
121
+ return new Intl.NumberFormat(this._locale, format).format(value);
122
+ }
123
+ };
124
+
125
+ //#endregion
126
+ exports.I18nClass = I18nClass;
127
+ //# sourceMappingURL=I18nClass.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"I18nClass.cjs","names":["EventEmitter"],"sources":["../../src/I18nClass.ts"],"sourcesContent":["import { getIntlayer } from '@intlayer/core/interpreter';\nimport { resolveMessage } from '@intlayer/core/messageFormat';\nimport type {\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type {\n AllMessages,\n Locale,\n Locales,\n MessageDescriptor,\n MessageId,\n MessageOptions,\n Messages,\n} from '@lingui/core';\nimport { EventEmitter } from './eventEmitter';\n\n/** Mirrors the unexported `Values` type from `@lingui/core`. */\ntype Values = Record<string, unknown>;\n\n/** Mirrors the unexported `MessageCompiler` type from `@lingui/core`. */\ntype MessageCompiler = (message: string) => unknown;\n\n/** Mirrors the unexported `Events` type from `@lingui/core`. */\ntype LinguiEvents = {\n change: () => void;\n missing: (event: { locale: Locale; id: MessageId }) => void;\n};\n\n/** Mirrors the unexported `I18nProps` type from `@lingui/core`. */\ntype I18nProps = {\n locale?: Locale;\n locales?: Locales;\n messages?: AllMessages;\n missing?: string | ((locale: string, id: string) => string);\n};\n\n/**\n * Navigates a nested object by a dot-separated path.\n *\n * Example: `navigatePath({home: {title: 'Hello'}}, 'home.title')` → `'Hello'`\n */\nconst navigatePath = (object: unknown, path: string): unknown => {\n if (!path) return object;\n const parts = path.split('.');\n let current: unknown = object;\n for (const part of parts) {\n if (\n current === null ||\n current === undefined ||\n typeof current !== 'object'\n ) {\n return undefined;\n }\n current = (current as Record<string, unknown>)[part];\n }\n return current;\n};\n\n/**\n * Looks up a lingui message from the `messages` intlayer dictionary.\n *\n * The entire lingui catalog is stored in a single `messages` dictionary.\n * Dotted IDs (e.g. `'home.title'`) are resolved as nested paths within that\n * dictionary. Hash-style IDs (no dots) are direct top-level keys.\n */\nconst lookupMessage = (\n id: string,\n locale: LocalesValues\n): string | undefined => {\n try {\n const dictionary = getIntlayer('messages' as DictionaryKeys, locale);\n const value = navigatePath(dictionary, id);\n return typeof value === 'string' ? value : undefined;\n } catch {\n return undefined;\n }\n};\n\n/**\n * Intlayer-backed implementation of `@lingui/core`'s `I18n` class.\n *\n * - Messages are read from the `messages` intlayer dictionary.\n * - ICU MessageFormat syntax is resolved via `@intlayer/core/messageFormat`.\n * - `load()` / `loadAndActivate()` / `setMessagesCompiler()` are no-ops —\n * messages are served by intlayer's compiled dictionaries.\n * - `activate(locale)` emits `'change'` so that React consumers re-render.\n */\nexport class I18nClass extends EventEmitter<LinguiEvents> {\n private _locale: string;\n private _locales?: Locales;\n\n constructor({ locale = 'en', locales }: I18nProps = {}) {\n super();\n this._locale = typeof locale === 'string' ? locale : 'en';\n this._locales = locales;\n }\n\n get locale(): string {\n return this._locale;\n }\n\n get locales(): Locales | undefined {\n return this._locales;\n }\n\n get messages(): Messages {\n try {\n return getIntlayer(\n 'messages' as DictionaryKeys,\n this._locale as LocalesValues\n ) as Messages;\n } catch {\n return {};\n }\n }\n\n /**\n * No-op: intlayer handles message compilation at build time.\n */\n setMessagesCompiler(_compiler: MessageCompiler): this {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n '@intlayer/lingui: i18n.setMessagesCompiler() is a no-op — ' +\n 'message compilation is handled at build time by intlayer.'\n );\n }\n return this;\n }\n\n /**\n * No-op: messages are loaded automatically via intlayer dictionaries.\n */\n load(_localeOrAll: Locale | AllMessages, _messages?: Messages): void {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n '@intlayer/lingui: i18n.load() is a no-op — ' +\n 'messages are loaded automatically via intlayer dictionaries.'\n );\n }\n }\n\n /**\n * Activates the given locale (emits `'change'`).\n * The `messages` argument is ignored — intlayer handles the catalog.\n */\n loadAndActivate({\n locale,\n locales,\n }: {\n locale: Locale;\n locales?: Locales;\n messages: Messages;\n }): void {\n this.activate(locale, locales);\n }\n\n /**\n * Sets the active locale and emits `'change'` to notify React consumers.\n */\n activate(locale: Locale, locales?: Locales): void {\n this._locale = locale;\n this._locales = locales;\n this.emit('change');\n }\n\n /**\n * Translates a message descriptor or a plain ID.\n *\n * Resolution order:\n * 1. `messages` intlayer dictionary (dotted path navigation)\n * 2. `descriptor.message` or `options.message` (original source string)\n * 3. The raw `id` as fallback\n */\n _(descriptor: MessageDescriptor): string;\n _(id: MessageId, values?: Values, options?: MessageOptions): string;\n _(\n descriptorOrId: MessageDescriptor | MessageId,\n values?: Values,\n options?: MessageOptions\n ): string {\n const isDescriptor =\n typeof descriptorOrId === 'object' && descriptorOrId !== null;\n const id = isDescriptor\n ? (descriptorOrId as MessageDescriptor).id\n : (descriptorOrId as MessageId);\n const defaultMessage = isDescriptor\n ? ((descriptorOrId as MessageDescriptor).message ?? options?.message)\n : options?.message;\n const resolvedValues: Values = isDescriptor\n ? {\n ...((descriptorOrId as MessageDescriptor).values ?? {}),\n ...(values ?? {}),\n }\n : (values ?? {});\n\n const rawValue = lookupMessage(id, this._locale as LocalesValues);\n const template = rawValue ?? defaultMessage ?? id;\n\n return (\n resolveMessage(\n template,\n resolvedValues as Record<string, string | number>,\n this._locale as LocalesValues,\n 'icu'\n ) ?? id\n );\n }\n\n /**\n * Alias for `_`. Provided for lingui API compatibility.\n */\n t = (\n descriptorOrId: MessageDescriptor | MessageId,\n values?: Values,\n options?: MessageOptions\n ): string => this._(descriptorOrId as MessageId, values, options);\n\n /**\n * @deprecated Use `Intl.DateTimeFormat` directly.\n */\n date(\n value?: string | Date | number,\n format?: Intl.DateTimeFormatOptions\n ): string {\n if (value === undefined || value === null) return '';\n const dateValue =\n value instanceof Date\n ? value\n : new Date(typeof value === 'string' ? value : value);\n return new Intl.DateTimeFormat(this._locale, format).format(dateValue);\n }\n\n /**\n * @deprecated Use `Intl.NumberFormat` directly.\n */\n number(value: number | bigint, format?: Intl.NumberFormatOptions): string {\n return new Intl.NumberFormat(this._locale, format).format(value);\n }\n}\n"],"mappings":";;;;;;;;;;;AA0CA,MAAM,gBAAgB,QAAiB,SAA0B;CAC/D,IAAI,CAAC,MAAM,OAAO;CAClB,MAAM,QAAQ,KAAK,MAAM,GAAG;CAC5B,IAAI,UAAmB;CACvB,KAAK,MAAM,QAAQ,OAAO;EACxB,IACE,YAAY,QACZ,YAAY,UACZ,OAAO,YAAY,UAEnB;EAEF,UAAW,QAAoC;CACjD;CACA,OAAO;AACT;;;;;;;;AASA,MAAM,iBACJ,IACA,WACuB;CACvB,IAAI;EAEF,MAAM,QAAQ,yDADiB,YAA8B,MACzB,GAAG,EAAE;EACzC,OAAO,OAAO,UAAU,WAAW,QAAQ;CAC7C,QAAQ;EACN;CACF;AACF;;;;;;;;;;AAWA,IAAa,YAAb,cAA+BA,kCAA2B;CACxD,AAAQ;CACR,AAAQ;CAER,YAAY,EAAE,SAAS,MAAM,YAAuB,CAAC,GAAG;EACtD,MAAM;EACN,KAAK,UAAU,OAAO,WAAW,WAAW,SAAS;EACrD,KAAK,WAAW;CAClB;CAEA,IAAI,SAAiB;EACnB,OAAO,KAAK;CACd;CAEA,IAAI,UAA+B;EACjC,OAAO,KAAK;CACd;CAEA,IAAI,WAAqB;EACvB,IAAI;GACF,mDACE,YACA,KAAK,OACP;EACF,QAAQ;GACN,OAAO,CAAC;EACV;CACF;;;;CAKA,oBAAoB,WAAkC;EACpD,IAAI,QAAQ,IAAI,aAAa,eAC3B,QAAQ,KACN,qHAEF;EAEF,OAAO;CACT;;;;CAKA,KAAK,cAAoC,WAA4B;EACnE,IAAI,QAAQ,IAAI,aAAa,eAC3B,QAAQ,KACN,yGAEF;CAEJ;;;;;CAMA,gBAAgB,EACd,QACA,WAKO;EACP,KAAK,SAAS,QAAQ,OAAO;CAC/B;;;;CAKA,SAAS,QAAgB,SAAyB;EAChD,KAAK,UAAU;EACf,KAAK,WAAW;EAChB,KAAK,KAAK,QAAQ;CACpB;CAYA,EACE,gBACA,QACA,SACQ;EACR,MAAM,eACJ,OAAO,mBAAmB,YAAY,mBAAmB;EAC3D,MAAM,KAAK,eACN,eAAqC,KACrC;EACL,MAAM,iBAAiB,eACjB,eAAqC,WAAW,SAAS,UAC3D,SAAS;EACb,MAAM,iBAAyB,eAC3B;GACE,GAAK,eAAqC,UAAU,CAAC;GACrD,GAAI,UAAU,CAAC;EACjB,IACC,UAAU,CAAC;EAKhB,wDAHiB,cAAc,IAAI,KAAK,OAChB,KAAK,kBAAkB,IAK3C,gBACA,KAAK,SACL,KACF,KAAK;CAET;;;;CAKA,KACE,gBACA,QACA,YACW,KAAK,EAAE,gBAA6B,QAAQ,OAAO;;;;CAKhE,KACE,OACA,QACQ;EACR,IAAI,UAAU,UAAa,UAAU,MAAM,OAAO;EAClD,MAAM,YACJ,iBAAiB,OACb,QACA,IAAI,KAAK,OAAO,UAAU,WAAW,QAAQ,KAAK;EACxD,OAAO,IAAI,KAAK,eAAe,KAAK,SAAS,MAAM,CAAC,CAAC,OAAO,SAAS;CACvE;;;;CAKA,OAAO,OAAwB,QAA2C;EACxE,OAAO,IAAI,KAAK,aAAa,KAAK,SAAS,MAAM,CAAC,CAAC,OAAO,KAAK;CACjE;AACF"}
@@ -0,0 +1,64 @@
1
+ 'use client';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ const require_LinguiContext = require('./LinguiContext.cjs');
5
+ let react = require("react");
6
+ let react_intlayer = require("react-intlayer");
7
+ let react_jsx_runtime = require("react/jsx-runtime");
8
+
9
+ //#region src/I18nProvider.tsx
10
+ /**
11
+ * Drop-in for `@lingui/react`'s `I18nProvider`.
12
+ *
13
+ * Differences from the original:
14
+ * - Wraps children in an `IntlayerProvider` so that intlayer hooks receive the
15
+ * correct locale from the `i18n` instance.
16
+ * - Listens to the `i18n` `'change'` event to sync locale and context when
17
+ * `i18n.activate(locale)` is called at runtime.
18
+ * - The `defaultComponent` prop is forwarded but not used for rendering — it is
19
+ * stored in context for downstream `useLingui()` consumers.
20
+ *
21
+ * @example
22
+ * ```tsx
23
+ * import { i18n } from '@lingui/core';
24
+ * import { I18nProvider } from '@lingui/react';
25
+ *
26
+ * i18n.activate('fr');
27
+ *
28
+ * export default function App() {
29
+ * return (
30
+ * <I18nProvider i18n={i18n}>
31
+ * <YourApp />
32
+ * </I18nProvider>
33
+ * );
34
+ * }
35
+ * ```
36
+ */
37
+ const I18nProvider = ({ i18n, defaultComponent, children }) => {
38
+ const buildContext = (instance) => ({
39
+ i18n: instance,
40
+ _: instance._.bind(instance),
41
+ defaultComponent
42
+ });
43
+ const [linguiContext, setLinguiContext] = (0, react.useState)(() => buildContext(i18n));
44
+ const [locale, setLocale] = (0, react.useState)(i18n.locale);
45
+ (0, react.useEffect)(() => {
46
+ setLinguiContext(buildContext(i18n));
47
+ setLocale(i18n.locale);
48
+ return i18n.on("change", () => {
49
+ setLinguiContext(buildContext(i18n));
50
+ setLocale(i18n.locale);
51
+ });
52
+ }, [i18n]);
53
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_LinguiContext.LinguiContext.Provider, {
54
+ value: linguiContext,
55
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_intlayer.IntlayerProvider, {
56
+ locale,
57
+ children
58
+ })
59
+ });
60
+ };
61
+
62
+ //#endregion
63
+ exports.I18nProvider = I18nProvider;
64
+ //# sourceMappingURL=I18nProvider.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"I18nProvider.cjs","names":["LinguiContext","IntlayerProvider"],"sources":["../../src/I18nProvider.tsx"],"sourcesContent":["'use client';\n\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport type { I18n } from '@lingui/core';\nimport type { I18nProviderProps } from '@lingui/react';\nimport { type JSX, useEffect, useState } from 'react';\nimport { IntlayerProvider } from 'react-intlayer';\nimport { LinguiContext } from './LinguiContext';\n\n/**\n * Drop-in for `@lingui/react`'s `I18nProvider`.\n *\n * Differences from the original:\n * - Wraps children in an `IntlayerProvider` so that intlayer hooks receive the\n * correct locale from the `i18n` instance.\n * - Listens to the `i18n` `'change'` event to sync locale and context when\n * `i18n.activate(locale)` is called at runtime.\n * - The `defaultComponent` prop is forwarded but not used for rendering — it is\n * stored in context for downstream `useLingui()` consumers.\n *\n * @example\n * ```tsx\n * import { i18n } from '@lingui/core';\n * import { I18nProvider } from '@lingui/react';\n *\n * i18n.activate('fr');\n *\n * export default function App() {\n * return (\n * <I18nProvider i18n={i18n}>\n * <YourApp />\n * </I18nProvider>\n * );\n * }\n * ```\n */\nexport const I18nProvider = ({\n i18n,\n defaultComponent,\n children,\n}: I18nProviderProps): JSX.Element | null => {\n const buildContext = (instance: I18n) => ({\n i18n: instance,\n _: instance._.bind(instance),\n defaultComponent,\n });\n\n const [linguiContext, setLinguiContext] = useState(() => buildContext(i18n));\n const [locale, setLocale] = useState<string>(i18n.locale);\n\n useEffect(() => {\n setLinguiContext(buildContext(i18n));\n setLocale(i18n.locale);\n\n return i18n.on('change', () => {\n setLinguiContext(buildContext(i18n));\n setLocale(i18n.locale);\n });\n // defaultComponent intentionally excluded — changes to it require remounting anyway\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [i18n]);\n\n return (\n <LinguiContext.Provider value={linguiContext}>\n <IntlayerProvider locale={locale as LocalesValues}>\n {children}\n </IntlayerProvider>\n </LinguiContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,gBAAgB,EAC3B,MACA,kBACA,eAC2C;CAC3C,MAAM,gBAAgB,cAAoB;EACxC,MAAM;EACN,GAAG,SAAS,EAAE,KAAK,QAAQ;EAC3B;CACF;CAEA,MAAM,CAAC,eAAe,8CAAmC,aAAa,IAAI,CAAC;CAC3E,MAAM,CAAC,QAAQ,iCAA8B,KAAK,MAAM;CAExD,2BAAgB;EACd,iBAAiB,aAAa,IAAI,CAAC;EACnC,UAAU,KAAK,MAAM;EAErB,OAAO,KAAK,GAAG,gBAAgB;GAC7B,iBAAiB,aAAa,IAAI,CAAC;GACnC,UAAU,KAAK,MAAM;EACvB,CAAC;CAGH,GAAG,CAAC,IAAI,CAAC;CAET,OACE,2CAACA,oCAAc,UAAf;EAAwB,OAAO;YAC7B,2CAACC,iCAAD;GAA0B;GACvB;EACe;CACI;AAE5B"}
@@ -0,0 +1,23 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ let react = require("react");
3
+
4
+ //#region src/LinguiContext.tsx
5
+ /**
6
+ * Drop-in for `@lingui/react`'s `LinguiContext`.
7
+ *
8
+ * Provides the active `I18n` instance and the `_` translation function
9
+ * to all descendant components.
10
+ *
11
+ * @example
12
+ * ```tsx
13
+ * import { useContext } from 'react';
14
+ * import { LinguiContext } from '@lingui/react';
15
+ *
16
+ * const { i18n } = useContext(LinguiContext)!;
17
+ * ```
18
+ */
19
+ const LinguiContext = (0, react.createContext)(null);
20
+
21
+ //#endregion
22
+ exports.LinguiContext = LinguiContext;
23
+ //# sourceMappingURL=LinguiContext.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LinguiContext.cjs","names":[],"sources":["../../src/LinguiContext.tsx"],"sourcesContent":["import type { I18nContext } from '@lingui/react';\nimport { createContext } from 'react';\n\n/**\n * Drop-in for `@lingui/react`'s `LinguiContext`.\n *\n * Provides the active `I18n` instance and the `_` translation function\n * to all descendant components.\n *\n * @example\n * ```tsx\n * import { useContext } from 'react';\n * import { LinguiContext } from '@lingui/react';\n *\n * const { i18n } = useContext(LinguiContext)!;\n * ```\n */\nexport const LinguiContext = createContext<I18nContext | null>(null);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,MAAa,yCAAkD,IAAI"}