원클릭으로
i18n-handler
Guidelines for managing internationalization (i18n) in the project using next-intl and unified translation patterns.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Guidelines for managing internationalization (i18n) in the project using next-intl and unified translation patterns.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
ZGO API development standards including pagination, error handling, and RESTful design
Test patterns, mocking strategies, and organization best practices
Standardized error format, error code clusters, and API client usage for consistent error handling.
Specifications for Zustand stores, React Query hooks, and the Service-Hook-Type pattern with optimistic updates.
Strict rules for environment variable management using Zod validation and src/config/env.ts.
High-level overview of project structure, mock API architecture, and authentication flow.
SOC 직업 분류 기준
| name | i18n-handler |
| description | Guidelines for managing internationalization (i18n) in the project using next-intl and unified translation patterns. |
This skill provides comprehensive instructions for implementing and maintaining internationalization (i18n) within the LlamaFront AI Scaffold. It covers client and server component usage, type-safe translation keys, module organization, and scoped translations.
The i18n system provides full TypeScript type safety through:
AllTranslationKeys: Union type of all valid dot-notation keys (e.g., 'common.save' | 'auth.login' | ...)Messages: Root type containing all module namespaces and their translationsScopedTranslations<P>: Type-safe scoped translator for a specific prefix pathThe project uses next-intl with a unified pattern that supports both dot notation (recommended) and namespace-based access.
Use the useT hook for translations in client-side components.
'use client';
import { useT } from '@/i18n';
function MyComponent() {
const t = useT();
return (
<div>
{/* Dot notation (recommended) */}
<button>{t('common.save')}</button>
{/* Namespace-based (backward compatible) */}
<button>{t.common('save')}</button>
</div>
);
}
Use the asynchronous getT function for translations in server-side components.
// app/page.tsx (Server Component)
import { getT } from '@/i18n';
export default async function Page() {
const t = await getT();
return <h1>{t('common.loading')}</h1>;
}
For components with many translations from a single namespace, use the scoped pattern:
import { useT } from '@/i18n';
function SettingsPage() {
// Scoped to 'settings' namespace - only settings keys are valid
const t = useT('settings');
return (
<div>
<h1>{t('title')}</h1> {/* settings.title */}
<p>{t('description')}</p> {/* settings.description */}
</div>
);
}
Translations are organized into functional modules located in src/i18n/modules/[module]/.
| Module | Description |
|---|---|
common | Common UI text (buttons, labels, messages) |
auth | Authentication-related text |
nav | Navigation labels |
settings | Settings page translations |
errors | Error messages |
metadata | Page titles and SEO metadata |
dashboard | Dashboard-specific translations |
test | Testing translations |
zh-Hans (Simplified Chinese) - Base locale, defines typesen-US (English US) - Implements base typeConfiguration in src/i18n/config.ts.
Each module contains three files:
src/i18n/modules/[module]/
├── zh-Hans.ts # Base file (defines types)
├── en-US.ts # English translations (implements type)
└── index.ts # Barrel export
zh-Hans.ts)const messages = {
title: '标题',
description: '描述',
nested: {
item: '嵌套项目',
},
};
export default messages;
export type ModuleNameMessages = typeof messages;
en-US.ts)import type { ModuleNameMessages } from './zh-Hans';
const messages: ModuleNameMessages = {
title: 'Title',
description: 'Description',
nested: {
item: 'Nested Item',
},
};
export default messages;
When adding a new page or feature:
src/i18n/modules/.zh-Hans.ts first (this defines the type).en-US.ts (TypeScript will enforce this).modules/[module-name]/zh-Hans.ts with type exporten-US.ts implementing the typeindex.ts barrel exportmodules/index.tsAVAILABLE_MODULES in src/i18n/loader.tsmoduleRegistry in loader.ts// In zh-Hans.ts:
// greeting: '你好,{name}!欢迎回来。'
const t = useT();
t('common.greeting', { name: '张三' }); // -> "你好,张三!欢迎回来。"
// or
t.common('greeting', { name: '张三' }); // -> "你好,张三!欢迎回来。"
| Task | Action |
|---|---|
| New Page | Add translations to src/i18n/modules/[module]/[locale].ts and update src/constants/routes.ts. |
| New Component | Use useT (Client) or getT (Server) for all user-facing text. |
| Error Messages | Use the errors namespace and follow the standardized error handling patterns. |
| Scoped Component | Use useT('namespace') to get type-safe scoped translations. |
| File | Purpose |
|---|---|
src/i18n/config.ts | Locale configuration and settings |
src/i18n/index.ts | Barrel exports for all i18n utilities |
src/i18n/translations.ts | useT and getT implementation with types |
src/i18n/loader.ts | Dynamic module loading and AVAILABLE_MODULES |
src/i18n/modules/index.ts | Static type generation from modules |
src/i18n/README.md | Detailed documentation with examples |
| Variable | Description | Default |
|---|---|---|
NEXT_PUBLIC_DEFAULT_LOCALE | Default locale | zh-Hans |
NEXT_PUBLIC_LOCALE_SWITCHER_ENABLED | Show language switcher | true |
[!IMPORTANT] Zero Hardcoded Strings: All user-facing text MUST use i18n hooks. Never hardcode text directly in JSX.
[!TIP] For comprehensive examples and detailed API documentation, refer to
src/i18n/README.md.