Path: | lib/features/localized_models_by_lang_file.rb |
Last Update: | Wed Sep 12 14:46:23 +0200 2007 |
This feature provides a way to localize ActiveRecord models based on translated model and attribute names in the language file. Where the localized_models feature depends on translated names written in the source code of the models this feature reads all necessary strings from the loaded language file.
This feature is the right choice if your application should support multiple languages. If your application is strictly developed for just one language localized_models is the better choice.
To localize a model with this feature just add the necessary section to the languge file. How to do this is descriped in the next chapter.
The localized model and attribute names for this feature are located in the models section of the language file. The following example localizes the Computer model and it‘s attributes name, description, ip_address and user.
models: computer: name: Der Computer attributes: name: Der Name description: Die Beschreibung ip_address: Die IP-Adresse user: Der Besitzer
This feature will convert the name of the model class (Compuer) using String#underscore (results in computer) and will look in the corresponding subsection of the models section. Each model section in turn contains the name of the model ("Der Computer") and a map translating the model attributes.