
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
nuxt-i18n-micro-cli
Advanced tools
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.
This guide will walk you through installing, configuring, and using nuxt-i18n-micro-cli
to effectively manage your project's translations.
Install nuxt-i18n-micro-cli
globally using npm:
npm install -g nuxt-i18n-micro-cli
This will make the i18n-micro
command available globally on your system.
After installing, you can run i18n-micro
commands in your Nuxt.js project directory.
Ensure that your project is set up with nuxt-i18n
and has the necessary configuration in nuxt.config.js
.
For detailed documentation and further configuration options, visit the nuxt-i18n-micro CLI guide.
nuxt-i18n-micro-cli
provides several commands to help manage your translations:
extract
: Extract translation keys from your codebase.translate
: Automatically translate missing keys using external translation services.sync
: Synchronize translation files across locales.validate
: Validate translation files for missing or extra keys.stats
: Display translation statistics for each locale.clean
: Remove unused translation keys from translation files.import
: Convert PO files back to JSON format.export
: Export translations to PO files for external translation management.text-to-i18n
: Replace text in files with translation references.format
: Format translation files by sorting keys and applying consistent indentation.backup
: Creates password-protected zip archives of translation files for backup purposes.restore
: Restores translation files from a backup archive.optimize
: Optimize translation file structure for performance and maintainability.Each command can be run using i18n-micro <command>
.
--cwd
: Specify the current working directory (defaults to .
).--logLevel
: Set the log level (silent
, info
, verbose
).Description: Replace text in files with translation references
Usage:
i18n-micro text-to-i18n [options]
Description: Extracts translation keys from your codebase and organizes them by scope.
Usage:
i18n-micro extract [options]
Options:
--prod, -p
: Run in production mode.Example:
i18n-micro extract
This 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
).
Description: Automatically translates missing or all keys using external translation services.
Usage:
i18n-micro translate [options]
Options:
--translationDir
: Directory containing JSON translation files (default: locales
).--service
: Translation service to use (e.g., google
, deepl
, yandex
, etc.) (default: google
).--token
: API key corresponding to the translation service.--options
: Additional options for the translation service in key:value
pairs, separated by commas.--replace
: Translate all keys, replacing existing translations (default: false
).Example:
i18n-micro translate --service deepl --token YOUR_DEEPL_API_KEY
This command translates missing keys in your translation files using the specified translation service and saves the translations in the corresponding files.
Description: Synchronizes translation files across locales, ensuring all locales have the same keys.
Usage:
i18n-micro sync [options]
Options:
--translationDir
: Directory containing JSON translation files (default: locales
).Example:
i18n-micro sync
This 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.
Description: Validates translation files for missing or extra keys compared to the reference locale.
Usage:
i18n-micro validate [options]
Options:
--translationDir
: Directory containing JSON translation files (default: locales
).Example:
i18n-micro validate
This command checks for missing or extra keys in your translation files and reports any discrepancies.
Description: Displays translation statistics for each locale.
Usage:
i18n-micro stats [options]
Options:
--translationDir
: Directory containing JSON translation files (default: locales
).Example:
i18n-micro stats
This command shows the number of translated keys and the completion percentage for each locale compared to the reference locale.
Description: Removes unused translation keys from translation files.
Usage:
i18n-micro clean [options]
Options:
--translationDir
: Directory containing JSON translation files (default: locales
).Example:
i18n-micro clean
This command removes translation keys that are no longer used in your codebase from the translation files.
Description: Converts PO files back to JSON format and saves them in the translation directory.
Usage:
i18n-micro import [options]
Options:
--potsDir
: Directory containing PO files (default: pots
).--translationDir
: Directory to save JSON translation files (default: locales
).Example:
i18n-micro import --potsDir pots --translationDir locales
This command converts PO files to JSON and saves them in the specified translation directory.
Description: Exports translations to PO files for external translation management.
Usage:
i18n-micro export [options]
Options:
--potsDir
: Directory to save PO files (default: pots
).--translationDir
: Directory containing JSON translation files (default: locales
).Example:
i18n-micro export --potsDir pots
This command converts your JSON translation files to PO files, which can be used with external translation tools.
Description: Splits large translation files into smaller ones based on various criteria.
Usage:
i18n-micro split [options]
Options:
--translationDir <dir>
: Directory containing translation files (default: 'locales')--maxKeys <number>
: Maximum number of keys per file when splitting by key count--maxDepth <number>
: Maximum nesting depth when splitting by depth--splitByPrefix
: Split translations by their prefix (e.g., 'common', 'header', etc.)--outputDir <dir>
: Directory where split files will be saved (default: 'locales/split')--backup
: Create backup of original files before splitting--cwd <dir>
: Current working directory--logLevel <level>
: Logging level (default: 'info')Features:
Examples:
i18n-micro split --maxKeys 50
i18n-micro split --maxDepth 2
i18n-micro split --splitByPrefix
i18n-micro split --maxKeys 50 --maxDepth 2 --splitByPrefix --backup
i18n-micro split --outputDir locales/modules
Description: Formats translation files by sorting keys and applying consistent indentation.
Usage:
i18n-micro format [options]
Options:
--translationDir <dir>
: Directory containing translation files (default: 'locales')--indent <number>
: Number of spaces for indentation (default: 2)--sortKeys
: Sort translation keys alphabetically (default: true)--backup
: Create backup before formatting--cwd <dir>
: Current working directory--logLevel <level>
: Logging level (default: 'info')Features:
Examples:
i18n-micro format
i18n-micro format --indent 4 --backup
i18n-micro format --sortKeys false
i18n-micro format --translationDir locales/custom
Description: Creates password-protected zip archives of translation files for backup purposes.
Usage:
i18n-micro backup [options]
Options:
--translationDir <dir>
: Directory containing JSON translation files (default: 'locales')--backupDir <dir>
: Directory to save backup archives (default: 'locales/backups')--password <string>
: Password for encrypting the backup archive--comment <string>
: Optional comment to add to backup name--cwd <dir>
: Current working directory--logLevel <level>
: Logging level (default: 'info')Features:
Examples:
i18n-micro backup
i18n-micro backup --password "your-secure-password"
i18n-micro backup --comment "before-major-update"
i18n-micro backup --backupDir "backups/translations"
Description: Restores translation files from a backup archive.
Usage:
i18n-micro restore [options]
Options:
--translationDir <dir>
: Directory to restore translation files to (default: 'locales')--backupDir <dir>
: Directory containing backup archives (default: 'locales/backups')--backup <name>
: Name of the backup to restore (optional)--password <string>
: Password for decrypting the backup archive--force
: Skip confirmation prompt--cwd <dir>
: Current working directory--logLevel <level>
: Logging level (default: 'info')Features:
Examples:
i18n-micro restore
i18n-micro restore --backup "2024-03-20T12-00-00"
i18n-micro restore --backup "2024-03-20T12-00-00" --password "your-secure-password"
i18n-micro restore --backup "2024-03-20T12-00-00" --force
Description: Optimizes translation file structure for performance and maintainability.
Usage:
i18n-micro optimize [options]
Options:
--translationDir
: Directory containing JSON translation files (default: 'locales')--minSize
: Minimum file size in bytes for optimization (default: 1024)--maxDepth
: Maximum nesting depth for optimization (default: 3)--dryRun
: Show recommendations without making changes--updatePaths
: Update translation paths in Vue and JS files (default: true)--cwd
: Current working directory--logLevel
: Logging levelFeatures:
Examples:
# Analyze files without making changes
i18n-micro optimize --dryRun
# Optimize with minimum file size of 2KB
i18n-micro optimize --minSize 2048
# Optimize with maximum nesting depth of 2
i18n-micro optimize --maxDepth 2
# Optimize files in specified directory
i18n-micro optimize --translationDir custom/locales
# Optimize without updating paths in Vue and JS files
i18n-micro optimize --updatePaths false
Extracting translations:
i18n-micro extract
Translating missing keys using Google Translate:
i18n-micro translate --service google --token YOUR_GOOGLE_API_KEY
Translating all keys, replacing existing translations:
i18n-micro translate --service deepl --token YOUR_DEEPL_API_KEY --replace
Validating translation files:
i18n-micro validate
Cleaning unused translation keys:
i18n-micro clean
Synchronizing translation files:
i18n-micro sync
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.
export default {
modules: ['@nuxtjs/i18n'],
i18n: {
locales: [
{ code: 'en', iso: 'en-US' },
{ code: 'fr', iso: 'fr-FR' },
{ code: 'es', iso: 'es-ES' },
// Add other locales as needed
],
defaultLocale: 'en',
vueI18n: {
fallbackLocale: 'en',
},
// Specify the directory where your translation files are stored
translationDir: 'locales',
},
};
Ensure that the translationDir
matches the directory used by nuxt-i18n-micro-cli
(default is locales
).
The translate
command supports multiple translation services. Some of the supported services are:
google
)deepl
)yandex
)openai
)azure
)ibm
)baidu
)libretranslate
)mymemory
)lingvatranslate
)papago
)tencent
)systran
)yandexcloud
)modernmt
)lilt
)unbabel
)reverso
)Some 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.
For example:
i18n-micro translate --service openai --token YOUR_OPENAI_API_KEY --options openaiModel:gpt-3.5-turbo,max_tokens:1000
Ensure translation keys are consistent and descriptive to avoid confusion and duplication.
Use the clean
command regularly to remove unused translation keys and keep your translation files clean.
Integrate nuxt-i18n-micro-cli
commands into your development workflow or CI/CD pipeline to automate extraction, translation, validation, and synchronization of translation files.
When 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.
If you encounter issues or have suggestions for improvements, feel free to contribute to the project or open an issue on the project's repository.
v1.3.0
FAQs
⚡️ nuxt-i18n-micro-cli CLI Experience
We found that nuxt-i18n-micro-cli demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.