Are you struggling to keep the UI strings in your code repo, your CMS and your translation software up to date? Many tools out there don’t exactly make it easy for developers to avoid data inconsistencies and preserve a single source of truth.
You change one string in the code and it can take days until it gets pushed to the translation system and even longer for the translation to be updated.
The i18n JSON command-line interface (CLI) is a collection of Python scripts that automatically sync JSON files for internationalization (i18n) with Gridly. This helps you automate the localization (l10n) of your software interface strings and ship faster.
In other words, every time you change text in your software, Gridly is updated and the translation triggered automatically, which means less waiting time and fewer manual steps to deploy your latest code.
The tool is available on GitHub. You can either download the executable file for Windows or for Mac. You can also compile the Python code yourself.
Here’s an example of the syntax for running the CLI. Just follow this pattern when calling the CLI. For details on supported arguments and options, see the readme file on GitHub.
gridlyi18njson.exe method rootPath viewId apiKey
Here’s a concrete example:
gridlyi18njson.exe import . 9982tis71srvj kv5gmct471sk6i
The view ID can be found in your Grid. To get your API key, follow this guide.
Note that the tool will run on all JSON files found in the specified root path and its subfolders. The folder structure is preserved in Gridly. In the given example “.” means that the root path is the same folder where the executable file is located.
The method can be “import” or “export”. You can also use the option “-c” to add columns for language columns that exist in the JSON file but not in your Grid.
Simply run the executable file manually or schedule the tool to run at specific intervals. You can just run the tool as a GitHub action. For details, see the official GitHub documentation.
Here are the basic steps for adding a GitHub action, assuming you are running Windows:
- Add your EXE file to a specific directory in your repository, such as “bin/”.
- Create a ‘.github/workflows’ directory if it doesn’t already exist.
- Create a YAML file in this directory, such as “action.yaml”.
- Write how to run the CLI into the YAML file.
Now every time the specified action is performed, the CLI will export the changes to GitHub.
Here’s some example code for a YAML file to call the CLI:
name: Run JSON CLI
on: [push, pull_request] # Specify the events that will trigger this action
jobs:
run-cli:
runs-on: windows-latest # Use the latest Windows runner
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Run JSON CLI
run: |
# Make sure the EXE is executable
chmod +x ./bin/gridlyi18njson.exe
# Run the EXE file with any required arguments
./bin/gridlyi18njson.exe -export . 9982tis71srvj kv5gmct471sk6i
If you don’t want to use a GitHub action and would rather run the executable as a regular task in Windows, you can proceed as follows:
- Open Task Scheduler: Press Win + R, type taskschd.msc, and press Enter.
- Create a New Task: In the Task Scheduler window, click on “Create Task…” in the right pane.
- General Tab: Provide a name for the task. Optionally, add a description. Select “Run whether user is logged on or not” for the task to run in the background.
- Triggers Tab: Click “New…”. In the “New Trigger” window, select the task trigger based on your requirement (e.g., daily, weekly, or monthly). To run the task at a custom interval (e.g., every x hours), select “Daily” and then click on the “Repeat task every” dropdown and choose your interval. Click “OK”.
- Actions Tab: Click “New…”. In the “New Action” window, select “Start a program”. Click “Browse…” and select the executable file you want to run. Click “OK”.
- Conditions Tab (optional): Adjust conditions based on your needs, such as running the task only if the computer is idle or on AC power.
- Settings Tab: Ensure the task is set to run as scheduled by enabling “Allow task to be run on demand”. Optionally, adjust additional settings like stopping the task if it runs longer than a specific time.
- Finish and Save: Click “OK” to save the task. Enter your user credentials if prompted.
In summary, automating the synchronization of i18n JSON files with Gridly streamlines the internationalization (i18n) and localization (l10n) processes for your software. Wherever your language files are stored, you can easily run this tool as a manual job or schedule it. The Gridly i18n JSON CLI ensures that every change in your UI copy is promptly updated and translated, minimizing manual effort and deployment times.