Communitygithub.com

ASoudy/AGS

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

AGS 是什麼?

此技能專注於軟體開發中的國際化(i18n)與本地化(L10n)最佳實務,協助開發者將應用程式設計為可翻譯的架構。它涵蓋了從核心概念(如語言環境與 RTL 支援)到實際實作模式的所有環節,包括 React 的 react-i18next、Next.js 的 next-intl 以及 Python 的 gettext 等主流框架的整合方式。技能中明確指導如何建立標準的語言檔案結構(例如 locales/en/、locales/tr/),並強調整組件中避免使用硬編碼字串、支援複數規則、處理日期/數字格式以及預先規劃 RTL 版面配置等關鍵最佳實務。此外,技能還提供了一個 `scripts/i18n_checker.py` 腳本,可自動偵測專案中的硬編碼字串與遺漏的翻譯,並透過完整的核對清單幫助開發者在發佈前確認所有使用者面向的文字均已正確國際化。此技能適用於任何需要支援多語言的公共網站、SaaS 產品或內部工具,並建議在單一地區應用程式中也考慮未來擴充需求。

相容平台~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本地化 - 實際的翻譯
語言環境語言 + 地區(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. 最佳實務

應該 ✅

  • 使用翻譯鍵,而非原始文字
  • 按功能劃分翻譯命名空間
  • 支援複數規則
  • 根據語言環境處理日期/數字格式
  • 從一開始就規劃 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.

相關技能