i18nsmith
v0.6.0
Published
CLI for i18nsmith
Readme
i18nsmith CLI
Command-line interface for i18nsmith - universal automated i18n.
Installation
npm install -g i18nsmith
# or
pnpm add -g i18nsmithQuick Start
# Initialize project
i18nsmith init
# Scan for translation candidates
i18nsmith scan
# Sync locale files with code
i18nsmith sync
# Run health checks
i18nsmith checkCommands
| Command | Description |
|---------|-------------|
| init | Initialize i18n configuration |
| scan | Scan source files for hardcoded text |
| sync | Synchronize locale files with code references |
| check | Run validation checks on locales |
| transform | Transform hardcoded strings to i18n calls |
| rename | Rename translation keys |
| diagnose | Generate diagnostic report |
| backup | Backup/restore locale files |
| detect | Auto-detect project configuration |
| review | Review borderline candidates interactively |
| translate | Translate using external services |
| coverage | Show translation coverage stats |
| preflight | Validate setup before operations |
| scaffold-adapter | Scaffold translation adapter files |
Architecture
The CLI follows Hexagonal Architecture principles. Commands use ServiceContainer for dependency injection:
import { getServiceContainer } from '../utils/bootstrap.js';
import { CliError, withErrorHandling } from '../utils/errors.js';
export function registerMyCommand(program: Command) {
program
.command('my-command')
.action(withErrorHandling(async (options) => {
const { config, projectRoot } = await loadConfigWithMeta(options.config);
const container = getServiceContainer({ workspaceRoot: projectRoot });
const result = await container.scanner.scan(config);
if (!result.success) {
throw new CliError(result.error.message);
}
// Use result.data
}));
}Service Container
The CLI bootstrap (src/utils/bootstrap.ts) configures:
NodeFileSystem- Node.js file operationsCliLoggerFactory- Console logging with chalk formatting
Commands Using ServiceContainer
| Command | Services Used |
|---------|--------------|
| scan | scanner |
| sync | keyRenamer |
| check | check |
| diagnose | diagnostics |
| detect | projectIntelligence |
| backup | backup |
| rename | keyRenamer |
| coverage | diagnostics |
| init | scanner, keyGenerator, projectIntelligence |
| review | scanner |
| scaffold-adapter | diagnostics |
Development
# Build
pnpm build
# Test
pnpm test
# Run locally
node dist/index.js <command>Adding New Commands
- Create command in
src/commands/my-command.ts - Use
getServiceContainer()for service access - Handle
Result<T>pattern for error handling - Register in
src/index.ts
See CONTRIBUTING.md for detailed patterns.
Related Documentation
| Document | Purpose | |----------|---------| | ARCHITECTURE.md | System architecture, Hexagonal pattern | | CONTRIBUTING.md | Contribution guidelines | | docs/schema.md | Configuration schema reference | | docs/best-practices.md | Usage best practices | | @i18nsmith/core README | Core library documentation |
