Skip to content

Instantly share code, notes, and snippets.

@mamarx
Last active August 29, 2015 14:05
Show Gist options
  • Save mamarx/24fe8d010b450e313c8b to your computer and use it in GitHub Desktop.
Save mamarx/24fe8d010b450e313c8b to your computer and use it in GitHub Desktop.
Integrate PhraseApp 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 PhraseApp for our Symfony2 app (see this post). So we decided to try it for iOS developement. As it turned out it works like a charme with iOS Localizable Strings as well.

Our workflow looks like this:

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

Step-by-step tutorial

  1. Sign up at PhraseApp, create your Project and remember your auth token Phrase Project Setup

  2. Install the PhraseApp gem

    gem install phrase
  3. Got to your project dir and init PhraseApp

    phrase init --secret=YOUR_AUTH_CODE
  4. Push your existing "Localizable.string" files to phrase to automatically create the languages (you can't create "Base" locale over their backend)

    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 PhraseApp 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
    
  1. Set the script to be executable

    chmod +x Resources/Scripts/UpdateTranslations.sh
  2. Whenever you want to update your translation keys, run the script

    ./Resources/Scripts/UpdateTranslations.sh
  3. Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment