[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-4216a488-6409-46bc-a800-db7b34e385c2":3,"$fSoGxfeeizeOjD5RrUB9oEOvLdX6xZIj9yLWeo5kPSaE":42},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":33},"4216a488-6409-46bc-a800-db7b34e385c2","i18n-localization","国际化与本地化模式。检测硬编码字符串，管理翻译，区域文件，右对齐支持。","cat_writing_translation","mod_writing","sickn33,writing","---\nname: i18n-localization\ndescription: \"Internationalization and localization patterns. Detecting hardcoded strings, managing translations, locale files, RTL support.\"\nrisk: safe\nsource: community\ndate_added: \"2026-02-27\"\n---\n\n# i18n & Localization\n\n> Internationalization (i18n) and Localization (L10n) best practices.\n\n---\n\n## 1. Core Concepts\n\n| Term | Meaning |\n|------|---------|\n| **i18n** | Internationalization - making app translatable |\n| **L10n** | Localization - actual translations |\n| **Locale** | Language + Region (en-US, tr-TR) |\n| **RTL** | Right-to-left languages (Arabic, Hebrew) |\n\n---\n\n## 2. When to Use i18n\n\n| Project Type | i18n Needed? |\n|--------------|--------------|\n| Public web app | ✅ Yes |\n| SaaS product | ✅ Yes |\n| Internal tool | ⚠️ Maybe |\n| Single-region app | ⚠️ Consider future |\n| Personal project | ❌ Optional |\n\n---\n\n## 3. Implementation Patterns\n\n### React (react-i18next)\n\n```tsx\nimport { useTranslation } from 'react-i18next';\n\nfunction Welcome() {\n  const { t } = useTranslation();\n  return \u003Ch1>{t('welcome.title')}\u003C\u002Fh1>;\n}\n```\n\n### Next.js (next-intl)\n\n```tsx\nimport { useTranslations } from 'next-intl';\n\nexport default function Page() {\n  const t = useTranslations('Home');\n  return \u003Ch1>{t('title')}\u003C\u002Fh1>;\n}\n```\n\n### Python (gettext)\n\n```python\nfrom gettext import gettext as _\n\nprint(_(\"Welcome to our app\"))\n```\n\n---\n\n## 4. File Structure\n\n```\nlocales\u002F\n├── en\u002F\n│   ├── common.json\n│   ├── auth.json\n│   └── errors.json\n├── tr\u002F\n│   ├── common.json\n│   ├── auth.json\n│   └── errors.json\n└── ar\u002F          # RTL\n    └── ...\n```\n\n---\n\n## 5. Best Practices\n\n### DO ✅\n\n- Use translation keys, not raw text\n- Namespace translations by feature\n- Support pluralization\n- Handle date\u002Fnumber formats per locale\n- Plan for RTL from the start\n- Use ICU message format for complex strings\n\n### DON'T ❌\n\n- Hardcode strings in components\n- Concatenate translated strings\n- Assume text length (German is 30% longer)\n- Forget about RTL layout\n- Mix languages in same file\n\n---\n\n## 6. Common Issues\n\n| Issue | Solution |\n|-------|----------|\n| Missing translation | Fallback to default language |\n| Hardcoded strings | Use linter\u002Fchecker script |\n| Date format | Use Intl.DateTimeFormat |\n| Number format | Use Intl.NumberFormat |\n| Pluralization | Use ICU message format |\n\n---\n\n## 7. RTL Support\n\n```css\n\u002F* CSS Logical Properties *\u002F\n.container {\n  margin-inline-start: 1rem;  \u002F* Not margin-left *\u002F\n  padding-inline-end: 1rem;   \u002F* Not padding-right *\u002F\n}\n\n[dir=\"rtl\"] .icon {\n  transform: scaleX(-1);\n}\n```\n\n---\n\n## 8. Checklist\n\nBefore shipping:\n\n- [ ] All user-facing strings use translation keys\n- [ ] Locale files exist for all supported languages\n- [ ] Date\u002Fnumber formatting uses Intl API\n- [ ] RTL layout tested (if applicable)\n- [ ] Fallback language configured\n- [ ] No hardcoded strings in components\n\n---\n\n## Script\n\n| Script | Purpose | Command |\n|--------|---------|---------|\n| `scripts\u002Fi18n_checker.py` | Detect hardcoded strings & missing translations | `python scripts\u002Fi18n_checker.py \u003Cproject_path>` |\n\n## When to Use\nThis skill is applicable to execute the workflow or actions described in the overview.\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,135,249,"2026-05-16 13:23:14",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"写作研究","writing","mdi-pencil-outline","从学术写作到创意文案，让 AI 成为你的专属写作助手",1,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":32,"skillCount":25,"createdAt":26},"翻译","translation","mdi-translate","多语言翻译、本地化",3,[34],{"id":35,"skillId":4,"version":36,"fileName":37,"fileSize":38,"filePath":39,"fileHash":40,"manifest":41,"createdAt":19},"e0d5cbca-55c5-460f-88b7-3ea30b6f2e8f","1.0.0","i18n-localization.zip",4436,"uploads\u002Fskills\u002F4216a488-6409-46bc-a800-db7b34e385c2\u002Fi18n-localization.zip","c2ecd52c41fa8d280e920be3e319fa93c185399f9a33644d5a44c68725ba4cf3","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":3567},{\"path\":\"scripts\u002Fi18n_checker.py\",\"isDirectory\":false,\"size\":7714}]",{"code":43,"message":44,"data":45},200,"success",{"items":46,"stats":47,"page":50},[],{"averageRating":48,"totalRatings":48,"ratingCounts":49},0,[48,48,48,48,48],{"limit":51,"offset":48,"hasMore":52,"nextOffset":51,"ratedOnly":16},15,false]