@intlayer/docs 8.0.0 → 8.0.1-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 (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
@@ -204,6 +204,7 @@ We’ve built Intlayer with flexibility in mind, offering seamless integration a
204
204
  - **[Intlayer with SvelteKit](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_with_svelte_kit.md)**
205
205
  - **[Intlayer with Express](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_with_express.md)**
206
206
  - **[Intlayer with NestJS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_with_nestjs.md)**
207
+ - **[Intlayer with Hono](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_with_hono.md)**
207
208
  - **[Intlayer with Angular](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_with_angular.md)**
208
209
 
209
210
  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.
@@ -0,0 +1,50 @@
1
+ ---
2
+ createdAt: 2026-01-30
3
+ updatedAt: 2026-01-30
4
+ title: adonis-intlayer Package Documentation
5
+ description: AdonisJS middleware for Intlayer, providing translation functions and locale detection.
6
+ keywords:
7
+ - adonis-intlayer
8
+ - adonisjs
9
+ - middleware
10
+ - internationalization
11
+ - i18n
12
+ slugs:
13
+ - doc
14
+ - packages
15
+ - adonis-intlayer
16
+ - exports
17
+ history:
18
+ - version: 8.0.0
19
+ date: 2026-01-30
20
+ changes: Initial documentation
21
+ ---
22
+
23
+ # adonis-intlayer Package
24
+
25
+ The `adonis-intlayer` package provides a middleware for AdonisJS applications to handle internationalization. It detects the user's locale and provides translation functions.
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ npm install adonis-intlayer
31
+ ```
32
+
33
+ ## Exports
34
+
35
+ ### Middleware
36
+
37
+ The package provides an AdonisJS middleware to handle internationalization.
38
+
39
+ | Function | Description | Related Doc |
40
+ | -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
41
+ | `IntlayerMiddleware` | AdonisJS middleware that detects the user's locale and populates the request context with Intlayer data. It also sets up a CLS (Async Local Storage) namespace for request lifecycle access, enabling the use of global functions like `t`, `getIntlayer`, etc. | [intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/packages/adonis-intlayer/intlayer.md) |
42
+
43
+ ### Functions
44
+
45
+ | Function | Description | Related Doc |
46
+ | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ |
47
+ | `t` | Translation function that retrieves content for the current locale. Works within the request lifecycle managed by the `intlayer` middleware. Uses CLS (Async Local Storage) to access request context. | [translation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/translation.md) |
48
+ | `getIntlayer` | Retrieves a dictionary by its key from the generated declaration and returns its content for the specified locale. Optimized version of `getDictionary`. Uses CLS to access request context. | - |
49
+ | `getDictionary` | Processes dictionary objects and returns content for the specified locale. Processes `t()` translations, enumerations, markdown, HTML, etc. Uses CLS to access request context. | - |
50
+ | `getLocale` | Retrieves the current locale from the request context using CLS. | - |
@@ -0,0 +1,54 @@
1
+ ---
2
+ createdAt: 2026-01-30
3
+ updatedAt: 2026-01-30
4
+ title: intlayer AdonisJS Middleware Documentation | adonis-intlayer
5
+ description: See how to use the intlayer middleware for adonis-intlayer package
6
+ keywords:
7
+ - intlayer
8
+ - adonisjs
9
+ - middleware
10
+ - Intlayer
11
+ - Internationalization
12
+ - Documentation
13
+ slugs:
14
+ - doc
15
+ - packages
16
+ - adonis-intlayer
17
+ - intlayer
18
+ history:
19
+ - version: 8.0.0
20
+ date: 2026-01-30
21
+ changes: Initial documentation
22
+ ---
23
+
24
+ # intlayer AdonisJS Middleware Documentation
25
+
26
+ The `intlayer` middleware for AdonisJS detects the user's locale and provides translation functions through the request context. It also enables the use of global translation functions within the request flow.
27
+
28
+ ## Usage
29
+
30
+ ```ts fileName="start/kernel.ts"
31
+ router.use([() => import("adonis-intlayer/middleware")]);
32
+ ```
33
+
34
+ ```ts fileName="start/routes.ts"
35
+ import router from "@adonisjs/core/services/router";
36
+ import { t } from "adonis-intlayer";
37
+
38
+ router.get("/", async () => {
39
+ return t({
40
+ en: "Hello",
41
+ fr: "Bonjour",
42
+ });
43
+ });
44
+ ```
45
+
46
+ ## Description
47
+
48
+ The middleware performs the following tasks:
49
+
50
+ 1. **Locale Detection**: It analyzes the request (headers, cookies, etc.) to determine the user's preferred locale.
51
+ 2. **Context Setup**: It populates the request context with locale information.
52
+ 3. **Async Local Storage**: It uses `cls-hooked` to manage an asynchronous context, allowing global Intlayer functions like `t`, `getIntlayer`, and `getDictionary` to access the request-specific locale without passing it manually.
53
+
54
+ > Note: To use cookies for locale detection, ensure `@adonisjs/cookie` is configured and used in your application.
@@ -0,0 +1,149 @@
1
+ ---
2
+ createdAt: 2026-01-30
3
+ updatedAt: 2026-01-30
4
+ title: t Function Documentation | adonis-intlayer
5
+ description: See how to use the t function for adonis-intlayer package
6
+ keywords:
7
+ - t
8
+ - translation
9
+ - Intlayer
10
+ - Internationalization
11
+ - Documentation
12
+ - AdonisJS
13
+ - JavaScript
14
+ slugs:
15
+ - doc
16
+ - packages
17
+ - adonis-intlayer
18
+ - t
19
+ history:
20
+ - version: 8.0.0
21
+ date: 2026-01-30
22
+ changes: Initial documentation
23
+ ---
24
+
25
+ # Documentation: `t` Function in `adonis-intlayer`
26
+
27
+ The `t` function in the `adonis-intlayer` package is the core utility for providing localized responses in your AdonisJS application. It simplifies internationalization (i18n) by dynamically selecting content based on the user's preferred language.
28
+
29
+ ---
30
+
31
+ ## Overview
32
+
33
+ The `t` function is used to define and retrieve translations for a given set of languages. It automatically determines the appropriate language to return based on the client's request settings, such as the `Accept-Language` header. If the preferred language is unavailable, it gracefully falls back to the default locale specified in your configuration.
34
+
35
+ ---
36
+
37
+ ## Key Features
38
+
39
+ - **Dynamic Localization**: Automatically selects the most appropriate translation for the client.
40
+ - **Fallback to Default Locale**: Falls back to a default locale if the client's preferred language isn't available, ensuring continuity in user experience.
41
+ - **Asynchronous Context**: Works seamlessly within the AdonisJS request lifecycle using Async Local Storage.
42
+ - **TypeScript Support**: Enforce type safety for your translations.
43
+
44
+ ---
45
+
46
+ ## Function Signature
47
+
48
+ ```typescript
49
+ t(translations: Record<string, any>): any;
50
+ ```
51
+
52
+ ### Parameters
53
+
54
+ - `translations`: An object where the keys are locale codes (e.g., `en`, `fr`, `es`) and the values are the corresponding translated content.
55
+
56
+ ### Returns
57
+
58
+ - The content representing the client's preferred language.
59
+
60
+ ---
61
+
62
+ ## Loading the Middleware
63
+
64
+ To ensure that the `t` function works correctly, you **must** register the `intlayer` middleware in your AdonisJS application.
65
+
66
+ ```typescript fileName="start/kernel.ts"
67
+ router.use([() => import("adonis-intlayer/middleware")]);
68
+ ```
69
+
70
+ ---
71
+
72
+ ## Usage Examples
73
+
74
+ ### Basic Example
75
+
76
+ ```typescript fileName="start/routes.ts"
77
+ import router from "@adonisjs/core/services/router";
78
+ import { t } from "adonis-intlayer";
79
+
80
+ router.get("/", async () => {
81
+ return t({
82
+ en: "Welcome!",
83
+ fr: "Bienvenue!",
84
+ es: "¡Bienvenido!",
85
+ });
86
+ });
87
+ ```
88
+
89
+ ### Usage in Controllers
90
+
91
+ ```typescript fileName="app/controllers/example_controller.ts"
92
+ import type { HttpContext } from "@adonisjs/core/http";
93
+ import { t } from "adonis-intlayer";
94
+
95
+ export default class ExampleController {
96
+ async index({ response }: HttpContext) {
97
+ return response.send(
98
+ t({
99
+ en: "Hello from controller",
100
+ fr: "Bonjour depuis le contrôleur",
101
+ })
102
+ );
103
+ }
104
+ }
105
+ ```
106
+
107
+ ---
108
+
109
+ ## Advanced Topics
110
+
111
+ ### Fallback Mechanism
112
+
113
+ If a preferred locale is unavailable, the `t` function will fallback to the default locale defined in your `intlayer.config.ts`.
114
+
115
+ ```typescript
116
+ import { Locales, type IntlayerConfig } from "intlayer";
117
+
118
+ const config: IntlayerConfig = {
119
+ internationalization: {
120
+ locales: [
121
+ Locales.ENGLISH,
122
+ Locales.RUSSIAN,
123
+ Locales.JAPANESE,
124
+ Locales.FRENCH,
125
+ Locales.KOREAN,
126
+ Locales.CHINESE,
127
+ Locales.SPANISH,
128
+ Locales.GERMAN,
129
+ Locales.ARABIC,
130
+ Locales.ITALIAN,
131
+ Locales.ENGLISH_UNITED_KINGDOM,
132
+ Locales.PORTUGUESE,
133
+ Locales.HINDI,
134
+ Locales.TURKISH,
135
+ Locales.POLISH,
136
+ Locales.INDONESIAN,
137
+ Locales.VIETNAMESE,
138
+ Locales.UKRAINIAN,
139
+ ],
140
+ defaultLocale: Locales.ENGLISH,
141
+ },
142
+ };
143
+
144
+ export default config;
145
+ ```
146
+
147
+ ### TypeScript Integration
148
+
149
+ The `t` function is type-safe when used with defined dictionaries. For more details, refer to the [TypeScript documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/configuration.md).
@@ -0,0 +1,59 @@
1
+ ---
2
+ createdAt: 2026-01-29
3
+ updatedAt: 2026-01-29
4
+ title: hono-intlayer Package Documentation
5
+ description: Hono middleware for Intlayer, providing translation functions and locale detection.
6
+ keywords:
7
+ - hono-intlayer
8
+ - hono
9
+ - middleware
10
+ - internationalization
11
+ - i18n
12
+ slugs:
13
+ - doc
14
+ - packages
15
+ - hono-intlayer
16
+ - exports
17
+ history:
18
+ - version: 8.0.0
19
+ date: 2026-01-29
20
+ changes: Unified documentation for all exports
21
+ ---
22
+
23
+ # hono-intlayer Package
24
+
25
+ The `hono-intlayer` package provides a middleware for Hono applications to handle internationalization. It detects the user's locale and populates the context object.
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ npm install hono-intlayer
31
+ ```
32
+
33
+ ## Exports
34
+
35
+ ### Middleware
36
+
37
+ Import:
38
+
39
+ ```tsx
40
+ import { intlayer } from "hono-intlayer";
41
+ ```
42
+
43
+ | Function | Description | Related Doc |
44
+ | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
45
+ | `intlayer` | Hono middleware that integrates Intlayer into your Hono application. Handles locale detection from storage (cookies, headers), populates the context with `t`, `getIntlayer`, and `getDictionary`, and sets up CLS namespace for programmatic access during the request lifecycle. | [intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/packages/hono-intlayer/intlayer.md) |
46
+
47
+ ### Functions
48
+
49
+ Import:
50
+
51
+ ```tsx
52
+ import { t, getIntlayer, getDictionary } from "hono-intlayer";
53
+ ```
54
+
55
+ | Function | Description | Related Doc |
56
+ | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
57
+ | `t` | Global translation function that retrieves content for the current locale in Hono. Utilizes CLS (Async Local Storage) and must be used within a request context managed by the `intlayer` middleware. Can also be accessed via context. | [translation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/translation.md) |
58
+ | `getIntlayer` | Retrieves a dictionary by its key from the generated declaration and returns its content for the specified locale. Optimized version of `getDictionary`. Uses CLS to access request context. Can also be accessed via context. | - |
59
+ | `getDictionary` | Processes dictionary objects and returns content for the specified locale. Processes `t()` translations, enumerations, markdown, HTML, etc. Uses CLS to access request context. Can also be accessed via context. | - |
@@ -0,0 +1,59 @@
1
+ ---
2
+ createdAt: 2026-01-29
3
+ updatedAt: 2026-01-29
4
+ title: intlayer Hono Middleware Documentation | hono-intlayer
5
+ description: See how to use the intlayer middleware for hono-intlayer package
6
+ keywords:
7
+ - intlayer
8
+ - hono
9
+ - middleware
10
+ - Intlayer
11
+ - Internationalization
12
+ - Documentation
13
+ slugs:
14
+ - doc
15
+ - packages
16
+ - hono-intlayer
17
+ - intlayer
18
+ history:
19
+ - version: 8.0.0
20
+ date: 2026-01-29
21
+ changes: Init doc
22
+ ---
23
+
24
+ # intlayer Hono Middleware Documentation
25
+
26
+ The `intlayer` middleware for Hono detects the user's locale and populates the context object with Intlayer functions. It also enables the use of global translation functions within the request context.
27
+
28
+ ## Usage
29
+
30
+ ```ts
31
+ import { Hono } from "hono";
32
+ import { intlayer } from "hono-intlayer";
33
+
34
+ const app = new Hono();
35
+
36
+ app.use("*", intlayer());
37
+
38
+ app.get("/", async (c) => {
39
+ const t = c.get("t");
40
+ const content = t({
41
+ en: "Hello",
42
+ fr: "Bonjour",
43
+ });
44
+
45
+ return c.text(content);
46
+ });
47
+ ```
48
+
49
+ ## Description
50
+
51
+ The middleware performs the following tasks:
52
+
53
+ 1. **Locale Detection**: It analyzes the request (headers, cookies, etc.) to determine the user's preferred locale.
54
+ 2. **Context Population**: It adds Intlayer data to the Hono context, accessible via `c.get()`. This includes:
55
+ - `locale`: The detected locale.
56
+ - `t`: A translation function.
57
+ - `getIntlayer`: A function to retrieve dictionaries.
58
+ - `getDictionary`: A function to process dictionary objects.
59
+ 3. **Context Management**: It uses `cls-hooked` to manage an asynchronous context, allowing global Intlayer functions (`t`, `getIntlayer`, `getDictionary`) to access the request-specific locale without passing the context object.