Communitygithub.com

BEKO2210/Firstbrain

國際化與本地化模式:偵測硬編碼字串、管理翻譯、語言環境檔案與 RTL 支援

Firstbrain 是什麼?

此技能提供一套完整的國際化(i18n)與本地化(L10n)最佳實踐指南。它幫助開發者與 AI 代理(如 Claude Code、Cursor)在專案中導入標準的 i18n 模式,包括檢測硬編碼字串、管理多語言翻譯檔案(如 en/、tr/、ar/)以及支援從右到左(RTL)的語言。技能涵蓋了 React(react-i18next)、Next.js(next-intl)與 Python(gettext)等多種開發平台的實作範例,並說明如何使用 ICU 訊息格式處理複數與日期/數字格式化。此外,技能提供了一個 `scripts/i18n_checker.py` 指令碼來自動掃描硬編碼字串與遺漏的翻譯,並附上實務檢查清單,協助團隊在出貨前確保所有使用者面向的文字都已國際化。支援的平台包括網頁應用程式、SaaS 產品以及內部工具,並具備從專案初期就規劃 RTL 佈局的建議。

相容平台~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?
公開網站✅ 是
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. 最佳實務

應該 ✅

  • 使用翻譯鍵(translation keys),而非原始文字
  • 按功能模組劃分翻譯命名空間
  • 支援複數形式
  • 針對每個語言環境處理日期/數字格式
  • 從一開始就規劃 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 <專案路徑>

使用時機

此技能適用於執行概述中所描述的工作流程或動作。

連結

  • 領域: [[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

相關技能