Communitygithub.com

ASoudy/AGS

国际化和本地化模式:检测硬编码字符串、管理翻译、区域设置文件以及从右到左(RTL)语言支持。

AGS 是什么?

这个技能提供了一套全面的国际化和本地化最佳实践,覆盖了从核心概念到具体实现的完整工作流程。它教导开发者如何将应用程序设计为可翻译(i18n),并实际执行翻译(L10n),同时处理区域设置(Locale,如 en-US、tr-TR)和从右到左(RTL,如阿拉伯语、希伯来语)布局。 该技能针对不同技术栈提供了具体实现模式,包括 React 环境下的 react-i18next、Next.js 中的 next-intl 以及 Python 中的 gettext。它还详细描述了推荐的文件结构(按语言和功能模块组织 JSON 文件)、必须遵守的最佳实践(如使用翻译键而非原始文本、按功能命名空间划分翻译、支持复数形式)、常见问题的解决方案(如缺失翻译时回退到默认语言、使用 Intl.DateTimeFormat 处理日期格式),以及 RTL 支持的 CSS 逻辑属性技术。 此外,技能附带一个实用脚本(`scripts/i18n_checker.py`),用于自动检测项目中的硬编码字符串和缺失翻译。该脚本通过命令行执行,帮助团队在发布前确保所有用户面向的文本都已正确国际化。此技能适用于 Claude Code、Coder 或任何支持 AI 辅助开发的平台,旨在为开发者提供标准化、可复用的 i18n 实施指导。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ASoudy/AGS/tree/HEAD/AGAS/plugins/antigravity-awesome-skills-claude/skills/i18n-localization

在你喜欢的 AI 中提问

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

文档

i18n 和本地化

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


1. 核心概念

术语含义
i18n国际化 - 使应用可翻译
L10n本地化 - 实际翻译
区域设置 (Locale)语言 + 区域 (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.

ASoudy/AGS

Advanced JavaScript animation library skill for creating complex, high-performance web animations.

ASoudy/AGS

Astropy is the core Python package for astronomy, providing essential functionality for astronomical research and data analysis.

ASoudy/AGS

Build content-focused websites with Astro — zero JS by default, islands architecture, multi-framework components, and Markdown/MDX support.

ASoudy/AGS

One sentence - what this skill does and when to invoke it

ASoudy/AGS

Audit and fix animation performance issues including layout thrashing, compositor properties, scroll-linked motion, and blur effects. Use when animations stutter, transitions jank, or reviewing CSS/JS animation performance.

ASoudy/AGS

Pull a YouTube video transcript into a queryable markdown vault with yt-dlp subtitle discovery, VTT cleanup, metadata frontmatter, and capture-seed stubs.

ASoudy/AGS

Expert in building portfolios that actually land jobs and clients - not just showing work, but creating memorable experiences. Covers developer portfolios, designer portfolios, creative portfolios, and portfolios that convert visitors into opportunities.

ASoudy/AGS

Generates high-converting Next.js/React landing pages with Tailwind CSS. Uses PAS, AIDA, and BAB frameworks for optimized copy/components (Heroes, Features, Pricing). Focuses on Core Web Vitals/SEO.

ASoudy/AGS

AI-powered animation tool for creating motion in logos, UI, icons, and social media assets.

ASoudy/AGS

CRITICAL: Use for Makepad animation system. Triggers on: makepad animation, makepad animator, makepad hover, makepad state, makepad transition, "from: { all: Forward", makepad pressed, makepad 动画, makepad 状态, makepad 过渡, makepad 悬停效果

ASoudy/AGS

Comprehensive patterns for Next.js 14+ App Router architecture, Server Components, and modern full-stack React development.

ASoudy/AGS

Next.js App Router principles. Server Components, data fetching, routing patterns.

ASoudy/AGS

Expert integration of Supabase Auth with Next.js App Router

ASoudy/AGS

React and Next.js 14+ application development with App Router, Server Components, TypeScript, Tailwind CSS, and modern frontend patterns.

ASoudy/AGS

Best practices for Remotion - Video creation in React

ASoudy/AGS

Generate walkthrough videos from Stitch projects using Remotion with smooth transitions, zooming, and text overlays

ASoudy/AGS

Seek and analyze video content using Memories.ai Large Visual Memory Model for persistent video intelligence

ASoudy/AGS

Writes complete, structured landing pages optimized for SEO ranking, AEO citation, and visitor conversion. Activate when the user wants to write or generate a landing page for a product, service, or offer.

ASoudy/AGS

Three.js animation - keyframe animation, skeletal animation, morph targets, animation mixing. Use when animating objects, playing GLTF animations, creating procedural motion, or blending animations.

ASoudy/AGS

Skill for discovering and researching autonomous AI agents, tools, and ecosystems using the AgentFolio directory.

相关技能