From time to time, Localazy users ask us how to handle specialized tasks with the Localazy CLI. Common requests include uploading localizable files from a ZIP archive, post-processing downloaded translations (merging them, changing the content, or copying them elsewhere), and more.

Localazy CLI doesn't and will likely never ship with every possible feature you might need to fully customize your workflow. We don't want to reinvent the wheel, and it would be almost impossible to support every specialized scenario. Instead, the CLI focuses on critical localization tasks while remaining flexible and script-friendly, ready for further personalization.

The big idea? Think of the Localazy CLI as one command among many in your workflow. Use standard command-line tools before or after calling localazy upload or localazy download. By chaining commands, you can accomplish almost any automation or customization task.

📚 Reference materials 🔗

Before we dive in, let's quickly refresh what you need to know about CLI:

Basic commands 🔗

  • localazy upload – Uploads your source files or strings to Localazy.
  • localazy download – Downloads translations back to your project.

Once you're up and running with these basics, you're ready to start chaining commands.

article-image

⛓ The power of chaining commands 🔗

In a shell environment (e.g., Bash, Zsh, PowerShell), you can invoke multiple commands in a sequence. The output of one command might be the input for another, or you might want to run commands in parallel or conditionally.

Why chaining matters 🔗

  • Automation: Instead of manually preparing files or post-processing them, you can script the entire pipeline.
  • Flexibility: Use native OS commands or third-party tools for tasks like archiving, renaming, uploading to remote servers, and more.
  • Efficiency: A single script can handle the entire "prepare → upload → download → finalize" cycle.

For example, if you want to prepare your JSON files before uploading, you might do something like this:

# 1) Combine multiple JSON partials into one file
jq -s 'reduce .[] as $item ({}; . * $item)' partials/*.json > combined.json

# 2) Upload combined.json using Localazy CLI
localazy upload --file combined.json

# 3) Clean up
rm combined.json

This mini-script merges multiple JSON files into one before uploading them to Localazy.

📝 10 command chaining ideas 🔗

Below are some common examples of how you can combine Localazy CLI calls with other commands and tools. Each idea has a quick snippet or conceptual workflow for inspiration.

1. Creating and extracting archives 🔗

  • Use case: Store your translation files in compressed archives or package downloaded translations to prepare them for distribution.
  • Tools: zip, unzip, tar, gzip, etc.
# Extract your source files from an archive
unzip my-translations.zip -d extracted_files/

# Upload the extracted files
localazy upload --path extracted_files/

# After downloads, compress them again
localazy download --path final_translations/
zip -r final_translations.zip final_translations/

2. Committing files to Git 🔗

  • Use case: Automatically commit newly downloaded translations to your Git repository.
  • Tools: git CLI
# Download translations
localazy download --path i18n/

# Commit them to your repo
git add i18n/
git commit -m "chore: update translations"
git push origin main
This can be integrated into a CI/CD pipeline such as GitHub Actions or GitLab CI/CD

3. Moving files to different locations 🔗

  • Use case: Distribute downloaded translations into multiple folders/projects.
  • Tools: mv, cp, or more advanced file-moving scripts.
# Download translations to a staging folder
localazy download --path translations_temp/

# Move files to each project
mv translations_temp/en.json projectA/src/locales/
mv translations_temp/es.json projectB/app/assets/lang/

4. Modifying files with Regex (sed, awk) 🔗

  • Use case: Remove or replace placeholders, internal IDs, or environment-specific URLs in translation files.
  • Tools: sed, awk, or other text processors.
# Download the translations
localazy download --path translations/

# Replace staging URL with production URL
sed -i 's|https://staging.example.com|https://production.example.com|g' translations/*.json

5. Merging, splitting, and overriding files 🔗

  • Use case: Combine multiple files into one, split a large file into smaller ones, or override specific keys using other files.
  • Tools: jq, custom scripts, etc.
localazy download --path dl_files/
# Suppose you have en.json and en-extra.json in dl_files/ and want to merge them.

jq -s 'reduce .[] as $item ({}; . * $item)' dl_files/en.json dl_files/en-extra.json > dl_files/en-merged.json

6. Changing file formats 🔗

  • Use case: Convert downloaded files into a format your framework needs.
  • Tools: yq, custom XML/Properties converters, etc.
# Convert YAML to JSON
yq -o=json translations.yaml > translations.json

# Then upload the JSON to Localazy
localazy upload --file translations.json
💡
Tip: Consider using Localazy Format Conversions, which provide more options, 15+ conversion pairs, and might be better suited for your use case. Explore the capabilities in the documentation

7. Generating source code from translations 🔗

  • Use case: Some frameworks prefer translations as source code files (e.g., .dart, .ts).
  • Tools: Node.js scripts, custom Python scripts, templating engines, etc.
# Download the translations
localazy download --path i18n/

# Generate TypeScript constants
node scripts/generate-ts-constants.js i18n/en.json src/i18n/en.ts

Your generate-ts-constants.js script would parse the JSON and produce a .ts file with typed exports.

8. Running a linter or validator 🔗

  • Use case: Ensure files maintain correct placeholders, avoid broken links, or follow a certain schema.
  • Tools: ESLint, custom scripts, or specialized translation linters.
localazy download --path i18n/

# Validate JSON structure with a JSON schema validator
ajv validate -s schema.json -d i18n/*.json

9. Uploading to FTP, SFTP, or cloud storage 🔗

  • Use case: Automatically upload your translations to a CDN or remote server.
  • Tools: scp, sftp, AWS CLI, Azure CLI, GCP CLI, etc.
# Download translations
localazy download --path i18n/

# Upload them to an SFTP server
scp i18n/*.json [email protected]:/var/www/translations/

10. Creating files from and inserting them in a database 🔗

  • Use case: You might have translations stored in a DB. Export them to a file, upload them to Localazy, and then reimport the final translations back into the DB.
  • Tools: psql, mysqldump, custom SQL scripts.

⤵️ Creating files from DB:

# Example with PostgreSQL: dump translations to JSON
psql -U user -d mydb -c "COPY (SELECT json_agg(t) FROM translations t) TO STDOUT" > db_translations.json

# Upload to Localazy
localazy upload --file db_translations.json

↪️ Inserting into DB:

# Download from Localazy
localazy download --path downloaded_files/

# Insert them back into your DB
psql -U user -d mydb -c "\COPY translations FROM 'downloaded_files/en.json'"

You can also find inspiration in our PostgreSQL solution for detailed setup instructions.

✔️ Conclusion 🔗

These examples demonstrate how one small command, localazy upload or localazy download, can be part of a much larger workflow. By chaining commands from your operating system or other third-party tools, you're only limited by your imagination.

We'd love to hear how you're using our CLI! If you have a creative command-chain setup or face any challenges in your scripts, feel free to contact us. Localazy is designed to stay flexible, and user feedback helps us improve. 💪

Remember:

  • Automating with scripts saves time and reduces manual errors.
  • Standard CLI tools like tar, sed, jq, and git are your friends.
  • The Localazy CLI works best when it's one piece of your overall localization pipeline.

Happy chaining, and let us know if you need help getting your perfect workflow up and running!