Creation:2026-01-21Last update:2026-01-21
이 문서를 원하는 AI 어시스턴트에 참조하세요ChatGPTClaudeDeepSeekGoogle AI modeGeminiPerplexityMistralGrok
이 페이지와 원하는 AI 어시스턴트를 사용하여 문서를 요약합니다
버전 기록
- "문서 초기화"v8.0.02026. 1. 21.
이 페이지의 콘텐츠는 AI를 사용하여 번역되었습니다.
영어 원본 내용의 최신 버전을 보기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 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.
사용법
ts
코드 복사
코드를 클립보드에 복사
import Fastify from "fastify";import { intlayer } from "fastify-intlayer";const fastify = Fastify();fastify.register(intlayer);fastify.get("/", async (req, reply) => { const content = req.intlayer.t({ ko: "안녕하세요", en: "Hello", fr: "Bonjour", }); return content;});설명
이 플러그인은 다음 작업을 수행합니다:
- 로케일 감지: 요청(헤더, 쿠키 등)을 분석하여 사용자의 선호 로케일을 결정합니다.
- 요청 데코레이션:
FastifyRequest객체에intlayer속성을 추가하며, 해당 속성은 다음을 포함합니다:locale: 감지된 로케일.t: 번역 함수.getIntlayer: 사전을 가져오는 함수.
- 컨텍스트 관리: 비동기 컨텍스트를 관리하기 위해
cls-hooked를 사용하여, 전역 Intlayer 함수들이 요청별 로케일에 접근할 수 있도록 합니다.