i18n

Add react-i18next translations and generate language files with pnpm i18n.

Updated Dec 12, 2024
One-click install
npx skills add https://github.com/kingmacth/lobe-chat --skill i18n-kingmacth
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: i18n
Source: https://github.com/kingmacth/lobe-chat/tree/main/.agents/skills/i18n
Command: npx skills add https://github.com/kingmacth/lobe-chat --skill i18n-kingmacth

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Internationalization in React apps can be error-prone and inconsistent. This guide provides a structured workflow for adding translations and i18n keys using react-i18next, helping teams maintain uniform localization across components.

Core Features & Use Cases

  • Guidelines for naming keys with flat dot notation
  • Workflow to add keys and generate translations
  • Suitable for development and production locales, with a dev preview workflow

Quick Start

Initialize and manage translations in your project by following the defined conventions.

Frequently Asked Questions about i18n

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure translation keys for react-i18next to keep localization consistent?

Structure translation keys for react-i18next using flat dot notation to maintain consistent localization. This naming convention prevents errors and ensures translations remain synchronized across all React components in your project.

What is the standard workflow to add i18n keys and generate language files in a React app?

The standard i18n workflow requires restricting translation edits to the src/locales/default directory. After adding keys there, run pnpm i18n to automatically generate the synchronized language files required for your React components.

Can I use this react-i18next workflow for both development and production environments?

Yes, you can use this react-i18next workflow for both development and production environments. It includes a dev preview workflow and supports staging environments where multiple languages are required and translations must be synchronized.

Why should I restrict localization edits to a single default directory in React?

Restricting localization edits to the src/locales/default directory prevents error-prone manual updates across multiple files. It centralizes translation management so the pnpm i18n command can reliably generate and synchronize all language outputs.

What's the best way to prevent inconsistent translations across React components?

The best way to prevent inconsistent translations across React components is to adopt a structured i18n workflow. Using flat dot notation for keys and generating files via pnpm i18n from a default locale directory ensures uniform localization.