public
Description: JavaScript Rails internationalization
Homepage:
Clone URL: git://github.com/toretore/babilu.git
babilu /
name age message
file .gitignore Fri Dec 05 02:59:36 -0800 2008 Ignore .swp files [toretore]
file MIT-LICENSE Thu Dec 04 13:15:56 -0800 2008 Initial commity [toretore]
file README Wed Feb 04 12:19:52 -0800 2009 Syntax fail [toretore]
file Rakefile Wed Feb 04 08:18:12 -0800 2009 Rename everything from I18nJs to Babilu [toretore]
file init.rb Wed Apr 22 14:01:51 -0700 2009 Reload I18n before generating the locales.js fi... [mvanholstyn]
file install.rb Thu Dec 04 13:15:56 -0800 2008 Initial commity [toretore]
directory lib/ Wed Feb 04 12:15:01 -0800 2009 Use same scope on defaultValue lookup as the in... [toretore]
directory tasks/ Thu Dec 04 13:15:56 -0800 2008 Initial commity [toretore]
directory test/ Wed Feb 04 12:15:01 -0800 2009 Use same scope on defaultValue lookup as the in... [toretore]
file uninstall.rb Thu Dec 04 13:15:56 -0800 2008 Initial commity [toretore]
README
Babilu
=======

Babilu converts all your translations into JavaScript so you can use them on
the client side. It mimicks the Ruby/Rails I18n API and works in pretty much the
same way:

//JavaScript
I18n.defaultLocale // "en"
I18n.locale // Whatever the locale has been set to on the server

I18n.t('hello') // "Hello World"
I18n.t('messages.invalid', {scope:['activerecord', 'errors']})  // "is invalid"
I18n.t('activerecord.errors.template.header', {count:4, model:'pony'}) // "4 errors prohibited this pony from being 
saved"

I18n.translations.en.ponies = {one: 'I have a pony', other: 'I have {{count}} ponies'};
I18n.t('ponies', {count:5}) // "I have 5 ponies"

The only difference is that because JavaScript doesn't have symbols we can't
easily differentiate between keys and values in the "defaultValue" option. A workaround
is used in which strings starting with ":" are considered to be keys and are used for
looking up additional translations:

I18n.t('doesntexist', {defaultValue:'humbaba'}) // "humbaba"
I18n.t('doesntexist', {defaultValue:':hello'}) // "Hello world"
I18n.t('doesntexist', {defaultValue:[':alsodoesntexist', 'The Sasqutch: Fact or Fiction?']}) // "The Sasquatch: Fact or 
Fiction?"

This plugin depends on http://github.com/toretore/lucy


Copyright (c) 2008 Tore Darell, released under the MIT license