public
Description: Localize the frontend of single language Rails apps
Clone URL: git://github.com/leethal/localized-frontend.git
Search Repo:
name age message
folder .gitignore Sun Jun 29 16:27:25 -0700 2008 RDoc fixes [leethal]
folder MIT-LICENSE Fri May 16 15:24:11 -0700 2008 Added my name to the MIT-LICENSE [leethal]
folder README Tue Jul 01 05:20:21 -0700 2008 Updated README, doing what we need to do in ini... [leethal]
folder Rakefile Fri May 16 11:26:46 -0700 2008 Initial commit [leethal]
folder TODO Mon Jul 07 01:03:15 -0700 2008 Added a TODO [leethal]
folder init.rb Tue Jul 01 05:20:21 -0700 2008 Updated README, doing what we need to do in ini... [leethal]
folder lib/ Tue Jul 01 05:49:19 -0700 2008 Allowing @object to be nil (say, form_for(:some... [leethal]
folder test/ Tue Jul 01 05:49:19 -0700 2008 Allowing @object to be nil (say, form_for(:some... [leethal]
README
= Localized Frontend

http://gitorious.org/projects/localized-frontend/
http://github.com/leethal/localized-frontend/

Localizing the front-end of single language Rails apps.

The localizations are stored in YAML files. Create a spanish.yml file, call 
LocalizedFrontend.in :spanish somewhere in your app (probably in environment.rb or an
initializer), and rejoice!

It localizes inflectors (pluralize, singularize etc), Active Record error messages, month
and day names, form labels (<%= f.label :foo %>) and Array#to_sentence.

== To contributors

Feel free to submit your own translations and localizations! You can mail me patches on
augustlilleaas@gmail.com, or you can fork the Git repository on 
http://github.com/leethal/localized-frontend/ and send a pull request. Or write it down on
paper and mail it to me. Your call!

Keep in mind that the YAML file is whiny - certain keys and values are required in
order to avoid errors being raised. At the moment, the tests are hardcoded in Norwegian.
That should probably change, so that one can set the language in an environment
variable and run the tests in whatever language one might prefer.

Also, the code is fairly hard to grok, as it's mostly monkey patches. Feel free to improve
the readability of the code!

== What it does

Here's a short list of features (examples are in norwegian)

Localizing %b, %B, %a and %A in Time#strftime, Date#strftime and DateTime#strftime

* Time.now.strftime('%b') => okt
* Time.now.strftime('%b') => oktober
* Time.now.strftime('%a') => søn
* Time.now.strftime('%A') => søndag
    
Localized inflections. "bil".pluralize => "biler"

Localizing attribute names in ActiveRecord.

 class Question < ActiveRecord::Base
   localized_fields :question => "Spørsmål", :answer => "Svar"
 end
    
== TODO

* Make tests runnable in any language. In other words, don't let tests be hardcoded in Norwegian.


Copyright (c) 2008 August Lilleaas, released under the MIT license