Communitygithub.com

BEKO2210/Firstbrain

国际化与本地化模式。检测硬编码字符串、管理翻译、语言环境文件、RTL 支持。

Firstbrain 是什么?

该技能(skill)专注于国际化(i18n)和本地化(L10n)的最佳实践。它提供了一整套指导方案,用于在软件开发中检测硬编码字符串、管理翻译文件、处理复数与日期格式,并支持从右到左(RTL)的语言布局。该技能涵盖了 React(react-i18next)、Next.js(next-intl)以及 Python(gettext)等主流技术栈的实现模式,并给出了清晰的文件结构建议。此外,它还提供了用于自动检测硬编码字符串和缺失翻译的检查脚本。无论你正在构建公共 Web 应用、SaaS 产品还是内部工具,本技能都能帮助你构建真正可全球化的应用程序。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/BEKO2210/Firstbrain/tree/HEAD/03%20-%20Resources/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(_("欢迎使用我们的应用"))

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>

使用时机

此技能适用于执行概述中描述的工作流或操作。

关联

  • 领域: [[Software Entwicklung]]
  • 类别: [[Software Architektur]]
  • 文件:
    • scripts/i18n_checker.py
  • 导航: [[Skills Uebersicht]], [[Home]]

Individual skills in this repo

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

BEKO2210/Firstbrain

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

BEKO2210/Firstbrain

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

BEKO2210/Firstbrain

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

BEKO2210/Firstbrain

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.

BEKO2210/Firstbrain

Expert in building portfolios that actually land jobs and clients -

BEKO2210/Firstbrain

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.

BEKO2210/Firstbrain

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

BEKO2210/Firstbrain

Best practices for Remotion - Video creation in React

BEKO2210/Firstbrain

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

BEKO2210/Firstbrain

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

BEKO2210/Firstbrain

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.

BEKO2210/Firstbrain

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

BEKO2210/Firstbrain

Automate TikTok tasks via Rube MCP (Composio): upload/publish videos, post photos, manage content, and view user profiles/stats. Always search tools first for current schemas.

BEKO2210/Firstbrain

Video and audio perception, indexing, and editing. Ingest files/URLs/live streams, build visual/spoken indexes, search with timestamps, edit timelines, add overlays/subtitles, generate media, and create real-time alerts.

BEKO2210/Firstbrain

Upload, stream, search, edit, transcribe, and generate AI video and audio using the VideoDB SDK.

BEKO2210/Firstbrain

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

BEKO2210/Firstbrain

Automate YouTube tasks via Rube MCP (Composio): upload videos, manage playlists, search content, get analytics, and handle comments. Always search tools first for current schemas.

BEKO2210/Firstbrain

Extract transcripts from YouTube videos and generate comprehensive, detailed summaries using intelligent analysis frameworks

相关技能