README

Path: README
Last Update: Thu Sep 07 12:03:56 Romance Daylight Time 2006

= Localization Simplified (LocalizationSimplified)

Localization Simplified plugin for Ruby on Rails. Really simple localization. Written by Jesper Rønn-Jensen ( justaddwater.dk/ )

The goal is to have a dead simple plugin for one-language (non-english) Rails applications. Many of the existing localization / internationalization plugins are too big for this and hard to get started with. Just dump this plugin in /vendor/plugins/, set your language and off you go.

Unlike the more advanced plugins, you don’t have to translate anything in your view files. Just use the standard Rails commands you’re used to.

The simple approach also makes limits. Make sure you understand them to decide if this plugin is right for you.

I use this plugin when creating new projects. Then later in the development process I can decide to change to a more advanced localization plugin (if necessary)

What it does

This plugin modifies the following most used helpers for Rails

  • Sets UTF-8 content-type HTTP header
  • Sets UTF-8 connection to database
  • Localized monthnames on date_select etc. (changing the order of Y-M-D, where Rails allows)
  • Localized ActiveRecord errors (and error headings)
  • Localized distance_of_time_in_words
  • Localized to_currency (but not changing the order of unit/currency)
  • Simple pluralization also available in the lang-file (but currently only used for pluralizing "error"=>"errors" in local language)
  • Uses standard Rails methods. In this way, there is no tedious rewrite of localization functions in your view files

Limitations

  • More advanced features are not likely to be available here.
  • No translation of models or the like.
  • If you want support for multiple languages, use another L10N/I18n plugin, like GLoc or Globalize
  • No support for re-ordering datetime_select fields or currency indicators. But date_select IS re-ordered. Currently, Rails lacks support of :order on these, but it can be done fairly easy and is already implemented in other frameworks.

The reason why I have not reordered the datetime_select fields or currency is that it will introduce an unnecessary dependency here (because functions have to be recoded).

Supported languages

Currently supported languages:

  • English (for running test cases and comparing to normal texts)
  • German
  • Spanish
  • French
  • Dutch
  • Danish
  • Swedish
  • Finnish
  • Canadian French
  • Swedish Chef, and Pirate talk (just for the fun of it)
  • any other language you want. Just dump your translation in the /lib folder

Download code

Usage:

in init.rb, set your language. That’s it. Now your db connection is running UTF-8 and standard Rails output is localized.

If your view files contains text, you probably also want to save your files as UTF-8.

Installation:

1) Just copy this plugin into your /vendor/lib folder 2) Choose your lang-file in init.rb (default is Danish because I am Danish)

A special note of WARNING: All files here are saved using UTF-8 encoding. It’s not required for working, I guess, but other encodings could bring you in trouble.

TODO

  • Rake task that modifies all view-files and converts them to UTF-8
  • Also a task that modifies all generators to use UTF-8
  • Other helpers that need modification? (your suggestions and contributions are welcome)
  • Add more test cases to verify it works properly
  • Modify to_boolean_select_tag with localized true/false?? (normally, I would prefer to use a checkbox for this and NOT a select tag)
  • Verify that the lang-files supplied are relevant

DONE

  • Added comments in all lang-files, thanks Jarkko Laine for the idea (2006-09-07)
  • Bugfix: Replaced hardcoded string in distance_of_time_in_words when :include_seconds was false (2006-08-30)
  • Added Canadian French translation (thanks Daniel) (2006-08-25)
  • Added comments in lang-file for documentation of how to localize (2006-08-25)
  • Added French translation (thanks Fred Cavazza) (2006-08-25)
  • Added Finnish translation (thanks Jarkko Laine) (2006-08-25)
  • Bugfix re-added HTTP header for UTF-8. Necessary for some lang-files (2004-08-24)
  • Renamed test files to make rake test command work (2006-08-23)
  • Localized time "Wed Aug 23 12:38:22 Romance Daylight Time 2006" =>
                   "onsdag d. 23 august 2006 12:38:22" (Danish)
    
  • Reordering of date_select fields (2006-08-23)
  • Test that plugin works with the Rails version it is installed next to (2006-08-20)
  • Added Dutch translation lang_nl.rb, thanks to Jeroen Houben (2006-08-20)
  • Added Pirate language lang_pirate.rb, thanks to Tobias Michaelsen (2006-08-18)
  • Added Date and Time#to_formatted_s with locale specific strings (2006-08-18)
  • Added MIT-license, copied from Ruby on Rails (2006-08-13)
  • Added tests for plugin (2006-08-13)
  • Localized version of Array.to_sentence (2006-08-09)
  • Added test scaffold (2006-08-09)
  • Added swedish language, thanks to Olle Jonsson (2006-08-09)
  • Localized version of to_currency helper (2006-08-07)

Your help

Feel free to use, translate, modify and improve this code. Do send me translations, improvements, etc. I cannot promise to use it, but chances are that I will unless it bloats the code here completely or makes code harder to maintain.

I added FIXME notes in the code to indicate where I also could use help.

Credits

This plugin uses a few bits and pieces from other Rails plugins GLoc (rubyforge.org/projects/gloc/) and swe_rails (opensource.ki.se/swe_rails.html)

Created 2006-07-28 by Jesper Rønn-Jensen justaddwater.dk/

[Validate]