Localization L10n

作者 mindrally97184105b5da無授權條款269 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫5 週前更新

Implement localization (l10n) best practices to adapt applications for specific regions, languages, and cultural preferences.

AI 產生的概覽

為網頁與行動應用提供在地化指南,涵蓋區域語言、格式與文化調適。

功能
此技能提供參考指引,用來把已完成國際化的網頁與行動應用調適到特定地區。內容涵蓋在地化函式庫、翻譯檔案組織與回退鏈、依地區設定的日期、數字與貨幣格式、文化與法律調適、RTL 與排版考量、地區地址與單位處理,以及在地化測試。它產出的是建議性說明,而非程式碼或檔案。
適用情境
適合已支援國際化的應用在規劃或檢視在地化工作時使用。適用於翻譯檔案結構設計、i18n 函式庫選擇、地區變體處理,以及在地化測試與偽在地化設定等任務。
執行需求
此技能未附任何指令碼或資源,僅有說明內容。套用這些指引需要具備國際化支援的應用程式碼庫;範例另涉及 JavaScript/TypeScript 以及 i18next、react-intl、formatjs、expo-localization 等函式庫。

Localization (l10n)

You are an expert in localization for web and mobile applications. Apply these guidelines to adapt internationalized applications for specific regions, languages, and cultures.

Core Principles

  • Localization (l10n) builds on internationalization (i18n)
  • Ensure all user-facing text supports localization
  • Adapt content for cultural appropriateness
  • Respect regional conventions for dates, numbers, and currency
  • Design for content that varies significantly between locales

Localization Libraries

Web Applications

  • Use i18next and react-i18next for web applications
  • Implement namespace-based translation organization
  • Use libraries like react-intl or next-i18next for Next.js applications
  • Leverage formatjs for ICU message format support

Mobile Applications

  • Use expo-localization for React Native apps
  • Use react-native-i18n or expo-localization for internationalization and localization
  • Support multiple languages with fallback mechanisms
  • Handle device locale detection automatically

Translation Management

File Organization

locales/  en-US/    common.json    legal.json    marketing.json  en-GB/    common.json    legal.json    marketing.json  es-ES/    common.json    legal.json    marketing.json  es-MX/    common.json    legal.json    marketing.json

Regional Variants

  • Support regional language variants (en-US vs en-GB, es-ES vs es-MX)
  • Implement fallback chains (es-MX -> es -> en)
  • Handle spelling differences (color vs colour)
  • Adapt terminology for regional preferences

Locale-Specific Formatting

Date and Time Formatting

typescript
// Format dates according to localeconst formatDate = (date: Date, locale: string) => {  return new Intl.DateTimeFormat(locale, {    year: 'numeric',    month: 'long',    day: 'numeric'  }).format(date);};
// US: January 23, 2026// UK: 23 January 2026// Germany: 23. Januar 2026

Number Formatting

typescript
// Format numbers according to localeconst formatNumber = (num: number, locale: string) => {  return new Intl.NumberFormat(locale).format(num);};
// US: 1,234,567.89// Germany: 1.234.567,89// France: 1 234 567,89

Currency Formatting

typescript
// Format currency according to localeconst formatCurrency = (amount: number, locale: string, currency: string) => {  return new Intl.NumberFormat(locale, {    style: 'currency',    currency: currency  }).format(amount);};
// US/USD: $1,234.56// Germany/EUR: 1.234,56 EUR// Japan/JPY: JPY 1,235

Cultural Adaptation

Content Localization

  • Adapt imagery for cultural appropriateness
  • Localize marketing content, not just translate
  • Consider cultural sensitivities in color choices
  • Adapt examples and references for local relevance

Legal and Compliance

  • Localize privacy policies and terms of service
  • Adapt for regional legal requirements (GDPR, CCPA)
  • Display appropriate regulatory information
  • Handle region-specific disclaimers

Layout and Typography

Text Expansion

  • Design for 30-50% text expansion from English
  • Use flexible layouts that accommodate longer text
  • Test with German (often longest) and Chinese (often shortest)
  • Avoid fixed-width containers for text

RTL Support

  • Implement full RTL (right-to-left) support for Arabic, Hebrew, etc.
  • Use CSS logical properties for directional layouts
  • Mirror UI elements appropriately
  • Handle bidirectional text (mixed LTR/RTL)
css
/* Use logical properties for RTL support */.card {  margin-inline-start: 1rem;  padding-inline-end: 0.5rem;  text-align: start;}

Typography Considerations

  • Use fonts that support required character sets
  • Consider CJK (Chinese, Japanese, Korean) typography needs
  • Support Arabic and other script-specific requirements
  • Implement proper line breaking for different languages

Regional Features

Address Formats

  • Adapt address forms for regional formats
  • Support international phone number formats
  • Handle postal/ZIP code validation by country
  • Implement country-specific form validation

Measurement Units

  • Support metric and imperial units
  • Display appropriate units based on locale
  • Allow user preference override
  • Convert values accurately

Calendars and Time

  • Support different calendar systems (Gregorian, Hijri, etc.)
  • Handle timezone display preferences
  • Support different week start days (Sunday vs Monday)
  • Display appropriate date formats

Testing and Quality Assurance

Localization Testing

  • Test with native speakers for each locale
  • Verify layout with actual translated content
  • Test all date, number, and currency formats
  • Verify RTL layouts function correctly

Automated Checks

  • Implement missing translation detection
  • Check for hardcoded strings in code
  • Validate translation file format and completeness
  • Monitor for translation quality issues

Pseudolocalization

  • Use pseudolocalization during development
  • Detect hardcoded strings early
  • Verify UI handles text expansion
  • Test character encoding support

Content Delivery

Language Detection

  • Detect user language from browser/device settings
  • Support URL-based locale switching (/en/, /es/, /fr/)
  • Persist user language preference
  • Implement graceful fallback mechanisms

Performance Optimization

  • Lazy load translation files by namespace
  • Cache translations appropriately
  • Use CDN for static translation files
  • Minimize initial translation bundle size

Integration Best Practices

State Management

  • Store locale preference in user settings
  • Sync preference across devices when logged in
  • Handle locale changes without full page reload
  • Update all components on locale switch

API Integration

  • Pass locale in API requests
  • Return localized content from backend when appropriate
  • Handle server-side locale negotiation
  • Support content negotiation headers

來源與署名

來源:mindrally/skills位於localization-l10n提交9718410

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架