Translating

Website Translation (Strings)

Content is machine translated from English by Phrase Language AI.

Play Framework for Strings

Play Framework is a High Velocity Web Framework for Java and Scala.

Prepare the Application

Ensure localization files are correctly formatted and Play Properties use UTF-8 encoding.

To prepare the application, follow these steps:

  1. 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"
  2. 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

Rails for Ruby i18n in Strings

To use Rails for Ruby i18n, follow these steps:

  1. Download the latest client and follow the setup instructions.

  2. 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.

  3. 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.

  4. 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 or development/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

Ruby Motion in Strings

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.

Install the Gem

To install the gem, follow these steps:

  1. Add the phraseapp-rubymotion gem to your project using bundler:

    gem 'phraseapp-rubymotion'

    or manually:

    $ gem install phraseapp-rubymotion
  2. Require the gem in the Rakefile.

Initialize the Project

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.

Usage

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:

  1. Install the command line client (CLI).

  2. 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.

  3. 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
Was this article helpful?

Sorry about that! In what way was it not helpful?

The article didn’t address my problem.
I couldn’t understand the article.
The feature doesn’t do what I need.
Other reason.

Note that feedback is provided anonymously so we aren't able to reply to questions.
If you'd like to ask a question, submit a request to our Support team.
Thank you for your feedback.