UNPKG

@logistically/i18n-cli

Version:

Enterprise-grade CLI tool for extracting and managing translations in Logistically microservices

39 lines 1.64 kB
#!/usr/bin/env node "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.replaceTranslationStrings = replaceTranslationStrings; exports.createReplaceCommand = createReplaceCommand; const commander_1 = require("commander"); const replacer_1 = require("../utils/replacer"); const logger_1 = require("../utils/logger"); const logger = logger_1.Logger.getInstance(); async function replaceTranslationStrings(options) { const replacer = new replacer_1.TranslationReplacer(); await replacer.replace({ path: options.path, keysFile: options.keysFile, backup: options.backup, dryRun: options.dryRun, verbose: options.verbose }); } function createReplaceCommand() { const command = new commander_1.Command('replace') .description('Replace hardcoded strings with translation keys in TypeScript files') .option('-p, --path <path>', 'Path to search for TypeScript files', '.') .option('-k, --keys-file <file>', 'Translation keys file', 'translation-keys.json') .option('--no-backup', 'Skip creating backup files') .option('--dry-run', 'Show what would be replaced without making changes') .option('-v, --verbose', 'Enable verbose output') .action(async (options) => { try { await replaceTranslationStrings(options); } catch (error) { logger.error(`Replacement failed: ${error instanceof Error ? error.message : 'Unknown error'}`); // Handle error gracefully without exiting } }); return command; } //# sourceMappingURL=replace.js.map