@intlayer/docs 8.0.0 → 8.0.1-canary.1

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 (172) hide show
  1. package/dist/cjs/generated/docs.entry.cjs +160 -0
  2. package/dist/cjs/generated/docs.entry.cjs.map +1 -1
  3. package/dist/esm/generated/docs.entry.mjs +160 -0
  4. package/dist/esm/generated/docs.entry.mjs.map +1 -1
  5. package/dist/types/generated/docs.entry.d.ts +8 -0
  6. package/dist/types/generated/docs.entry.d.ts.map +1 -1
  7. package/docs/ar/intlayer_with_adonisjs.md +394 -0
  8. package/docs/ar/intlayer_with_hono.md +223 -0
  9. package/docs/ar/intlayer_with_vite+preact.md +317 -675
  10. package/docs/ar/packages/adonis-intlayer/exports.md +50 -0
  11. package/docs/ar/packages/adonis-intlayer/intlayer.md +54 -0
  12. package/docs/ar/packages/adonis-intlayer/t.md +149 -0
  13. package/docs/ar/packages/hono-intlayer/exports.md +59 -0
  14. package/docs/ar/packages/hono-intlayer/intlayer.md +60 -0
  15. package/docs/ar/packages/hono-intlayer/t.md +268 -0
  16. package/docs/de/intlayer_with_adonisjs.md +392 -0
  17. package/docs/de/intlayer_with_hono.md +418 -0
  18. package/docs/de/intlayer_with_vite+preact.md +272 -632
  19. package/docs/de/packages/adonis-intlayer/exports.md +50 -0
  20. package/docs/de/packages/adonis-intlayer/intlayer.md +54 -0
  21. package/docs/de/packages/adonis-intlayer/t.md +149 -0
  22. package/docs/de/packages/hono-intlayer/exports.md +59 -0
  23. package/docs/de/packages/hono-intlayer/intlayer.md +59 -0
  24. package/docs/de/packages/hono-intlayer/t.md +316 -0
  25. package/docs/en/index.md +8 -0
  26. package/docs/en/intlayer_with_adonisjs.md +388 -0
  27. package/docs/en/intlayer_with_hono.md +418 -0
  28. package/docs/en/intlayer_with_vite+preact.md +171 -556
  29. package/docs/en/introduction.md +1 -0
  30. package/docs/en/packages/adonis-intlayer/exports.md +50 -0
  31. package/docs/en/packages/adonis-intlayer/intlayer.md +54 -0
  32. package/docs/en/packages/adonis-intlayer/t.md +149 -0
  33. package/docs/en/packages/hono-intlayer/exports.md +59 -0
  34. package/docs/en/packages/hono-intlayer/intlayer.md +59 -0
  35. package/docs/en/packages/hono-intlayer/t.md +316 -0
  36. package/docs/en-GB/intlayer_with_adonisjs.md +394 -0
  37. package/docs/en-GB/intlayer_with_hono.md +418 -0
  38. package/docs/en-GB/intlayer_with_vite+preact.md +236 -583
  39. package/docs/en-GB/packages/adonis-intlayer/exports.md +50 -0
  40. package/docs/en-GB/packages/adonis-intlayer/intlayer.md +54 -0
  41. package/docs/en-GB/packages/adonis-intlayer/t.md +149 -0
  42. package/docs/en-GB/packages/hono-intlayer/exports.md +59 -0
  43. package/docs/en-GB/packages/hono-intlayer/intlayer.md +59 -0
  44. package/docs/en-GB/packages/hono-intlayer/t.md +316 -0
  45. package/docs/es/intlayer_with_adonisjs.md +388 -0
  46. package/docs/es/intlayer_with_hono.md +418 -0
  47. package/docs/es/intlayer_with_vite+preact.md +286 -650
  48. package/docs/es/packages/adonis-intlayer/exports.md +50 -0
  49. package/docs/es/packages/adonis-intlayer/intlayer.md +54 -0
  50. package/docs/es/packages/adonis-intlayer/t.md +149 -0
  51. package/docs/es/packages/hono-intlayer/exports.md +59 -0
  52. package/docs/es/packages/hono-intlayer/intlayer.md +59 -0
  53. package/docs/es/packages/hono-intlayer/t.md +316 -0
  54. package/docs/fr/intlayer_with_adonisjs.md +388 -0
  55. package/docs/fr/intlayer_with_hono.md +418 -0
  56. package/docs/fr/intlayer_with_vite+preact.md +274 -614
  57. package/docs/fr/packages/adonis-intlayer/exports.md +50 -0
  58. package/docs/fr/packages/adonis-intlayer/intlayer.md +54 -0
  59. package/docs/fr/packages/adonis-intlayer/t.md +149 -0
  60. package/docs/fr/packages/hono-intlayer/exports.md +59 -0
  61. package/docs/fr/packages/hono-intlayer/intlayer.md +59 -0
  62. package/docs/fr/packages/hono-intlayer/t.md +316 -0
  63. package/docs/hi/intlayer_with_adonisjs.md +394 -0
  64. package/docs/hi/intlayer_with_hono.md +227 -0
  65. package/docs/hi/intlayer_with_vite+preact.md +304 -680
  66. package/docs/hi/packages/adonis-intlayer/exports.md +50 -0
  67. package/docs/hi/packages/adonis-intlayer/intlayer.md +54 -0
  68. package/docs/hi/packages/adonis-intlayer/t.md +149 -0
  69. package/docs/hi/packages/hono-intlayer/exports.md +59 -0
  70. package/docs/hi/packages/hono-intlayer/intlayer.md +60 -0
  71. package/docs/hi/packages/hono-intlayer/t.md +268 -0
  72. package/docs/id/intlayer_with_adonisjs.md +394 -0
  73. package/docs/id/intlayer_with_hono.md +227 -0
  74. package/docs/id/intlayer_with_vite+preact.md +297 -697
  75. package/docs/id/packages/adonis-intlayer/exports.md +50 -0
  76. package/docs/id/packages/adonis-intlayer/intlayer.md +54 -0
  77. package/docs/id/packages/adonis-intlayer/t.md +149 -0
  78. package/docs/id/packages/hono-intlayer/exports.md +59 -0
  79. package/docs/id/packages/hono-intlayer/intlayer.md +60 -0
  80. package/docs/id/packages/hono-intlayer/t.md +268 -0
  81. package/docs/it/intlayer_with_adonisjs.md +394 -0
  82. package/docs/it/intlayer_with_hono.md +227 -0
  83. package/docs/it/intlayer_with_vite+preact.md +290 -659
  84. package/docs/it/packages/adonis-intlayer/exports.md +50 -0
  85. package/docs/it/packages/adonis-intlayer/intlayer.md +54 -0
  86. package/docs/it/packages/adonis-intlayer/t.md +149 -0
  87. package/docs/it/packages/hono-intlayer/exports.md +59 -0
  88. package/docs/it/packages/hono-intlayer/intlayer.md +60 -0
  89. package/docs/it/packages/hono-intlayer/t.md +268 -0
  90. package/docs/ja/intlayer_with_adonisjs.md +394 -0
  91. package/docs/ja/intlayer_with_hono.md +227 -0
  92. package/docs/ja/intlayer_with_vite+preact.md +307 -662
  93. package/docs/ja/packages/adonis-intlayer/exports.md +50 -0
  94. package/docs/ja/packages/adonis-intlayer/intlayer.md +54 -0
  95. package/docs/ja/packages/adonis-intlayer/t.md +149 -0
  96. package/docs/ja/packages/hono-intlayer/exports.md +59 -0
  97. package/docs/ja/packages/hono-intlayer/intlayer.md +60 -0
  98. package/docs/ja/packages/hono-intlayer/t.md +268 -0
  99. package/docs/ko/intlayer_with_adonisjs.md +394 -0
  100. package/docs/ko/intlayer_with_hono.md +227 -0
  101. package/docs/ko/intlayer_with_vite+preact.md +303 -703
  102. package/docs/ko/packages/adonis-intlayer/exports.md +50 -0
  103. package/docs/ko/packages/adonis-intlayer/intlayer.md +54 -0
  104. package/docs/ko/packages/adonis-intlayer/t.md +149 -0
  105. package/docs/ko/packages/hono-intlayer/exports.md +59 -0
  106. package/docs/ko/packages/hono-intlayer/intlayer.md +60 -0
  107. package/docs/ko/packages/hono-intlayer/t.md +268 -0
  108. package/docs/pl/intlayer_with_adonisjs.md +394 -0
  109. package/docs/pl/intlayer_with_hono.md +227 -0
  110. package/docs/pl/intlayer_with_vite+preact.md +289 -690
  111. package/docs/pl/packages/adonis-intlayer/exports.md +50 -0
  112. package/docs/pl/packages/adonis-intlayer/intlayer.md +54 -0
  113. package/docs/pl/packages/adonis-intlayer/t.md +149 -0
  114. package/docs/pl/packages/hono-intlayer/exports.md +59 -0
  115. package/docs/pl/packages/hono-intlayer/intlayer.md +60 -0
  116. package/docs/pl/packages/hono-intlayer/t.md +268 -0
  117. package/docs/pt/intlayer_with_adonisjs.md +394 -0
  118. package/docs/pt/intlayer_with_hono.md +227 -0
  119. package/docs/pt/intlayer_with_vite+preact.md +275 -637
  120. package/docs/pt/packages/adonis-intlayer/exports.md +50 -0
  121. package/docs/pt/packages/adonis-intlayer/intlayer.md +54 -0
  122. package/docs/pt/packages/adonis-intlayer/t.md +149 -0
  123. package/docs/pt/packages/hono-intlayer/exports.md +59 -0
  124. package/docs/pt/packages/hono-intlayer/intlayer.md +60 -0
  125. package/docs/pt/packages/hono-intlayer/t.md +268 -0
  126. package/docs/ru/intlayer_with_adonisjs.md +393 -0
  127. package/docs/ru/intlayer_with_hono.md +223 -0
  128. package/docs/ru/intlayer_with_vite+preact.md +319 -683
  129. package/docs/ru/packages/adonis-intlayer/exports.md +50 -0
  130. package/docs/ru/packages/adonis-intlayer/intlayer.md +54 -0
  131. package/docs/ru/packages/adonis-intlayer/t.md +149 -0
  132. package/docs/ru/packages/hono-intlayer/exports.md +59 -0
  133. package/docs/ru/packages/hono-intlayer/intlayer.md +60 -0
  134. package/docs/ru/packages/hono-intlayer/t.md +268 -0
  135. package/docs/tr/intlayer_with_adonisjs.md +394 -0
  136. package/docs/tr/intlayer_with_hono.md +227 -0
  137. package/docs/tr/intlayer_with_vite+preact.md +332 -665
  138. package/docs/tr/packages/adonis-intlayer/exports.md +50 -0
  139. package/docs/tr/packages/adonis-intlayer/intlayer.md +54 -0
  140. package/docs/tr/packages/adonis-intlayer/t.md +149 -0
  141. package/docs/tr/packages/hono-intlayer/exports.md +59 -0
  142. package/docs/tr/packages/hono-intlayer/intlayer.md +60 -0
  143. package/docs/tr/packages/hono-intlayer/t.md +268 -0
  144. package/docs/uk/intlayer_with_adonisjs.md +394 -0
  145. package/docs/uk/intlayer_with_hono.md +227 -0
  146. package/docs/uk/intlayer_with_vite+preact.md +228 -626
  147. package/docs/uk/packages/adonis-intlayer/exports.md +50 -0
  148. package/docs/uk/packages/adonis-intlayer/intlayer.md +54 -0
  149. package/docs/uk/packages/adonis-intlayer/t.md +149 -0
  150. package/docs/uk/packages/hono-intlayer/exports.md +59 -0
  151. package/docs/uk/packages/hono-intlayer/intlayer.md +60 -0
  152. package/docs/uk/packages/hono-intlayer/t.md +268 -0
  153. package/docs/vi/intlayer_with_adonisjs.md +394 -0
  154. package/docs/vi/intlayer_with_hono.md +227 -0
  155. package/docs/vi/intlayer_with_vite+preact.md +294 -679
  156. package/docs/vi/packages/adonis-intlayer/exports.md +50 -0
  157. package/docs/vi/packages/adonis-intlayer/intlayer.md +54 -0
  158. package/docs/vi/packages/adonis-intlayer/t.md +149 -0
  159. package/docs/vi/packages/hono-intlayer/exports.md +59 -0
  160. package/docs/vi/packages/hono-intlayer/intlayer.md +60 -0
  161. package/docs/vi/packages/hono-intlayer/t.md +268 -0
  162. package/docs/zh/intlayer_with_adonisjs.md +393 -0
  163. package/docs/zh/intlayer_with_hono.md +418 -0
  164. package/docs/zh/intlayer_with_vite+preact.md +338 -743
  165. package/docs/zh/packages/adonis-intlayer/exports.md +50 -0
  166. package/docs/zh/packages/adonis-intlayer/intlayer.md +54 -0
  167. package/docs/zh/packages/adonis-intlayer/t.md +149 -0
  168. package/docs/zh/packages/hono-intlayer/exports.md +59 -0
  169. package/docs/zh/packages/hono-intlayer/intlayer.md +60 -0
  170. package/docs/zh/packages/hono-intlayer/t.md +294 -0
  171. package/package.json +6 -6
  172. package/src/generated/docs.entry.ts +160 -0
package/docs/en/index.md CHANGED
@@ -107,6 +107,7 @@ We’ve built Intlayer with flexibility in mind, offering seamless integration a
107
107
  - **[Intlayer with Nuxt](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_with_nuxt.md)**
108
108
  - **[Intlayer with Express](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_with_express.md)**
109
109
  - **[Intlayer with NestJS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_with_nestjs.md)**
110
+ - **[Intlayer with Hono](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_with_hono.md)**
110
111
  - **[Intlayer with Angular](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_with_angular.md)**
111
112
 
112
113
  Each integration guide includes best practices for using Intlayer’s features, like **server-side rendering**, **dynamic routing**, or **client-side rendering**, so you can maintain a fast, SEO-friendly, and highly scalable application.
@@ -138,6 +139,13 @@ Leverage Intlayer within **Express**-based apps:
138
139
  - **[t](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/packages/express-intlayer/t.md)**
139
140
  A minimal, straightforward translation helper for your server routes and views.
140
141
 
142
+ ### `hono-intlayer`
143
+
144
+ Leverage Intlayer within **Hono**-based apps:
145
+
146
+ - **[t](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/packages/hono-intlayer/t.md)**
147
+ A minimal, straightforward translation helper for your server routes.
148
+
141
149
  ### `react-intlayer`
142
150
 
143
151
  Enhance your **React** applications with powerful hooks:
@@ -0,0 +1,388 @@
1
+ ---
2
+ createdAt: 2025-08-23
3
+ updatedAt: 2025-12-30
4
+ title: AdonisJS i18n - How to translate your AdonisJS app – guide 2026
5
+ description: Discover how to make your AdonisJS backend multilingual. Follow the documentation to internationalize (i18n) and translate it.
6
+ keywords:
7
+ - Internationalization
8
+ - Documentation
9
+ - Intlayer
10
+ - AdonisJS
11
+ - JavaScript
12
+ - Backend
13
+ slugs:
14
+ - doc
15
+ - environment
16
+ - adonisjs
17
+ applicationTemplate: https://github.com/aymericzip/intlayer-adonisjs-template
18
+ history:
19
+ - version: 8.0.0
20
+ date: 2025-12-30
21
+ changes: Init history
22
+ ---
23
+
24
+ # Translate your AdonisJS backend website using Intlayer | Internationalization (i18n)
25
+
26
+ `adonis-intlayer` is a powerful internationalization (i18n) package for AdonisJS applications, designed to make your backend services globally accessible by providing localized responses based on the client's preferences.
27
+
28
+ ### Practical Use Cases
29
+
30
+ - **Displaying Backend Errors in User's Language**: When an error occurs, displaying messages in the user's native language improves understanding and reduces frustration. This is especially useful for dynamic error messages that might be shown in front-end components like toasts or modals.
31
+
32
+ - **Retrieving Multilingual Content**: For applications pulling content from a database, internationalization ensures that you can serve this content in multiple languages. This is crucial for platforms like e-commerce sites or content management systems that need to display product descriptions, articles, and other content in the language preferred by the user.
33
+
34
+ - **Sending Multilingual Emails**: Whether it's transactional emails, marketing campaigns, or notifications, sending emails in the recipient’s language can significantly increase engagement and effectiveness.
35
+
36
+ - **Multilingual Push Notifications**: For mobile applications, sending push notifications in a user's preferred language can enhance interaction and retention. This personal touch can make notifications feel more relevant and actionable.
37
+
38
+ - **Other Communications**: Any form of communication from the backend, such as SMS messages, system alerts, or user interface updates, benefits from being in the user's language, ensuring clarity and enhancing the overall user experience.
39
+
40
+ By internationalizing the backend, your application not only respects cultural differences but also aligns better with global market needs, making it a key step in scaling your services worldwide.
41
+
42
+ ## Getting Started
43
+
44
+ ### Installation
45
+
46
+ To begin using `adonis-intlayer`, install the package using npm:
47
+
48
+ ```bash packageManager="npm"
49
+ npm install intlayer adonis-intlayer
50
+ npx intlayer init
51
+ ```
52
+
53
+ ```bash packageManager="pnpm"
54
+ pnpm add intlayer adonis-intlayer
55
+ pnpm intlayer init
56
+ ```
57
+
58
+ ```bash packageManager="yarn"
59
+ yarn add intlayer adonis-intlayer
60
+ yarn intlayer init
61
+ ```
62
+
63
+ ```bash packageManager="bun"
64
+ bun add intlayer adonis-intlayer
65
+ bunx intlayer init
66
+ ```
67
+
68
+ ### Setup
69
+
70
+ Configure the internationalization settings by creating an `intlayer.config.ts` in your project root:
71
+
72
+ ```typescript fileName="intlayer.config.ts" codeFormat="typescript"
73
+ import { Locales, type IntlayerConfig } from "intlayer";
74
+
75
+ const config: IntlayerConfig = {
76
+ internationalization: {
77
+ locales: [
78
+ Locales.ENGLISH,
79
+ Locales.RUSSIAN,
80
+ Locales.JAPANESE,
81
+ Locales.FRENCH,
82
+ Locales.KOREAN,
83
+ Locales.CHINESE,
84
+ Locales.SPANISH,
85
+ Locales.GERMAN,
86
+ Locales.ARABIC,
87
+ Locales.ITALIAN,
88
+ Locales.ENGLISH_UNITED_KINGDOM,
89
+ Locales.PORTUGUESE,
90
+ Locales.HINDI,
91
+ Locales.TURKISH,
92
+ Locales.POLISH,
93
+ Locales.INDONESIAN,
94
+ Locales.VIETNAMESE,
95
+ Locales.UKRAINIAN,
96
+ ],
97
+ defaultLocale: Locales.ENGLISH,
98
+ },
99
+ };
100
+
101
+ export default config;
102
+ ```
103
+
104
+ ```javascript fileName="intlayer.config.mjs" codeFormat="esm"
105
+ import { Locales } from "intlayer";
106
+
107
+ /** @type {import('intlayer').IntlayerConfig} */
108
+ const config = {
109
+ internationalization: {
110
+ locales: [
111
+ Locales.ENGLISH,
112
+ Locales.RUSSIAN,
113
+ Locales.JAPANESE,
114
+ Locales.FRENCH,
115
+ Locales.KOREAN,
116
+ Locales.CHINESE,
117
+ Locales.SPANISH,
118
+ Locales.GERMAN,
119
+ Locales.ARABIC,
120
+ Locales.ITALIAN,
121
+ Locales.ENGLISH_UNITED_KINGDOM,
122
+ Locales.PORTUGUESE,
123
+ Locales.HINDI,
124
+ Locales.TURKISH,
125
+ Locales.POLISH,
126
+ Locales.INDONESIAN,
127
+ Locales.VIETNAMESE,
128
+ Locales.UKRAINIAN,
129
+ ],
130
+ defaultLocale: Locales.ENGLISH,
131
+ },
132
+ };
133
+
134
+ export default config;
135
+ ```
136
+
137
+ ```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
138
+ const { Locales } = require("intlayer");
139
+
140
+ /** @type {import('intlayer').IntlayerConfig} */
141
+ const config = {
142
+ internationalization: {
143
+ locales: [
144
+ Locales.ENGLISH,
145
+ Locales.RUSSIAN,
146
+ Locales.JAPANESE,
147
+ Locales.FRENCH,
148
+ Locales.KOREAN,
149
+ Locales.CHINESE,
150
+ Locales.SPANISH,
151
+ Locales.GERMAN,
152
+ Locales.ARABIC,
153
+ Locales.ITALIAN,
154
+ Locales.ENGLISH_UNITED_KINGDOM,
155
+ Locales.PORTUGUESE,
156
+ Locales.HINDI,
157
+ Locales.TURKISH,
158
+ Locales.POLISH,
159
+ Locales.INDONESIAN,
160
+ Locales.VIETNAMESE,
161
+ Locales.UKRAINIAN,
162
+ ],
163
+ defaultLocale: Locales.ENGLISH,
164
+ },
165
+ };
166
+
167
+ module.exports = config;
168
+ ```
169
+
170
+ ### Declare Your Content
171
+
172
+ Create and manage your content declarations to store translations:
173
+
174
+ ```typescript fileName="app/index.content.ts" contentDeclarationFormat="typescript"
175
+ import { t, type Dictionary } from "intlayer";
176
+
177
+ const indexContent = {
178
+ key: "index",
179
+ content: {
180
+ exampleOfContent: t({
181
+ en: "Example of returned content in English",
182
+ fr: "Exemple de contenu renvoyé en français",
183
+ "es-ES": "Ejemplo de contenido devuelto en español (España)",
184
+ "es-MX": "Ejemplo de contenido devuelto en español (México)",
185
+ }),
186
+ },
187
+ } satisfies Dictionary;
188
+
189
+ export default indexContent;
190
+ ```
191
+
192
+ ```javascript fileName="app/index.content.mjs" contentDeclarationFormat="esm"
193
+ import { t } from "intlayer";
194
+
195
+ /** @type {import('intlayer').Dictionary} */
196
+ const indexContent = {
197
+ key: "index",
198
+ content: {
199
+ exampleOfContent: t({
200
+ en: "Example of returned content in English",
201
+ fr: "Exemple de contenu renvoyé en français",
202
+ "es-ES": "Ejemplo de contenido devuelto en español (España)",
203
+ "es-MX": "Ejemplo de contenido devuelto en español (México)",
204
+ }),
205
+ },
206
+ };
207
+
208
+ export default indexContent;
209
+ ```
210
+
211
+ ```javascript fileName="app/index.content.cjs" contentDeclarationFormat="commonjs"
212
+ const { t } = require("intlayer");
213
+
214
+ /** @type {import('intlayer').Dictionary} */
215
+ const indexContent = {
216
+ key: "index",
217
+ content: {
218
+ exampleOfContent: t({
219
+ en: "Example of returned content in English",
220
+ fr: "Exemple de contenu renvoyé en français",
221
+ "es-ES": "Ejemplo de contenido devuelto en español (España)",
222
+ "es-MX": "Ejemplo de contenido devuelto en español (México)",
223
+ }),
224
+ },
225
+ };
226
+
227
+ module.exports = indexContent;
228
+ ```
229
+
230
+ ```json fileName="app/index.content.json" contentDeclarationFormat="json"
231
+ {
232
+ "$schema": "https://intlayer.org/schema.json",
233
+ "key": "index",
234
+ "content": {
235
+ "exampleOfContent": {
236
+ "nodeType": "translation",
237
+ "translation": {
238
+ "en": "Example of returned content in English",
239
+ "fr": "Exemple de contenu renvoyé en français",
240
+ "es-ES": "Ejemplo de contenido devuelto en español (España)",
241
+ "es-MX": "Ejemplo de contenido devuelto en español (México)"
242
+ }
243
+ }
244
+ }
245
+ }
246
+ ```
247
+
248
+ > Your content declarations can be defined anywhere in your application as soon as they are included into the `contentDir` directory (by default, `./src` or `./app`). And match the content declaration file extension (by default, `.content.{json,ts,tsx,js,jsx,mjs,cjs}`).
249
+
250
+ > For more details, refer to the [content declaration documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/content_file.md).
251
+
252
+ ### AdonisJS Application Setup
253
+
254
+ Setup your AdonisJS application to use `adonis-intlayer`.
255
+
256
+ #### Register the middleware
257
+
258
+ First, you need to register the `intlayer` middleware in your application.
259
+
260
+ ```typescript fileName="start/kernel.ts"
261
+ router.use([() => import("adonis-intlayer/middleware")]);
262
+ ```
263
+
264
+ #### Define your routes
265
+
266
+ ```typescript fileName="start/routes.ts"
267
+ import router from "@adonisjs/core/services/router";
268
+ import { t, getIntlayer, getDictionary } from "adonis-intlayer";
269
+ import indexContent from "../app/index.content";
270
+
271
+ router.get("/t_example", async () => {
272
+ return t({
273
+ en: "Example of returned content in English",
274
+ fr: "Exemple de contenu renvoyé en français",
275
+ "es-ES": "Ejemplo de contenido devuelto en español (España)",
276
+ "es-MX": "Ejemplo de contenido devuelto en español (México)",
277
+ });
278
+ });
279
+
280
+ router.get("/getIntlayer_example", async () => {
281
+ return getIntlayer("index").exampleOfContent;
282
+ });
283
+
284
+ router.get("/getDictionary_example", async () => {
285
+ return getDictionary(indexContent).exampleOfContent;
286
+ });
287
+ ```
288
+
289
+ #### Functions
290
+
291
+ `adonis-intlayer` exports several functions to handle internationalization in your application:
292
+
293
+ - `t(content, locale?)`: Basic translation function.
294
+ - `getIntlayer(key, locale?)`: Retrieve content by key from your dictionaries.
295
+ - `getDictionary(dictionary, locale?)`: Retrieve content from a specific dictionary object.
296
+ - `getLocale()`: Retrieve the current locale from the request context.
297
+
298
+ #### Use in Controllers
299
+
300
+ ```typescript fileName="app/controllers/example_controller.ts"
301
+ import type { HttpContext } from "@adonisjs/core/http";
302
+ import { t } from "adonis-intlayer";
303
+
304
+ export default class ExampleController {
305
+ async index({ response }: HttpContext) {
306
+ return response.send(
307
+ t({
308
+ en: "Hello from controller",
309
+ fr: "Bonjour depuis le contrôleur",
310
+ })
311
+ );
312
+ }
313
+ }
314
+ ```
315
+
316
+ ### Compatibility
317
+
318
+ `adonis-intlayer` is fully compatible with:
319
+
320
+ - [`react-intlayer`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/packages/react-intlayer/index.md) for React applications
321
+ - [`next-intlayer`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/packages/next-intlayer/index.md) for Next.js applications
322
+ - [`vite-intlayer`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/packages/vite-intlayer/index.md) for Vite applications
323
+
324
+ It also works seamlessly with any internationalization solution across various environments, including browsers and API requests. You can customize the middleware to detect locale through headers or cookies:
325
+
326
+ ```typescript fileName="intlayer.config.ts" codeFormat="typescript"
327
+ import { Locales, type IntlayerConfig } from "intlayer";
328
+
329
+ const config: IntlayerConfig = {
330
+ // ... Other configuration options
331
+ middleware: {
332
+ headerName: "my-locale-header",
333
+ cookieName: "my-locale-cookie",
334
+ },
335
+ };
336
+
337
+ export default config;
338
+ ```
339
+
340
+ By default, `adonis-intlayer` will interpret the `Accept-Language` header to determine the client's preferred language.
341
+
342
+ > For more information on configuration and advanced topics, visit our [documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/configuration.md).
343
+
344
+ ### Configure TypeScript
345
+
346
+ `adonis-intlayer` leverages the robust capabilities of TypeScript to enhance the internationalization process. TypeScript's static typing ensures that every translation key is accounted for, reducing the risk of missing translations and improving maintainability.
347
+
348
+ ![Autocompletion](https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true)
349
+
350
+ ![Translation error](https://github.com/aymericzip/intlayer/blob/main/docs/assets/translation_error.png?raw=true)
351
+
352
+ Ensure the autogenerated types (by default at ./types/intlayer.d.ts) are included in your tsconfig.json file.
353
+
354
+ ```json5 fileName="tsconfig.json"
355
+ {
356
+ // ... Your existing TypeScript configurations
357
+ "include": [
358
+ // ... Your existing TypeScript configurations
359
+ ".intlayer/**/*.ts", // Include the auto-generated types
360
+ ],
361
+ }
362
+ ```
363
+
364
+ ### VS Code Extension
365
+
366
+ To improve your development experience with Intlayer, you can install the official **Intlayer VS Code Extension**.
367
+
368
+ [Install from the VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
369
+
370
+ This extension provides:
371
+
372
+ - **Autocompletion** for translation keys.
373
+ - **Real-time error detection** for missing translations.
374
+ - **Inline previews** of translated content.
375
+ - **Quick actions** to easily create and update translations.
376
+
377
+ For more details on how to use the extension, refer to the [Intlayer VS Code Extension documentation](https://intlayer.org/doc/vs-code-extension).
378
+
379
+ ### Git Configuration
380
+
381
+ It is recommended to ignore the files generated by Intlayer. This allows you to avoid committing them to your Git repository.
382
+
383
+ To do this, you can add the following instructions to your `.gitignore` file:
384
+
385
+ ```plaintext fileName=".gitignore"
386
+ # Ignore the files generated by Intlayer
387
+ .intlayer
388
+ ```