{"id":21344476,"url":"https://github.com/s00d/nuxt-i18n-micro-cli","last_synced_at":"2026-02-09T10:34:17.832Z","repository":{"id":257551444,"uuid":"858666837","full_name":"s00d/nuxt-i18n-micro-cli","owner":"s00d","description":null,"archived":false,"fork":false,"pushed_at":"2024-09-18T08:30:58.000Z","size":744,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-06T03:07:04.166Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/s00d.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-17T10:17:59.000Z","updated_at":"2024-09-18T08:31:02.000Z","dependencies_parsed_at":"2024-09-17T11:05:13.719Z","dependency_job_id":"ade2cfaf-a8bc-4fca-8b9c-8f8c4c9cf11d","html_url":"https://github.com/s00d/nuxt-i18n-micro-cli","commit_stats":null,"previous_names":["s00d/nuxt-i18n-micro-cli"],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s00d%2Fnuxt-i18n-micro-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s00d%2Fnuxt-i18n-micro-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s00d%2Fnuxt-i18n-micro-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s00d%2Fnuxt-i18n-micro-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/s00d","download_url":"https://codeload.github.com/s00d/nuxt-i18n-micro-cli/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225825376,"owners_count":17530069,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-22T01:19:12.658Z","updated_at":"2026-02-09T10:34:12.798Z","avatar_url":"https://github.com/s00d.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nuxt i18n CLI\n\n\n## 📖 Introduction\n\n`nuxt-i18n-micro-cli` is a command-line tool designed to streamline the localization and internationalization process in Nuxt.js projects using the `nuxt-i18n` module. It provides utilities to extract translation keys from your codebase, manage translation files, synchronize translations across locales, and automate the translation process using external translation services.\n\nThis guide will walk you through installing, configuring, and using `nuxt-i18n-micro-cli` to effectively manage your project's translations.\n\n## 🔧 Installation and Setup\n\n### 📦 Installing nuxt-i18n-micro-cli\n\nInstall `nuxt-i18n-micro-cli` globally using npm:\n\n```bash\nnpm install -g nuxt-i18n-micro-cli\n```\n\nThis will make the `i18n-micro` command available globally on your system.\n\n### 🛠 Initializing in Your Project\n\nAfter installing, you can run `i18n-micro` commands in your Nuxt.js project directory.\n\nEnsure that your project is set up with `nuxt-i18n` and has the necessary configuration in `nuxt.config.js`.\n\n\nFor detailed documentation and further configuration options, visit the [nuxt-i18n-micro CLI guide](https://s00d.github.io/nuxt-i18n-micro/guide/cli).\n\n## 🗂️ Commands and Usage\n\n`nuxt-i18n-micro-cli` provides several commands to help manage your translations:\n\n- [`extract`](#extract): Extract translation keys from your codebase.\n- [`translate`](#translate): Automatically translate missing keys using external translation services.\n- [`sync`](#sync): Synchronize translation files across locales.\n- [`validate`](#validate): Validate translation files for missing or extra keys.\n- [`stats`](#stats): Display translation statistics for each locale.\n- [`clean`](#clean): Remove unused translation keys from translation files.\n- [`import`](#import): Convert PO files back to JSON format.\n- [`export`](#export): Export translations to PO files for external translation management.\n- [`text-to-i18n`](#text-to-i18n): Replace text in files with translation references.\n- [`format`](#format): Format translation files by sorting keys and applying consistent indentation.\n- [`backup`](#backup): Creates password-protected zip archives of translation files for backup purposes.\n- [`restore`](#restore): Restores translation files from a backup archive.\n- [`optimize`](#optimize): Optimize translation file structure for performance and maintainability.\n\nEach command can be run using `i18n-micro \u003ccommand\u003e`.\n\n### 📄 Common Arguments\n\n- `--cwd`: Specify the current working directory (defaults to `.`).\n- `--logLevel`: Set the log level (`silent`, `info`, `verbose`).\n\n### 📋 Commands\n\n#### text-to-i18n\n\n**Description**: Replace text in files with translation references\n\n**Usage**:\n\n```bash\ni18n-micro text-to-i18n [options]\n```\n\n#### extract\n\n**Description**: Extracts translation keys from your codebase and organizes them by scope.\n\n**Usage**:\n\n```bash\ni18n-micro extract [options]\n```\n\n**Options**:\n\n- `--prod, -p`: Run in production mode.\n\n**Example**:\n\n```bash\ni18n-micro extract\n```\n\nThis command scans your project files, extracts translation keys used in components, pages, layouts, etc., and generates translation files in the specified translation directory (default is `locales`).\n\n#### translate\n\n**Description**: Automatically translates missing or all keys using external translation services.\n\n**Usage**:\n\n```bash\ni18n-micro translate [options]\n```\n\n**Options**:\n\n- `--translationDir`: Directory containing JSON translation files (default: `locales`).\n- `--service`: Translation service to use (e.g., `google`, `deepl`, `yandex`, etc.) (default: `google`).\n- `--token`: API key corresponding to the translation service.\n- `--options`: Additional options for the translation service in `key:value` pairs, separated by commas.\n- `--replace`: Translate all keys, replacing existing translations (default: `false`).\n\n**Example**:\n\n```bash\ni18n-micro translate --service deepl --token YOUR_DEEPL_API_KEY\n```\n\nThis command translates missing keys in your translation files using the specified translation service and saves the translations in the corresponding files.\n\n#### sync\n\n**Description**: Synchronizes translation files across locales, ensuring all locales have the same keys.\n\n**Usage**:\n\n```bash\ni18n-micro sync [options]\n```\n\n**Options**:\n\n- `--translationDir`: Directory containing JSON translation files (default: `locales`).\n\n**Example**:\n\n```bash\ni18n-micro sync\n```\n\nThis command synchronizes the translation files based on the reference locale (the first locale specified in your `nuxt.config.js`), adding missing keys and ensuring consistency.\n\n#### validate\n\n**Description**: Validates translation files for missing or extra keys compared to the reference locale.\n\n**Usage**:\n\n```bash\ni18n-micro validate [options]\n```\n\n**Options**:\n\n- `--translationDir`: Directory containing JSON translation files (default: `locales`).\n\n**Example**:\n\n```bash\ni18n-micro validate\n```\n\nThis command checks for missing or extra keys in your translation files and reports any discrepancies.\n\n#### stats\n\n**Description**: Displays translation statistics for each locale.\n\n**Usage**:\n\n```bash\ni18n-micro stats [options]\n```\n\n**Options**:\n\n- `--translationDir`: Directory containing JSON translation files (default: `locales`).\n\n**Example**:\n\n```bash\ni18n-micro stats\n```\n\nThis command shows the number of translated keys and the completion percentage for each locale compared to the reference locale.\n\n#### clean\n\n**Description**: Removes unused translation keys from translation files.\n\n**Usage**:\n\n```bash\ni18n-micro clean [options]\n```\n\n**Options**:\n\n- `--translationDir`: Directory containing JSON translation files (default: `locales`).\n\n**Example**:\n\n```bash\ni18n-micro clean\n```\n\nThis command removes translation keys that are no longer used in your codebase from the translation files.\n\n#### import\n\n**Description**: Converts PO files back to JSON format and saves them in the translation directory.\n\n**Usage**:\n\n```bash\ni18n-micro import [options]\n```\n\n**Options**:\n\n- `--potsDir`: Directory containing PO files (default: `pots`).\n- `--translationDir`: Directory to save JSON translation files (default: `locales`).\n\n**Example**:\n\n```bash\ni18n-micro import --potsDir pots --translationDir locales\n```\n\nThis command converts PO files to JSON and saves them in the specified translation directory.\n\n#### export\n\n**Description**: Exports translations to PO files for external translation management.\n\n**Usage**:\n\n```bash\ni18n-micro export [options]\n```\n\n**Options**:\n\n- `--potsDir`: Directory to save PO files (default: `pots`).\n- `--translationDir`: Directory containing JSON translation files (default: `locales`).\n\n**Example**:\n\n```bash\ni18n-micro export --potsDir pots\n```\n\nThis command converts your JSON translation files to PO files, which can be used with external translation tools.\n\n#### split\n\n**Description**: Splits large translation files into smaller ones based on various criteria.\n\n**Usage**:\n\n```bash\ni18n-micro split [options]\n```\n\n**Options**:\n\n- `--translationDir \u003cdir\u003e`: Directory containing translation files (default: 'locales')\n- `--maxKeys \u003cnumber\u003e`: Maximum number of keys per file when splitting by key count\n- `--maxDepth \u003cnumber\u003e`: Maximum nesting depth when splitting by depth\n- `--splitByPrefix`: Split translations by their prefix (e.g., 'common', 'header', etc.)\n- `--outputDir \u003cdir\u003e`: Directory where split files will be saved (default: 'locales/split')\n- `--backup`: Create backup of original files before splitting\n- `--cwd \u003cdir\u003e`: Current working directory\n- `--logLevel \u003clevel\u003e`: Logging level (default: 'info')\n\n**Features**:\n\n1. **Split by Key Count**: Divides translations into smaller files based on the maximum number of keys\n2. **Split by Depth**: Separates translations based on their nesting depth\n3. **Split by Prefix**: Groups translations by their prefix (e.g., 'common', 'header', etc.)\n4. **Combined Splitting**: Can combine multiple splitting strategies\n5. **Backup Support**: Creates backup of original files before splitting\n\n**Examples**:\n\n1. Split translations into files with maximum 50 keys each:\n```bash\ni18n-micro split --maxKeys 50\n```\n\n2. Split translations by depth, keeping maximum 2 levels of nesting:\n```bash\ni18n-micro split --maxDepth 2\n```\n\n3. Split translations by their prefixes (e.g., 'common', 'header', etc.):\n```bash\ni18n-micro split --splitByPrefix\n```\n\n4. Combine multiple splitting strategies with backup:\n```bash\ni18n-micro split --maxKeys 50 --maxDepth 2 --splitByPrefix --backup\n```\n\n5. Specify custom output directory:\n```bash\ni18n-micro split --outputDir locales/modules\n```\n\n#### format\n\n**Description**: Formats translation files by sorting keys and applying consistent indentation.\n\n**Usage**:\n\n```bash\ni18n-micro format [options]\n```\n\n**Options**:\n\n- `--translationDir \u003cdir\u003e`: Directory containing translation files (default: 'locales')\n- `--indent \u003cnumber\u003e`: Number of spaces for indentation (default: 2)\n- `--sortKeys`: Sort translation keys alphabetically (default: true)\n- `--backup`: Create backup before formatting\n- `--cwd \u003cdir\u003e`: Current working directory\n- `--logLevel \u003clevel\u003e`: Logging level (default: 'info')\n\n**Features**:\n\n1. **Sort by Key**: Sorts translation keys alphabetically\n2. **Indentation**: Applies consistent indentation\n3. **Backup**: Creates backup before formatting\n4. **Multiple Locales**: Supports multiple locales\n5. **Nested Structure**: Preserves nested translation structures\n\n**Examples**:\n\n1. Format all translation files with default settings:\n```bash\ni18n-micro format\n```\n\n2. Format with custom indentation and create backup:\n```bash\ni18n-micro format --indent 4 --backup\n```\n\n3. Format without sorting keys:\n```bash\ni18n-micro format --sortKeys false\n```\n\n4. Format specific translation directory:\n```bash\ni18n-micro format --translationDir locales/custom\n```\n\n#### backup\n\n**Description**: Creates password-protected zip archives of translation files for backup purposes.\n\n**Usage**:\n\n```bash\ni18n-micro backup [options]\n```\n\n**Options**:\n\n- `--translationDir \u003cdir\u003e`: Directory containing JSON translation files (default: 'locales')\n- `--backupDir \u003cdir\u003e`: Directory to save backup archives (default: 'locales/backups')\n- `--password \u003cstring\u003e`: Password for encrypting the backup archive\n- `--comment \u003cstring\u003e`: Optional comment to add to backup name\n- `--cwd \u003cdir\u003e`: Current working directory\n- `--logLevel \u003clevel\u003e`: Logging level (default: 'info')\n\n**Features**:\n\n1. **Password Protection**: Creates encrypted zip archives for secure backups\n2. **Automatic Naming**: Generates unique backup names using timestamps\n3. **Custom Comments**: Allows adding descriptive comments to backup names\n4. **Directory Structure**: Preserves the complete directory structure of translations\n5. **Compression**: Uses maximum compression to minimize backup size\n\n**Examples**:\n\n1. Create a basic backup:\n```bash\ni18n-micro backup\n```\n\n2. Create an encrypted backup with password:\n```bash\ni18n-micro backup --password \"your-secure-password\"\n```\n\n3. Create a backup with a descriptive comment:\n```bash\ni18n-micro backup --comment \"before-major-update\"\n```\n\n4. Specify custom backup directory:\n```bash\ni18n-micro backup --backupDir \"backups/translations\"\n```\n\n#### restore\n\n**Description**: Restores translation files from a backup archive.\n\n**Usage**:\n\n```bash\ni18n-micro restore [options]\n```\n\n**Options**:\n\n- `--translationDir \u003cdir\u003e`: Directory to restore translation files to (default: 'locales')\n- `--backupDir \u003cdir\u003e`: Directory containing backup archives (default: 'locales/backups')\n- `--backup \u003cname\u003e`: Name of the backup to restore (optional)\n- `--password \u003cstring\u003e`: Password for decrypting the backup archive\n- `--force`: Skip confirmation prompt\n- `--cwd \u003cdir\u003e`: Current working directory\n- `--logLevel \u003clevel\u003e`: Logging level (default: 'info')\n\n**Features**:\n\n1. **Password Protection**: Supports restoring from encrypted backups\n2. **Interactive Selection**: Lists available backups if none specified\n3. **Confirmation**: Requires confirmation before restoring (can be skipped with --force)\n4. **Directory Structure**: Preserves the complete directory structure of translations\n5. **Cleanup**: Automatically cleans up temporary files after restoration\n\n**Examples**:\n\n1. List available backups:\n```bash\ni18n-micro restore\n```\n\n2. Restore from a specific backup:\n```bash\ni18n-micro restore --backup \"2024-03-20T12-00-00\"\n```\n\n3. Restore from an encrypted backup:\n```bash\ni18n-micro restore --backup \"2024-03-20T12-00-00\" --password \"your-secure-password\"\n```\n\n4. Restore without confirmation:\n```bash\ni18n-micro restore --backup \"2024-03-20T12-00-00\" --force\n```\n\n#### optimize\n\n**Description**: Optimizes translation file structure for performance and maintainability.\n\n**Usage**:\n\n```bash\ni18n-micro optimize [options]\n```\n\n**Options**:\n\n- `--translationDir`: Directory containing JSON translation files (default: 'locales')\n- `--minSize`: Minimum file size in bytes for optimization (default: 1024)\n- `--maxDepth`: Maximum nesting depth for optimization (default: 3)\n- `--dryRun`: Show recommendations without making changes\n- `--updatePaths`: Update translation paths in Vue and JS files (default: true)\n- `--cwd`: Current working directory\n- `--logLevel`: Logging level\n\n**Features**:\n\n- Analyzes file sizes and splits large files into smaller ones\n- Optimizes deeply nested keys\n- Removes duplicate keys\n- Updates translation paths in Vue and JS files\n- Preserves translation structure\n- Interactive mode with confirmation of changes\n- Dry run mode for preview\n\n**Examples**:\n\n```bash\n# Analyze files without making changes\ni18n-micro optimize --dryRun\n\n# Optimize with minimum file size of 2KB\ni18n-micro optimize --minSize 2048\n\n# Optimize with maximum nesting depth of 2\ni18n-micro optimize --maxDepth 2\n\n# Optimize files in specified directory\ni18n-micro optimize --translationDir custom/locales\n\n# Optimize without updating paths in Vue and JS files\ni18n-micro optimize --updatePaths false\n```\n\n### 🛠 Examples\n\n- **Extracting translations**:\n\n  ```bash\n  i18n-micro extract\n  ```\n\n- **Translating missing keys using Google Translate**:\n\n  ```bash\n  i18n-micro translate --service google --token YOUR_GOOGLE_API_KEY\n  ```\n\n- **Translating all keys, replacing existing translations**:\n\n  ```bash\n  i18n-micro translate --service deepl --token YOUR_DEEPL_API_KEY --replace\n  ```\n\n- **Validating translation files**:\n\n  ```bash\n  i18n-micro validate\n  ```\n\n- **Cleaning unused translation keys**:\n\n  ```bash\n  i18n-micro clean\n  ```\n\n- **Synchronizing translation files**:\n\n  ```bash\n  i18n-micro sync\n  ```\n\n## ⚙️ Configuration Guide\n\n`nuxt-i18n-micro-cli` relies on your Nuxt.js i18n configuration in `nuxt.config.js`. Ensure you have the `nuxt-i18n` module installed and configured.\n\n### 🔑 nuxt.config.js Example\n\n```js\nexport default {\n  modules: ['@nuxtjs/i18n'],\n  i18n: {\n    locales: [\n      { code: 'en', iso: 'en-US' },\n      { code: 'fr', iso: 'fr-FR' },\n      { code: 'es', iso: 'es-ES' },\n      // Add other locales as needed\n    ],\n    defaultLocale: 'en',\n    vueI18n: {\n      fallbackLocale: 'en',\n    },\n    // Specify the directory where your translation files are stored\n    translationDir: 'locales',\n  },\n};\n```\n\nEnsure that the `translationDir` matches the directory used by `nuxt-i18n-micro-cli` (default is `locales`).\n\n## 🌐 Supported Translation Services\n\nThe `translate` command supports multiple translation services. Some of the supported services are:\n\n- **Google Translate** (`google`)\n- **DeepL** (`deepl`)\n- **Yandex Translate** (`yandex`)\n- **OpenAI** (`openai`)\n- **Azure Translator** (`azure`)\n- **IBM Watson** (`ibm`)\n- **Baidu Translate** (`baidu`)\n- **LibreTranslate** (`libretranslate`)\n- **MyMemory** (`mymemory`)\n- **Lingva Translate** (`lingvatranslate`)\n- **Papago** (`papago`)\n- **Tencent Translate** (`tencent`)\n- **Systran Translate** (`systran`)\n- **Yandex Cloud Translate** (`yandexcloud`)\n- **ModernMT** (`modernmt`)\n- **Lilt** (`lilt`)\n- **Unbabel** (`unbabel`)\n- **Reverso Translate** (`reverso`)\n\n### ⚙️ Service Configuration\n\nSome services require specific configurations or API keys. When using the `translate` command, you can specify the service and provide the required `--token` (API key) and additional `--options` if needed.\n\nFor example:\n\n```bash\ni18n-micro translate --service openai --token YOUR_OPENAI_API_KEY --options openaiModel:gpt-3.5-turbo,max_tokens:1000\n```\n\n## 📝 Best Practices\n\n### 🔑 Consistent Key Naming\n\nEnsure translation keys are consistent and descriptive to avoid confusion and duplication.\n\n### 🧹 Regular Maintenance\n\nUse the `clean` command regularly to remove unused translation keys and keep your translation files clean.\n\n### 🛠 Automate Translation Workflow\n\nIntegrate `nuxt-i18n-micro-cli` commands into your development workflow or CI/CD pipeline to automate extraction, translation, validation, and synchronization of translation files.\n\n### 🛡️ Secure API Keys\n\nWhen using translation services that require API keys, ensure your keys are kept secure and not committed to version control systems. Consider using environment variables or secure key management solutions.\n\n## 📞 Support and Contributions\n\nIf you encounter issues or have suggestions for improvements, feel free to contribute to the project or open an issue on the project's repository.\n\n## License\n\n[MIT](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs00d%2Fnuxt-i18n-micro-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fs00d%2Fnuxt-i18n-micro-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs00d%2Fnuxt-i18n-micro-cli/lists"}