From 05da537e456901d16ae83bd485b2361389dcd792 Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Thu, 15 Jan 2026 13:21:58 +0100 Subject: [PATCH] fix(docs): correct malformed markdown in extract-translations command Fix broken markdown formatting where multiple sections were collapsed into a single malformed block. Properly structure HTML/TypeScript code examples, key naming conventions, usage examples, and edge cases. #6004 --- .claude/commands/extract-translations.md | 117 +++++++++++++++++------ 1 file changed, 86 insertions(+), 31 deletions(-) diff --git a/.claude/commands/extract-translations.md b/.claude/commands/extract-translations.md index 8981002df..df968a066 100644 --- a/.claude/commands/extract-translations.md +++ b/.claude/commands/extract-translations.md @@ -1,8 +1,8 @@ - - You are a translation extraction specialist that identifies untranslated strings in recently changed HTML and TypeScript files, extracts them to the translation files, and updates the source code to use translation keys. - + +You are a translation extraction specialist that identifies untranslated strings in recently changed HTML and TypeScript files, extracts them to the translation files, and updates the source code to use translation keys. + - + ## Phase 1: Identify Changed Files @@ -63,14 +63,14 @@ For each changed file: 2. Verify changes compile correctly 3. Report summary of changes - + - - Optional arguments: - - `--days `: How many days back to check for changes (default: 7) - - `--dry-run`: Preview changes without modifying files - - `--interactive`: Confirm each extraction before applying - + +Optional arguments: +- `--days `: How many days back to check for changes (default: 7) +- `--dry-run`: Preview changes without modifying files +- `--interactive`: Confirm each extraction before applying + @@ -88,25 +88,80 @@ For each changed file: {{ 'LABEL_NAME' | translate }} - - TypeScript Files // Extract these this.snackBar.open('Success!', 'OK'); const message = - 'Error occurred'; dialogConfig.data = { title: 'Confirm' }; // Skip these - this.snackBar.open(T.SUCCESS_MESSAGE, T.OK); const message = T.ERROR_OCCURRED; Follow - the existing pattern in en.json: - Feature-based grouping: FEATURE_COMPONENT_ELEMENT - - Action-based: ACTION_CONTEXT - Common elements: COMMON_ELEMENT_TYPE Examples: - - TASK_LIST_EMPTY_MESSAGE - DIALOG_CONFIRM_TITLE - BUTTON_SAVE # Extract translations from - files changed in last week /extract-translations # Check changes from last 3 days only - /extract-translations --days 3 # Preview without making changes /extract-translations - --dry-run # Interactive mode for selective extraction /extract-translations - --interactive Handle these edge cases: 1. Existing translations: Check if string already - has a key 2. Dynamic strings: Skip template literals and concatenations 3. Special - characters: Properly escape in JSON 4. File permissions: Ensure write access to - translation files 5. Git conflicts: Warn if en.json has uncommitted changes Summary - Report Translation Extraction Complete ============================== Files analyzed: 12 - Strings extracted: 8 Keys generated: 8 Changes by file: - - src/app/features/tasks/task-list.component.html ✓ "No tasks" → T.TASK_LIST_EMPTY ✓ "Add - task" → T.TASK_ADD_BUTTON - src/app/features/tasks/task.service.ts ✓ "Task saved" → - T.TASK_SAVED_MESSAGE Translation file updated: src/assets/i18n/en.json Build command - executed: npm run int ``` + +### TypeScript Files + +```typescript +// Extract these +this.snackBar.open('Success!', 'OK'); +const message = 'Error occurred'; +dialogConfig.data = { title: 'Confirm' }; + +// Skip these +this.snackBar.open(T.SUCCESS_MESSAGE, T.OK); +const message = T.ERROR_OCCURRED; +``` + +### Key Naming Conventions + +Follow the existing pattern in en.json: + +- Feature-based grouping: `FEATURE_COMPONENT_ELEMENT` +- Action-based: `ACTION_CONTEXT` +- Common elements: `COMMON_ELEMENT_TYPE` + +Examples: + +- `TASK_LIST_EMPTY_MESSAGE` +- `DIALOG_CONFIRM_TITLE` +- `BUTTON_SAVE` + + + +## Usage Examples + +```bash +# Extract translations from files changed in last week +/extract-translations + +# Check changes from last 3 days only +/extract-translations --days 3 + +# Preview without making changes +/extract-translations --dry-run + +# Interactive mode for selective extraction +/extract-translations --interactive +``` + +## Edge Cases + +Handle these edge cases: + +1. Existing translations: Check if string already has a key +2. Dynamic strings: Skip template literals and concatenations +3. Special characters: Properly escape in JSON +4. File permissions: Ensure write access to translation files +5. Git conflicts: Warn if en.json has uncommitted changes + +## Summary Report Example + +``` +Translation Extraction Complete +============================== +Files analyzed: 12 +Strings extracted: 8 +Keys generated: 8 + +Changes by file: +- src/app/features/tasks/task-list.component.html + ✓ "No tasks" → T.TASK_LIST_EMPTY + ✓ "Add task" → T.TASK_ADD_BUTTON +- src/app/features/tasks/task.service.ts + ✓ "Task saved" → T.TASK_SAVED_MESSAGE + +Translation file updated: src/assets/i18n/en.json +Build command executed: npm run int +```