localjsons-cli
v1.0.3
Published
Command Line Interface for Localjsons - A powerful localization platform
Maintainers
Readme
Localjsons CLI
A powerful command-line interface for Localjsons - the modern localization platform.
Installation
npm (Recommended)
npm install -g localjsons-cliDirect Download
Download the latest release for your platform:
Docker
docker pull localjsons/cli:latest
docker run --rm localjsons/cli --versionQuick Start
Initialize a project:
localjsons init your-project-idUpload translation files:
localjsons uploadDownload translations:
localjsons downloadCheck project status:
localjsons status
Commands
localjsons init [projectId]
Initialize a new Localjsons project.
Options:
-k, --api-key <key>- API key for authentication-u, --base-url <url>- Base URL for the API--skip-prompts- Skip interactive prompts and use defaults
Example:
localjsons init my-project --api-key your-api-keylocaljsons upload [files...]
Upload translation files to Localjsons.
Options:
-c, --config <path>- Path to config file (default: localjsons.json)--dry-run- Show what would be uploaded without actually uploading
Example:
localjsons upload "locales/*.json"
localjsons upload --dry-runlocaljsons download
Download latest translations from Localjsons.
Options:
-c, --config <path>- Path to config file (default: localjsons.json)--dry-run- Show what would be downloaded without actually downloading
Example:
localjsons download
localjsons download --dry-runlocaljsons status
Check project status and translation progress.
Options:
-c, --config <path>- Path to config file (default: localjsons.json)
Example:
localjsons statuslocaljsons config [action] [key] [value]
Manage configuration settings.
Actions:
list- List all configuration (default)get <key>- Get a specific configuration valueset <key> <value>- Set a configuration value
Example:
localjsons config list
localjsons config get upload.sourceLanguage
localjsons config set download.targetLanguages "es,fr,de"localjsons version
Show version information.
Example:
localjsons versionConfiguration
The CLI uses a localjsons.json configuration file in your project root:
{
"projectId": "your-project-id",
"apiKey": "your-api-key",
"baseUrl": "http://localhost:3000/api",
"upload": {
"sourceLanguage": "en",
"filePatterns": ["**/*.json", "**/locales/*.json"],
"excludePatterns": ["node_modules/**", "dist/**", "build/**"]
},
"download": {
"targetLanguages": ["es", "fr", "de"],
"outputPath": "./locales",
"format": "json"
}
}Configuration Options
- projectId: Your Localjsons project ID
- apiKey: Your API key for authentication
- baseUrl: Base URL for the API (optional)
- upload.sourceLanguage: Source language for translations
- upload.filePatterns: Glob patterns for files to upload
- upload.excludePatterns: Glob patterns for files to exclude
- download.targetLanguages: Languages to download
- download.outputPath: Directory to save downloaded files
- download.format: Output format (json, yaml, properties)
File Formats
The CLI supports multiple file formats:
- JSON:
{"key": "value"}(default) - YAML:
key: value - Properties:
key=value
Examples
Basic Workflow
# Initialize project
localjsons init my-project
# Upload source files
localjsons upload "src/locales/*.json"
# Download translations
localjsons download
# Check status
localjsons statusAdvanced Usage
# Upload specific files
localjsons upload "locales/en.json" "locales/es.json"
# Dry run to see what would be uploaded
localjsons upload --dry-run
# Use custom config file
localjsons upload -c config/localjsons.json
# Set configuration
localjsons config set download.targetLanguages "es,fr,de,it"Environment Variables
You can use environment variables instead of storing sensitive data in the config file:
LOCALJSONS_API_KEY- Your API keyLOCALJSONS_BASE_URL- Base URL for the API (usehttp://localhost:3000/apiin development)LOCALJSONS_PROJECT_ID- Your project ID
Troubleshooting
Common Issues
Config file not found
- Run
localjsons initto create a configuration file
- Run
Authentication failed
- Check your API key in the config file or environment variables
No files found to upload
- Check your file patterns in the configuration
- Use
--dry-runto see what files would be processed
Network errors
- Check your internet connection
- Verify the base URL if using a custom API endpoint
Getting Help
- Documentation: https://docs.localjsons.com/cli
- GitHub Issues: https://github.com/localjsons/cli/issues
- Support: https://localjsons.com/support
License
MIT License - see LICENSE for details.
Contributing
Contributions are welcome! Please see our Contributing Guide for details.
