Automating multiple extension translation management using the transifex client and a shell script
Saturday, 04 May 2013 14:54
We've been using transifex for more than a year now, and quite happy with the way crowd sourcing can help enrich the reach of your extensions. However updating all the resources for all the extensions was a painful task and something everyone wanted to avoid. The tx-client eases some pain by allowing easy pushes & pulls of source files & translations. However the tx-client relies on a 'config' file to be updated with all the resource slugs. With so many extensions and also with so many plugin language files getting added regularly, its a tough task to keep on updating the config file.
At Techjoomla we had almost 10 major extensions using transifex, each with 5-10 resources. To speed up things, here's a shell script that I wrote up. The script automates updation of your transifex config file. That way, everytime you need to add more resources, just pull them from your source control and run the joomlatx.sh script and your config will be updated with all the resources.
Here's a step by step tutorial on how to set up and use the script
- Set up the transifex client and configure your username and password. Here are a few guides on how to do that -
Also ensure that the language map is correctly set up, this is an important step.
- Assuming you have all your repositories in /home/ashwin/SVN initialise the tx client in that folder
$ cd /home/ashwin/SVN
$ tx init
- Copy the joomlatx.sh and the project-langs.txt from github into the SVN folder
- The project-langs.txt needs to be updated with the correct locations of your files for each transifex project. The word in the square brackets is 'slug' of your project on transifex. This is the projectname part of the URL when you visit your project page on transifex.net. The lines following are the locations where project language files are present.
Assuming english (en-GB) is your base language your repository should be set up as
In this case, you should only put the path till the /lang folder. The script will automatically pick up the default language files based on the setting in joomlatx.sh
- Once this is set up simply run the script
Note: If you have already set up resources in Transifex, then you will need to update the resource slugs in transifex according to the relevant slug names that have been created in the config file by the script. If you dont do this, you will end up with duplicate language files on Transifex.
- Running the script will update your config file and map the language files to transifex resources.
- Now you can simply push and pull source and translations. If there are new translations, the client automatically creates the folders and copies the files.
$ tx push -s
$ tx pull