Localize RubyMotion Projects with Phrase
This guide describes how to set up your first project as well how to setup and configure the Phrase RubyMotion gem.
- Add Project in Phrase
- Setup PhraseApp Rubymotion gem
- Browse RubyMotion app to upload new keys and translations
RubyMotion is a toolchain for iOS, OS X and Android development that lets you create iPhone, iPad, Mac and Android apps in Ruby.
Our phraseapp-rubymotion gem lets you connect your RubyMotion application to Phrase and benefit from the best internationalization workflow for your (iOS) projects.
Installing the gem
phraseapp-rubymotion gem to your project using bundler:
$ gem install phraseapp-rubymotion
and require it in your
Initialize your project
Let’s tell Phrase a little bit about the app we’re building. Add the Access Token and Project ID to your application’s Rakefile:
Motion::Project::App.setup do |app|
app.name = "Test Application"
app.phraseapp.enabled = true
app.phraseapp.access_token = "YOUR_ACCESS_TOKEN"
app.phraseapp.project_id = "YOUR_PROJECT_ID"
This will automatically create the
phraseapp_config.rb configuration file in your app folder during every build process.
Please make sure that you only enable Phrase in development mode and never in release mode!
Using Phrase with phraseapp-rubymotion lets you send new translations to the Phrase API automatically without having to write them into your Localizable.strings file or uploading them - just by browsing the app.
The first step towards a localized app is to localize all strings by extending them with their localized counterparts. This can be done by simply calling the
#__ method on each string that is implemented by phraseapp-rubymotion:
or (when using a fallback translation):
"Hello World".__("My fallback translation")
Of course you can use more generic names for your keys as well, such as:
Simply build and run your app (in the simulator). When in development mode, phraseapp-rubymotion will send all of your localized strings to Phrase automatically! Log into your Phrase account and check your newly created keys. If you already have your localization files in the correct place, it will transmit translations as well.
When all of your translations are completed in Phrase, it’s time to bundle them with your app. You can fetch all translations from the API and store them in our RubyMotion project by using our command line client.
- Install the Phrase command line client
2. Configure the command line tool for your project
To initialize the project configuration, just follow the instructions to initialize the Phrase command line tool:
$ phraseapp init
This will guide you through the necessary steps to configure your sources and targets for your project. Make sure you select
strings as your locale file format.
3. Download locale files
Once you have finished working on your translation in Translation Center you might want to download the data back into your project. This can be done by executing the
$ phraseapp pull
Optional: Upload locale files
Besides adding translations magically through browsing the app, you can of course also upload your existing locale files to Phrase. Just execute the
$ phraseapp push
All existing locale files will be uploaded to your Phrase project. Log into Translation Center to see your existing translations and add new languages or keys.