Communitygithub.com

Anhvu1107/all-agent-skill

始终在请求涉及国际化与本地化模式时使用此技能。

all-agent-skill 是什么?

该技能为开发者和AI代理提供了一套完整的国际化(i18n)与本地化(L10n)最佳实践指南。它支持多种平台,包括React(react-i18next)、Next.js(next-intl)和Python(gettext),并涵盖了从核心概念、文件结构到RTL(从右至左)语言支持的全面内容。技能文档包含清晰的“该做与不该做”列表、常见问题解决方案以及一个用于检测硬编码字符串和缺失翻译的Python脚本。通过推荐从参考文档开始选择性阅读,该技能确保仅加载与当前任务相关的资源,从而高效指导用户在不同项目类型中正确实施本地化。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Anhvu1107/all-agent-skill/tree/HEAD/.agent/skills/i18n-localization

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

i18n 与本地化

选择性阅读规则

从以下内容开始:

  • references/senior-master-standard.md
  • references/usage-routing.md
  • references/quality-checklist.md

然后仅加载与用户实际任务匹配的继承文档、脚本、资产或示例。

国际化(i18n)与本地化(L10n)最佳实践。


1. 核心概念

术语含义
i18n国际化——使应用可翻译
L10n本地化——实际翻译
区域设置语言+地区(en-US, tr-TR)
RTL从右至左语言(阿拉伯语、希伯来语)

2. 何时使用 i18n

项目类型需要 i18n?
公共 Web 应用✅ 是
SaaS 产品✅ 是
内部工具⚠️ 可能需要
单区域应用⚠️ 考虑未来
个人项目❌ 可选

3. 实现模式

React (react-i18next)

import { useTranslation } from 'react-i18next';

function Welcome() {
  const { t } = useTranslation();
  return <h1>{t('welcome.title')}</h1>;
}

Next.js (next-intl)

import { useTranslations } from 'next-intl';

export default function Page() {
  const t = useTranslations('Home');
  return <h1>{t('title')}</h1>;
}

Python (gettext)

from gettext import gettext as _

print(_("Welcome to our app"))

4. 文件结构

locales/
├── en/
│   ├── common.json
│   ├── auth.json
│   └── errors.json
├── tr/
│   ├── common.json
│   ├── auth.json
│   └── errors.json
└── ar/          # RTL
    └── ...

5. 最佳实践

应该做 ✅

  • 使用翻译键,而非原始文本
  • 按功能对翻译进行命名空间划分
  • 支持复数形式
  • 按区域设置处理日期/数字格式
  • 从一开始就规划 RTL 支持
  • 对复杂字符串使用 ICU 消息格式

不应该做 ❌

  • 在组件中硬编码字符串
  • 拼接翻译后的字符串
  • 假设文本长度(德语长约 30%)
  • 忘记 RTL 布局
  • 在同一文件中混合多种语言

6. 常见问题

问题解决方案
翻译缺失回退到默认语言
硬编码字符串使用 linter/检查脚本
日期格式使用 Intl.DateTimeFormat
数字格式使用 Intl.NumberFormat
复数形式使用 ICU 消息格式

7. RTL 支持

/* CSS 逻辑属性 */
.container {
  margin-inline-start: 1rem;  /* 不是 margin-left */
  padding-inline-end: 1rem;   /* 不是 padding-right */
}

[dir="rtl"] .icon {
  transform: scaleX(-1);
}

8. 检查清单

发布前检查项:

  • 所有面向用户的字符串均使用翻译键
  • 存在所有支持语言的区域设置文件
  • 日期/数字格式使用 Intl API
  • 已测试 RTL 布局(如果适用)
  • 已配置回退语言
  • 组件中无硬编码字符串

脚本

脚本用途命令
scripts/i18n_checker.py检测硬编码字符串和缺失翻译python scripts/i18n_checker.py <project_path>

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches 007: Security audit, hardening, threat modeling (STRIDE/PASTA), Red/Blue Team, OWASP checks, code review, incident response, and infrastructure security for any project.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Agentfolio: Skill for discovering and researching autonomous AI agents, tools, and ecosystems using the AgentFolio directory.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Animejs Animation: Advanced JavaScript animation library skill for creating complex, high-performance web animations.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Astropy: Astropy is the core Python package for astronomy, providing essential functionality for astronomical research and data analysis.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Astro: Build content-focused websites with Astro — zero JS by default, islands architecture, multi-framework components, and Markdown/MDX support.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Emotional ARC Designer: One sentence - what this skill does and when to invoke it

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Fixing Motion Performance: Audit and fix animation performance issues including layout thrashing, compositor properties, scroll-linked motion, and blur effects.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Interactive Portfolio: Expert in building portfolios that actually land jobs and clients - not just showing work, but creating memorable experiences.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches JQ: Expert jq usage for JSON querying, filtering, transformation, and pipeline integration.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Landing Page Generator: Generates high-converting Next.js/React landing pages with Tailwind CSS.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches LEX: Centralized ''Truth Engine'' for cross-jurisdictional legal context (US, EU, CA) and contract scaffolding.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Magic Animator: AI-powered animation tool for creating motion in logos, UI, icons, and social media assets.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Makepad Animation: CRITICAL: Use for Makepad animation system.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Nextjs APP Router Patterns: Comprehensive patterns for Next.js 14+ App Router architecture, Server Components, and modern full-stack React development.

Anhvu1107/all-agent-skill

ALWAYS use this when the user mentions Nextjs Best Practices, asks to build, debug, review, document, automate, test, configure, migrate, or make decisions in this domain, or the task clearly depends on Nextjs Best Practices; scope: Next.js App Router principles. Apply the bundled workflow, references, scripts, Senior Master standard, and Codex strict review gate before final output.

Anhvu1107/all-agent-skill

description: ALWAYS use this when the work is specifically about modern Next.js or React architecture, data flow, rendering strategy, routing, or performance-sensitive frontend behavior.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches Nextjs Supabase Auth: Expert integration of Supabase Auth with Next.js App Router

Anhvu1107/all-agent-skill

ALWAYS use this when the task involves reading, extracting, splitting, merging, rotating, creating, validating, OCR-ing, form-filling, or otherwise producing or modifying PDF files.

Anhvu1107/all-agent-skill

ALWAYS use this when the request matches React Nextjs Development: React and Next.js 14+ application development with App Router, Server Components, TypeScript, Tailwind CSS, and modern frontend patterns.

Anhvu1107/all-agent-skill

ALWAYS use this when working with Remotion code, video compositions, rendering logic, timing, media assets, or React-based motion workflows.

相关技能