Project

General

Profile

Actions

Internationalization » History » Revision 1

Revision 1/2 | Next »
Ward Vandewege, 01/28/2014 04:04 PM


Internationalization

Tapestry uses the standard Rails Internationalization (I18N) API.

Not every page has been converted yet to use the I18N API. Patches are welcome. Translations to new languages are also welcome!

Setting the default locale for an installation

In the config/config.yml file, make sure to add the locale lines to the default section (or the section for your environment). For example, to add Dutch and make it the default locale:

  available_locales: [:en, :de, :nl]
  default_locale: :nl

Viewing a page in a different locale

You can pass the 'locale' URL query parameter to force a specific locale. Please note that the locale must be listed in the available_locales configuration variable.

Adding/editing translations

The locale files live under

  config/locales/defaults
  config/locales/views

View-specific locales should be defined under views. Please follow the established naming pattern for files and directories.

Using translations in a view

Where possible, we use Lazy loading (see section 4.1.4).

For example, in

  app/views/users/index.html.erb

we write

  <h2><%= t('.participant_profiles') %></h2>

which maps to a yml file

config/locales/views/users/en.yml

with this structure

en:
  users:
    index:
      participant_profiles: "Participant Profiles" 

We could also write the lookup explicitly, like so:

  <h2><%= t('users.index.participant_profiles') %></h2

Updated by Ward Vandewege about 10 years ago · 1 revisions