Play Framework is a High Velocity Web Framework for Java and Scala.
Ensure localization files are correctly formatted and Play Properties use UTF-8 encoding.
To prepare the application, follow these steps:
-
Add required languages to be accepted into the
application.conf
with with priority being set by descending locale order (en being the most important, de second, etc.):application.langs="en,de,fr"
Add messages.en, messages.de and messages.fr files to the
conf/
folder.
Example:
# My Software Project (description) project.name=Some Name title1=AwesomeApp # You can never have enough titles! more_titles=Another Title
To use Rails for Ruby i18n, follow these steps:
Download the latest client and follow the setup instructions.
-
To initialize the project configuration, follow the instructions:
$ phrase init
Follow the steps to configure sources and targets for the project. Select
.yml
as the locale file format. -
If existing localization files are stored in the default location at
./config/locales
, upload data with the push command:$ phrase push
All existing localization files found in the source path are uploaded to the project. Existing translations are now in Phrase and new languages or keys can be added.
-
Download completed translations back into the project with the pull command:
$ phrase pull
Optional:
-
Add a custom locale download directory to the i18n load path
If downloading localization files to a folder other than
./config/locales
, configure the i18n load path of the application so that new localization files are accessible.Open the
application.rb
ordevelopment/staging/production.rb
and add the configuration (assuming localization files are downloaded to./custom/locales
.):config.i18n.load_path += Dir[Rails.root.join('custom', 'locales', '**', '*.yml').to_s]group :staging, :development do gem 'phraseapp-ruby' end
After restarting the application, newly downloaded files are visible.
-
Install the phraseapp-ruby gem
If writing a custom workflow using the API, use the phraseapp-ruby gem.
Add the phraseapp-ruby gem to your application by adding it to the Gemfile:
group :staging, :development do gem 'phraseapp-ruby' end
Install it using the bundle command:
$ bundle install
RubyMotion is a toolchain for iOS, OS X and Android development that creates iPhone, iPad, Mac and Android apps in Ruby.
The phraseapp-rubymotion gem connects the RubyMotion application to benefit from internationalization workflows (iOS) projects.
To install the gem, follow these steps:
Add the Access Token and Project ID to the application 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
Project ID of a project is found in project settings.
Using the phraseapp-rubymotion gem provides the automatic sending of new translations via API without having to write them into a Localizable.strings file or uploading them.
Localizing strings
Localize all strings by extending them with their localized counterparts. Call the #__ method
on each string that is implemented by phraseapp-rubymotion:
"Hello World"
becomes:
"Hello World".__
or when using a fallback translation:
"Hello World".__("My fallback translation")
Generic key names can also be used:
"HOME_WELCOME_BUTTON_LABEL".__
API communication
Build and run the app (in the simulator). When in development mode, phraseapp-rubymotion automatically sends all localized strings and are seen as newly created keys. If localization files are correctly placed, translation are also transmitted.
When translations are completed, bundle them with the app. All translations can be fetched from the API and stored in the RubyMotion project by using the command line client.
To fetch translations, follow these steps:
Install the command line client (CLI).
-
Configure the CLI for the project:
$ phrase init
Complete the required steps to configure sources and targets for the project. Select strings as the locale file format.
-
Download local files.
Once the translation is complete, download the data back into the project with the pull command:
$ phrase pull
To upload all existing local files to a project:
$ phrase push