Localize RubyMotion Projects with PhraseApp
This guide describes how to set up your first project as well how to setup and configure the PhraseApp RubyMotion gem.
- Add Project in PhraseApp
- 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 PhraseApp 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 PhraseApp 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.development do app.phraseapp do app.phraseapp.enabled = true app.phraseapp.access_token = "YOUR_ACCESS_TOKEN" app.phraseapp.project_id = "YOUR_PROJECT_ID" end end end
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 PhraseApp in development mode and never in release mode!
Using PhraseApp with phraseapp-rubymotion lets you send new translations to the PhraseApp 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 PhraseApp automatically! Log into your PhraseApp 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 PhraseApp, 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.
1. Install the PhraseApp command line client
2. Configure the command line tool for your project
To initialize the project configuration, just follow the instructions to initialize the PhraseApp 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 PhraseApp. Just execute the
$ phraseapp push
All existing locale files will be uploaded to your PhraseApp project. Log into Translation Center to see your existing translations and add new languages or keys.