--- createdAt: 2026-01-29 updatedAt: 2026-09-29 priority: 5 title: intlayer Hono Middleware Documentation | hono-intlayer description: "The intlayer middleware for Hono detects the user's locale and adds Intlayer translation functions to the request context." keywords: - intlayer - hono - middleware - Intlayer - Internationalization - Documentation slugs: - doc - packages - hono-intlayer - intlayer history: - version: 8.0.0 date: 2026-01-29 changes: "Init doc" author: aymericzip --- # 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 ```ts import { Hono } from "hono"; import { intlayer } from "hono-intlayer"; const app = new Hono(); app.use("*", intlayer()); app.get("/", async (c) => { const t = c.get("t"); const content = t({ en: "Hello", fr: "Bonjour", }); return c.text(content); }); ``` ## Description The middleware performs the following tasks: 1. **Locale Detection**: It analyzes the request (headers, cookies, etc.) to determine the user's preferred locale. 2. **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.