Using Crowdin

Working with translators can be a hassle. Especially if your App is translated to 10+ languages and you actively develop new features that require localization. New translations come in from the translators, developers already added their new strings to localization files - everything has to be merged somehow. This article describes how you can avoid this kind of problems.

At Wikia we use Crowdin. Crowdin is a Localization Management Platform. Crowdin has a lot of features including managing your own translators and hiring professionals fast. It provides UI for translators to work and supports most localization file formats out of the box.

One of the cool Crowdin features is its API. I wrote a few simple scripts using this API and they enhanced our workflow immensely.

Download script:

#!/bin/sh
APIKEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
TEMPDIR=`mktemp -d /tmp/translations.XXXXXX`
PROJDIR=`pwd`

echo "Created temporary directory ${TEMPDIR}"
cd ${TEMPDIR}
echo "Requesting rebuild from Crowdin"
curl -s https://api.crowdin.net/api/project/PROJECT-NAME/export?key=${APIKEY} 2>&1 1>/dev/null
echo "Downloading translations from Crowdin"
wget https://api.crowdin.net/api/project/PROJECT-NAME/download/all.zip?key=${APIKEY} -O translations.zip 2>/dev/null
echo "Unzipping the translations"
unzip translations.zip >/dev/null
echo "Installing translations from Crowdin"
mv -f ${TEMPDIR}/de/Localizable.strings    "$PROJDIR/de.lproj/Localizable.strings"
mv -f ${TEMPDIR}/es-ES/Localizable.strings "$PROJDIR/es.lproj/Localizable.strings"
mv -f ${TEMPDIR}/fr/Localizable.strings    "$PROJDIR/fr.lproj/Localizable.strings"
mv -f ${TEMPDIR}/it/Localizable.strings    "$PROJDIR/it.lproj/Localizable.strings"
mv -f ${TEMPDIR}/ja/Localizable.strings    "$PROJDIR/ja.lproj/Localizable.strings"
mv -f ${TEMPDIR}/pl/Localizable.strings    "$PROJDIR/pl.lproj/Localizable.strings"
mv -f ${TEMPDIR}/ru/Localizable.strings    "$PROJDIR/ru.lproj/Localizable.strings"
mv -f ${TEMPDIR}/zh-CN/Localizable.strings "$PROJDIR/zh-Hans.lproj/Localizable.strings"
mv -f ${TEMPDIR}/zh-TW/Localizable.strings "$PROJDIR/zh-Hant.lproj/Localizable.strings"
mv -f ${TEMPDIR}/en/Localizable.strings    "$PROJDIR/en.lproj/Localizable.strings"
mv -f ${TEMPDIR}/pt-BR/Localizable.strings "$PROJDIR/pt-BR.lproj/Localizable.strings"
cd
rm -rf ${TEMPDIR}

Upload script:

#!/bin/bash
STRINGFILE="en.lproj/Localizable.strings"
APIKEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

echo "Uploading file update to Crowdin"
curl -F "files[/Localizable.strings]=@$STRINGFILE" "https://api.crowdin.net/api/project/PROJECT-NAME/update-file?key=$APIKEY"

Thanks to the scripts sync with Crowdin is immediate. In the current development flow we download new translations just before adding new translatable strings and uploading them back. We also always download the most up-to-date translations in our release scripts.

Those tools are especially helpful if you have a lot of Apps and every App has the same folder layout. At Wikia we share a Crowdin project for all of our Community Apps and the scripts work on every one of those apps. Every App always has the most up-to-date translation and it's transparent to us.