Path: | README |
Last Update: | Wed Oct 10 22:09:10 +0200 2007 |
This plugin supports a simple localization for Ruby on Rails and was born in the first half of 2006 by searching a simple way to localize model and attribute names of ActiveRecord models. Time after time more and more features became necessary and the plugin grew. It supports multiple language localization for Ruby on Rails based on language files, localizes the Date and Time classes, many helpers, some methods of ActiveSupport, the ActiveRecord error messages and provides two ways to localize models and their attributes. You can also use the language file to easily localize your own application. You‘ll find an overview just below.
If you have some questions, want to report a bug or just want to talk about the plugin feel free to visit us at simple-localization.arkanis.de/.
To make the plugin more felxible and extendable most of the functionality is split into small "features". These "features" are source files located in the lib/features directory of the plugin and each one localizes a small part of Ruby on Rails. When initializing the plugin you can choose the featurs you want to use. This avoids conflicts in case you have already localized some parts of your application by other means.
To easily support new languages all language specific strings are extracted into language files. These language files can be found in the languages directory of the plugin (or app/languages for your own language files) and are written in the YAML format. They also contain meta data about the author of the language file and can be extended with Ruby code (eg. configuring the Rails Inflector). More detailed information or instructions for creating a new language file can be found in the plugin documenation at simple-localization.arkanis.de/docs/index.
You can install the newest version of the plugin (for Rails 1.1 and 1.2) directly from the SubVersion repository:
./script/plugin install http://svn.arkanis-development.de/projects/rails_plugins/current/simple_localization
The next and already last thing is to call the simple_localization method at the end of your environment.rb file:
simple_localization :language => :de
With this you‘re done. The :language parameter lets you define the language you want to use. Just specify the name of the language file without the .yml extension as a symbol or string. To load multiple languages just specify them in an array:
simple_localization :languages => [:de, :en, :nl, :fr]
The :languages and :language options are doing exactly the same. Use whatever sounds best for you. This one call of the simple_localization method gives you quite more control over the plugin but this is described in the next chapter.
Things get a bit complicated when using Rails model observers. Features which are accessed when the models are loaded are preloaded by the plugin. To disable a preloaded feature set the ArkanisDevelopment::SimpleLocalization::SUPPRESS_FEATURES constant to the name (symbol) of the feature. This have to be done before the Rails::Initializer.run call in the environment.rb. This is necessary because an observer (and with it the corresponding model) is loaded before the plugin is initialized in the environment.rb. Thanks to MK for reporting this problem.
Visit the plugin documentation at simple-localization.arkanis.de/docs/index. There is a lot of cool stuff waiting for you there (e.g. multipart language files, detailed feature descriptions, ect.). You‘ll also find a forum there so if you have a question don‘t hesitate to ask it.
These guys helped to make this plugin what it is today:
Copyright (c) 2007 Stephan Soller <stephan.soller@helionweb.de> and contributors
The MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.