Creation:2026-01-29Last update:2026-01-29
Reference this doc to your favorite AI assistantChatGPTClaudeDeepSeekGoogle AI modeGeminiPerplexityMistralGrok
Ask your question and get a summary of the document by referencing this page and the AI provider of your choice
Version History
- "Init doc"v8.0.01/29/2026
Edit this doc
If you have an idea for improving this documentation, please feel free to contribute by submitting a pull request on GitHub.
GitHub link to the documentationCopy
Copy doc Markdown to clipboard
intlayer Hono Middleware Documentation
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.
Usage
Description
The middleware performs the following tasks:
- Locale Detection: It analyzes the request (headers, cookies, etc.) to determine the user's preferred locale.
- Context Population: It adds Intlayer data to the Hono context, accessible via
c.get(). This includes:locale: The detected locale.t: A translation function.getIntlayer: A function to retrieve dictionaries.getDictionary: A function to process dictionary objects.
- Context Management: It uses
cls-hookedto manage an asynchronous context, allowing global Intlayer functions (t,getIntlayer,getDictionary) to access the request-specific locale without passing the context object.