Integrate Phrase Into Your IOS Translation Workflow

Phrase
Software Localization Tutorials
2 min readMay 23, 2016
Today we looked out for a nice tool to improve our translation workflow for an iOS app.

In the past we made good experiences with Phrase for our Symfony2 app (see this post). So we decided to try it for iOS development. As it turned out it works like a charm with iOS Localizable Strings as well.

Our Workflow

  1. Engineers add new translations keys to the code
NSLocalizedString(@"ACMELoginButton", @"Login button title")
  1. We run a script that uses to generate the strings from the source code
  2. We push the new strings as Base locale to Phrase
  3. The translators get notified about the new strings and can translate them in the Phrase backend
  4. We pull the translated strings from Phrase and all new translation keys are translated

Step-By-Step Tutorial

  1. Sign up at Phrase, create your project and remember your auth token
  2. Install the phrase gem
gem install phrase

Go to your project dir and init phrase

<span style="font-size: 12.8px; line-height: 1.5;">phrase init --secret=YOUR_AUTH_CODE</span>

3. Push your existing Localizable.strings files to Phrase to automatically create the languages

phrase push Resources/Localizations/Base.lproj/Localizable.strings
phrase push Resources/Localizations/en.lproj/Localizable.strings
phrase push Resources/Localizations/de.lproj/Localizable.strings

4. Create a small script (e.g. Resources/Scripts/UpdateTranslations.sh) that generates strings for your new translation keys from source, pushes them to Phrase and pulls back the translated strings

#!/bin/sh
localizationsPath="Resources/Localizations/"
find ./ -name "*.m" -print0 | xargs -0 genstrings -o ${localizationsPath}Base.lproj

phrase push ${localizationsPath}Base.lproj/Localizable.strings

phrase pull --target=${localizationsPath} --format=strings

5. Set the script to be executable

chmod +x Resources/Scripts/UpdateTranslations.sh

6. Whenever you want to update your translation keys, run the script

./Resources/Scripts/UpdateTranslations.sh

Done.

Originally published on The Phrase Blog.

--

--