← スキル一覧に戻る

i18n-refactor
by KasonTsui
⭐ 0🍴 0📅 2026年1月14日
SKILL.md
name: i18n-refactor description: Automated workflow to refactor Angular components for i18n with namespaced JSON. It extracts strings, updates HTML/TS files, injects TranslateService, and generates nested en/tc translation objects. version: 1.1.0
Angular i18n Refactoring Skill (Namespaced)
Use this skill to systematically refactor Angular components for internationalization (ngx-translate) using a nested JSON structure (Namespaces).
workflow
1. Scan and Extract
- Analyze the user-selected HTML file.
- Determine the Namespace based on the component name (e.g.,
UserProfileComponent->USER_PROFILE). - Identify all hardcoded text nodes and static attributes (specifically
placeholder,title,alt,aria-label). - Generate keys nested under the namespace in
UPPER_SNAKE_CASE(e.g., Namespace:USER_PROFILE, Key:SUBMIT_BTN).
2. Template Refactoring (HTML)
- Replace text content with the pipe syntax using dot notation:
{{ 'NAMESPACE.KEY' | translate }}.- Example:
{{ 'USER_PROFILE.SUBMIT_BTN' | translate }}
- Example:
- Replace attributes with bound syntax:
[placeholder]="'NAMESPACE.KEY' | translate".
3. Component Dependency Injection (TS)
- Locate the corresponding
.tsfile. - Check Imports: Ensure
import { TranslateService } from '@ngx-translate/core';exists. - Check Injection: Verify if
TranslateServiceis injected.- If missing, add:
private translate = inject(TranslateService);(Use constructor injection for older Angular versions).
- If missing, add:
4. Translation Generation (JSON)
- Locate
src/assets/i18n/en.jsonandsrc/assets/i18n/tc.json. - Structure: Create or update the JSON with nested objects, not flat keys. Example Structure: "USER_PROFILE": { "SUBMIT_BTN": "Submit", "CANCEL_BTN": "Cancel" }
- English (en.json): Add the nested keys with original text.
- Traditional Chinese (tc.json): Auto-translate text to Traditional Chinese (Hong Kong style, zh-HK) and maintain the same nested structure.
5. Final Reporting
- Output a markdown table summary of the changes:
| Key ID | English (en.json) | Chinese (tc.json) |
|---|---|---|
USER_PROFILE.SUBMIT_BTN | "Submit" | "提交" |
Guidelines
- Strictly maintain JSON nesting. Do not create keys like
"USER_PROFILE.SUBMIT_BTN": "...". It must be"USER_PROFILE": { "SUBMIT_BTN": "..." }. - Prioritize "Hong Kong" terminology for
tc.json(e.g., use "登入" for Login, not "登錄"). - If the translation files are not in context, ask the user for their location.
スコア
総合スコア
45/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
○言語
プログラミング言語が設定されている
0/5
○タグ
1つ以上のタグが設定されている
0/5
レビュー
💬
レビュー機能は近日公開予定です