A set of shell scripts designed to automate the localization process for iOS and Android projects. These scripts facilitate the downloading, translation, and management of localized strings using the Loco API and OpenAI's GPT model for translations.
- Download latest locales from Loco in various formats (CSV, iOS strings, Android XML)
- Translate missing strings using OpenAI's GPT model
- Upload translated strings back to Loco
- Generate localized files for iOS and Android projects
- Clean up temporary files
Before using these scripts, ensure you have the following:
- Bash shell
- curl
- jq (for JSON processing)
- An account with Loco (for API access)
- An OpenAI API key (for translations)
jq is a lightweight command-line JSON processor. To install it using Homebrew:
brew install jq
-
Clone this repository to your local machine.
-
Duplicate the
example.envfile and rename it to.env:cp example.env .env -
Open the
.envfile and fill in your specific details:# Loco API Key LOCO_API_KEY=your_loco_api_key_here # OpenAI API Key OPENAI_API_KEY=your_openai_api_key_here # Supported locales (comma-separated) LOCALES=es,pt,fr # Other configuration variables... -
Make sure all scripts are executable:
chmod +x *.sh
The main script that orchestrates the entire process is localize.sh. To run it:
cd Locolize
./localize.sh [ios|android]
This script will:
- Pull the latest locales from Loco
- Allow you to edit the CSV file if needed
- Translate missing strings
- Push the updated strings back to Loco
- Generate localized files for your iOS or Android project
- Clean up temporary files
To run any of the scripts you need to first enter in the Locolize directory:
cd Locolize
./[pull|translate|push|generate|clean].sh
pull.sh: Downloads the latest locales from Loco in CSV formattranslate.sh: Translates missing strings using OpenAI's GPT modelpush.sh: Uploads the updated CSV file back to Locogenerate.sh: Generates localized files for iOS or Android projectsclean.sh: Removes temporary files and directories
The config.sh file contains various configuration settings used across the scripts. Modify this file if you need to change paths, file names, or other settings.
To add or modify supported languages, update the LOCALES variable in your .env file.
- Always review the generated translations before pushing them to production.
- Be mindful of API usage limits for both Loco and OpenAI.
Contributions to improve these scripts are welcome. Please submit a pull request or open an issue to discuss proposed changes.