-
Notifications
You must be signed in to change notification settings - Fork 0
I18n
Ez-on-rails provides multilanguage support out of the box. Every generator you call that creates content takes care of creating files to provide translations.
The default locales are german (de) and english (en). The default locale is set to german, but you can change it in the config/initializers/i18n.rb file that was generated during the ezapp generator execution.
To add more languages you must do the following:
- Add the new locale in the locale scopes of the routes in the config/routes.rb file. Note that you must add this locale after each call of ezscaff
- Add the locale to the locale switch the _views/shared/locale_switch partial. You can eject the partial by calling ezviews. You can delete other ejected files you do not need.
- Provide the language files in the config/locales directory
The following section describes a helper that handles special cases of translations. This helper can be included in your controllers.
Ez-on-rails provides the EzOnRails::EzI18nHelper to handle translations that rails may not provide. The following subsections describe the methods the helper provides.
Translates the value of an enum. The enum values translations must be provided like this:
de:
activerecord:
enums:
article:
status:
draft: Entwurf
published: Veröffentlicht
archived: Archiviert
This enables you to include the methods eg. in controllers and use the method like this:
human_enum_name(Article, 'status', @resource.status)