# Translation Management Tools ## ๐ Overview This directory contains tools and utilities for managing translations across the Password Generator application. These tools help identify, extract, and maintain translatable strings across HTML, JavaScript, and PHP files. ## ๐ ๏ธ Tools Provided ### 1. **extract-translations.php** Advanced PHP-based translation extractor that scans your codebase and automatically generates/updates translation files. **Features:** - โ Scans HTML, JavaScript, and PHP files - โ Extracts `data-i18n` attributes - โ Finds `this.t()` calls in JavaScript - โ Identifies hardcoded strings - โ Generates translation keys automatically - โ Updates existing translation files - โ Provides basic translations for common strings - โ Preserves consistent key structure across locales **Usage:** ```bash php extract-translations.php ``` ### 2. **update-translations.sh** Shell script for quick translation file updates and scanning. **Features:** - โ Fast scanning with grep/sed - โ Updates all language files at once - โ Shows translation coverage statistics - โ Identifies hardcoded strings - โ Color-coded output **Usage:** ```bash chmod +x update-translations.sh ./update-translations.sh ``` ## ๐ Current Translation Status ### Supported Languages - ๐บ๐ธ **English (en)** - Base language - ๐ฉ๐ช **German (de)** - Partially translated - ๐ซ๐ท **French (fr)** - Partially translated - ๐ฎ๐น **Italian (it)** - Placeholders only - ๐ช๐ธ **Spanish (es)** - Placeholders only - ๐ฏ๐ต **Japanese (ja)** - Placeholders only - ๐จ๐ณ **Chinese (zh)** - Placeholders only ### Translation Keys Identified The tools have identified these categories of translatable strings: #### **UI Elements** - `generate` - Generate button text - `copy` - Copy button text - `language` - Language selector label - `options` - Options section header - `loading` - Loading messages - `error` - Error messages - `success` - Success messages #### **Password Generator Types** - `high_entropy` - High Entropy generator name - `xkcd_pass` - XKCD Pass generator name - `diceware` - Diceware generator name - `pwgen` - PWGen generator name - `passkey` - Passkey generator name #### **API Documentation** - `api_documentation` - API Documentation link - `download` - Download button text - `interactive_api_explorer` - API Explorer heading - `openapi_json` - OpenAPI JSON description - `postman_collection` - Postman Collection description ## ๐ง How to Use These Tools ### **Step 1: Run the Extractor** ```bash # Use the PHP extractor for comprehensive analysis php extract-translations.php # OR use the shell script for quick updates ./update-translations.sh ``` ### **Step 2: Review Generated Files** Check the `locales/` directory for: - Updated JSON files for each language - Any missing or placeholder translation entries that still need review ### **Step 3: Fix Hardcoded Strings** **HTML Files:** ```html ``` **JavaScript Files:** ```javascript // BEFORE showNotification('Copied to clipboard!'); generateBtn.innerHTML = 'Generating...'; // AFTER showNotification(this.t('copied_to_clipboard')); generateBtn.innerHTML = this.t('generating'); ``` ### **Step 4: Translate Placeholder Strings** Replace placeholder entries in language files: ```json { "generate": "Generate (TODO: de)", // โ Replace this "copy": "Kopieren" // โ Already translated } ``` With proper translations: ```json { "generate": "Generieren", // โ Properly translated "copy": "Kopieren" // โ Already translated } ``` ## ๐ Translation Statistics Run the tools to get current statistics: ``` ๐ Translation Status Report ============================ en: 87/87 (100%) translated de: 45/87 (52%) translated fr: 32/87 (37%) translated it: 15/87 (17%) translated es: 15/87 (17%) translated ja: 0/87 (0%) translated zh: 0/87 (0%) translated ``` ## ๐ฏ Quick Win Translations ### **High Priority Strings (Visible to Users)** 1. `generate` โ "Generate" button 2. `copy` โ "Copy" button 3. `language` โ Language selector 4. `loading_generators` โ Loading message 5. `api_documentation` โ Header link 6. `back_to_generator` โ Navigation link ### **Common Translations Already Provided** **German (de):** - `generate` โ "Generieren" - `copy` โ "Kopieren" - `language` โ "Sprache" - `password_generator` โ "Passwort-Generator" **French (fr):** - `generate` โ "Gรฉnรฉrer" - `copy` โ "Copier" - `language` โ "Langue" - `password_generator` โ "Gรฉnรฉrateur de mots de passe" ## ๐จ Common Issues & Solutions ### **Issue: Missing data-i18n attributes** **Solution:** Add `data-i18n="key"` to HTML elements ```html