Integrate Phrase Into Your IOS Translation Workflow

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")

    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

    phrase init --secret=YOUR_AUTH_CODE
  3. Push your existing Localizable.strings files to Phrase to automatically create the languages
  4. phrase push Resources/Localizations/Base.lproj/Localizable.strings
    phrase push Resources/Localizations/en.lproj/Localizable.strings
    phrase push Resources/Localizations/de.lproj/Localizable.strings
  5. 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
  6. Set the script to be executable
    chmod +x Resources/Scripts/UpdateTranslations.sh

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

  7. ./Resources/Scripts/UpdateTranslations.sh

    Done.

Rate this post
Comments