Creation:2026-01-21Last update:2026-01-21
将此文档参考到您的 AI 助手ChatGPTClaudeDeepSeekGoogle AI modeGeminiPerplexityMistralGrok
使用您最喜欢的AI助手总结文档,并引用此页面和AI提供商
版本历史
- "初始化文档"v8.0.02026/1/21
此页面的内容已使用 AI 翻译。
查看英文原文的最新版本编辑此文档
如果您有改善此文档的想法,请随时通过在GitHub上提交拉取请求来贡献。
文档的 GitHub 链接Copy
复制文档 Markdown 到剪贴板
intlayer Fastify 插件文档
The intlayer plugin for Fastify detects the user's locale and decorates the request object with Intlayer functions. It also enables the use of global translation functions within the request context.
用法
描述
该插件执行以下任务:
- 区域设置检测:它分析请求(headers、cookies 等)以确定用户偏好的区域设置。
- 请求装饰:它向
FastifyRequest对象添加一个intlayer属性,包含:locale:检测到的区域设置。t:翻译函数。getIntlayer:用于检索字典的函数。
- 上下文管理:它使用
cls-hooked管理异步上下文,使全局 Intlayer 函数能够访问请求特定的区域设置。