# i18n-translation > Complete internationalization implementation for web applications. Provides systematic AI-driven workflow to achieve 100% i18n coverage with zero hardcoded strings in SOURCE CODE. Use for adding i18n to new projects, migrating hardcoded strings to i18n, adding new language support, or auditing i18n coverage. CRITICAL: This skill focuses ONLY on source code internationalization (components, views, UI), NOT documentation files (README.md, docs/). When checking for existing i18n, prioritize src/ directory detection and ignore docs/, README*, and markdown files. Includes extraction patterns, component migration strategies, namespace organization, and validation checklists. Works with React, Vue, Angular, and similar frameworks. - Author: HybridTalentComputing - Repository: HybridTalentComputing/agent-skills-coding - Version: 20260121155028 - Stars: 0 - Forks: 0 - Last Updated: 2026-02-07 - Source: https://github.com/HybridTalentComputing/agent-skills-coding - Web: https://mule.run/skillshub/@@HybridTalentComputing/agent-skills-coding~i18n-translation:20260121155028 --- --- name: i18n-translation description: > Complete internationalization implementation for web applications. Provides systematic AI-driven workflow to achieve 100% i18n coverage with zero hardcoded strings in SOURCE CODE. Use for adding i18n to new projects, migrating hardcoded strings to i18n, adding new language support, or auditing i18n coverage. CRITICAL: This skill focuses ONLY on source code internationalization (components, views, UI), NOT documentation files (README.md, docs/). When checking for existing i18n, prioritize src/ directory detection and ignore docs/, README*, and markdown files. Includes extraction patterns, component migration strategies, namespace organization, and validation checklists. Works with React, Vue, Angular, and similar frameworks. --- # i18n-translation: Full Internationalization Implementation Implement complete internationalization (i18n) for web applications with 100% coverage. This skill provides a systematic, AI-driven workflow to eliminate all hardcoded strings and establish a scalable translation system. ## Quick Start For immediate i18n implementation: 1. **Read the complete workflow:** See [workflow.md](references/workflow.md) for the 5-phase process 2. **Plan file structure:** See [modular-files.md](references/modular-files.md) for splitting strategy 3. **Extract strings systematically:** Process every component, extract ALL user-facing text 4. **Set up infrastructure:** Install i18next, create modular translation files 5. **Migrate components:** Replace hardcoded strings with `t()` calls 6. **Validate thoroughly:** Ensure zero hardcoded strings remain **⚠️ Important:** For projects with > 1000 strings, you MUST split translation files by namespace. See [modular-files.md](references/modular-files.md) for complete guidance. **Expected outcome:** 100% of UI text uses i18n system, application works flawlessly in all supported languages. --- ## ⚠️ Critical: Code vs Documentation Internationalization **This skill ONLY handles source code internationalization.** ### What This Skill Does (Source Code i18n) ✅ **IN SCOPE - Components and Source Code:** - UI components in `src/`, `app/`, `components/`, `views/`, `pages/` - React/Vue/Angular/Svelte components (.tsx, .jsx, .vue, .ts, .js) - User-facing text in application code - Translation files for the application (en.json, zh.json, etc.) - i18n library setup (i18next, vue-i18n, etc.) ### What This Skill Does NOT Handle (Documentation i18n) ❌ **OUT OF SCOPE - Documentation Files:** - README.md, README.zh-CN.md, README.en.md - Documentation in `docs/` folder - Markdown files (.md) - Documentation-specific translation systems - Multi-language documentation sites ### Priority Rule **When detecting existing i18n implementation:** 1. **FIRST PRIORITY:** Check source code directories (`src/`, `app/`, `components/`, `views/`) - Look for i18n library imports in component files - Check for `useTranslation()`, `t()` function calls - Look for translation files in source directories 2. **SECOND PRIORITY:** Ignore documentation files - `README*.md` files do NOT count as i18n implementation - `docs/` folder should be completely ignored - Multi-language documentation ≠ application i18n ### Detection Commands **✅ CORRECT - Check source code only:** ```bash # Check for i18n in source code Grep: "i18n|useTranslation|i18next" in src/ directory Glob: "src/**/locales/**/*.json" Glob: "src/**/i18n/**" # Check component files Grep: "from [\"']react-i18next[\"']|from [\"']vue-i18n[\"']" in src/ ``` **❌ WRONG - Don't check documentation:** ```bash # These will detect documentation i18n, which is wrong Glob: "**/README*.md" Glob: "docs/**" Grep: "i18n" in all files (includes docs) ``` ### Common Misconceptions **Myth:** "My project has README.md and README.zh-CN.md, so it has i18n." **Fact:** No, documentation internationalization is separate from code i18n. **Myth:** "I have i18n in my docs/ folder, so I can skip i18n setup." **Fact:** Documentation i18n doesn't help your UI components translate. **Myth:** "Finding i18n references anywhere means the project is internationalized." **Fact:** Only source code i18n counts. Documentation must be ignored. --- ## When to Use This Skill Use this skill when: - Adding i18n to a new project - Migrating existing hardcoded strings to i18n - Adding support for additional languages - Auditing or improving existing i18n implementation - Ensuring complete i18n coverage **Key principle:** 100% coverage is the only acceptable standard. Zero hardcoded strings in UI. --- ## Core Methodology ### The 5-Phase Workflow **Phase 1: Project Analysis** (5-10 min) - Identify framework, build tool, and component structure - Check for existing i18n setup - Create component inventory - Design namespace structure **Phase 2: String Extraction** (30-60 min) - Systematically read each component - Extract ALL user-facing strings (text, placeholders, labels, messages, etc.) - Organize by namespace and component - Create master translation list **Phase 3: Translation Infrastructure** (15-20 min) - Install i18next (or framework-appropriate library) - Create i18n configuration - Create complete translation files for all languages - Add type definitions (if TypeScript) **Phase 4: Component Migration** (40-80 min) - Update each component to use `useTranslation` hook - Replace ALL hardcoded strings with `t()` calls - Handle interpolation, plurals, and complex patterns - Ensure zero hardcoded strings remain **Phase 5: Validation** (10-15 min) - Verify no hardcoded strings remain (search patterns) - Validate translation file syntax and consistency - Test language switching - Verify translation quality - Complete all checklist items **Total time:** 1.5-3 hours for typical app (50-100 components) ### Success Criteria ✅ 100% of user-facing text uses i18n ✅ Zero hardcoded strings in UI components ✅ Translation files complete for all languages ✅ Application works perfectly in all supported languages ✅ No console errors or warnings --- ## Implementation Guide ### Step 1: Understand the Project Before touching any code: 1. **Identify the framework:** - React → use `i18next` + `react-i18next` - Vue → use `vue-i18n` - Angular → use `@ngx-translate/core` - Other → check framework documentation 2. **Analyze component structure:** ```bash Glob: "src/components/**/*.{tsx,jsx,vue}" Glob: "src/views/**/*.{tsx,jsx,vue}" ``` 3. **Check existing i18n in SOURCE CODE only:** ```bash # ✅ CORRECT - Check source code directories only Grep: "i18n|i18next|vue-i18n|useTranslation" in src/ Glob: "src/**/locales/**" Glob: "src/**/i18n/**" # ❌ WRONG - Don't check documentation # Do NOT search in: docs/, README*.md, .md files ``` **CRITICAL:** Only check source code directories. Ignore documentation files completely. 4. **Create component inventory:** - List all components by category (layout, features, common, utility) - Note components with heavy UI text - Identify migration priority ### Step 2: Extract All Strings For **each component**, without exception: 1. Read the component file 2. Extract **every** user-facing string: - Text content: `
Error occurred
` - Attributes: `title`, `aria-label`, `alt` - Options: `` 3. Determine appropriate namespace 4. Create translation key using naming conventions 5. Add to master translation list **Pattern to follow:** ``` For component: src/components/chat/ChatView.tsx Extracted strings: - "Chat" → chat.chatView.title - "New Conversation" → chat.chatView.newConversation - "Type a message..." → chat.chatView.inputPlaceholder - "Send" → chat.chatView.sendButton ``` ### Step 3: Set Up i18n Infrastructure **For React projects:** 1. Install dependencies: ```bash npm install i18next react-i18next i18next-browser-languagedetector ``` 2. Create configuration (`src/i18n/config.ts`): ```typescript import i18n from "i18next" import { initReactI18next } from "react-i18next" import LanguageDetector from "i18next-browser-languagedetector" import enTranslations from "./locales/en.json" import zhTranslations from "./locales/zh.json" i18n .use(LanguageDetector) .use(initReactI18next) .init({ resources: { en: { translation: enTranslations }, zh: { translation: zhTranslations }, }, fallbackLng: "en", lng: "en", interpolation: { escapeValue: false }, }) export default i18n ``` 3. Create translation files: - `src/i18n/locales/en.json` - Copy all extracted strings here - `src/i18n/locales/zh.json` - Translate all values to Chinese 4. Initialize in main entry point: ```typescript import "./i18n/config" // Must be first import ``` ### Step 4: Migrate All Components For **each component**: 1. Add `useTranslation` hook: ```typescript import { useTranslation } from "react-i18next" export const MyComponent: React.FC = () => { const { t } = useTranslation("namespace") ``` 2. Replace **every** hardcoded string: ```tsx // BeforeHello, {userName}!
// After{t("greeting", { userName })}
// Translation file "greeting": "Hello, {{userName}}!" ``` ### Attributes ```tsx // Before // After ``` ### Multiple Namespaces ```tsx const { t: tCommon } = useTranslation("common") const { t: tSettings } = useTranslation("settings")