While writing a section on localization for my book, I noticed that
there doesn’t seem to be a localization system that works out of the
box on Ruby 1.9.
The changes to get either Ruby-GetText or Gibberish to work were
I really liked the general idea behind Gibberish, since it has a nice
Ruby interface and is very easy to configure. But it was a Rails
plugin, and needed some small modifications to work standalone.
I also wasn’t wild about using String# to do translation tagging, as
it seemed it’d be just as easy to get by without modifying core. I
did some other cleanup under the hood and removed the dependency on
ActiveSupport, and put up Gibberish::Simple:
I’m curious if folks find this interesting / useful enough for an
official release and further maintenance? I would be fine with just
using it as a book example, but if others find it useful beyond that,
I can document it, polish it up a bit, and push a gem.
== More Details ==
This library keeps most of the functionality Gibberish offers. In
most cases, you just need to switch:
“My String”[:tag, *args]
to look like this:
T(“My String”, :tag, *args)
After including the Gibberish::Simple module. Also, you replace any
call on Gibberish with a call to Gibberish::Simple. Some minor
features were removed, but otherwise it’s mostly the same library.
If you’re curious of what it looks like in a code sample, I coded up a
tiny Sinatra app that implements the rock paper scissors game:
You will need Sinatra 0.9.1 (from Github) and Ruby 1.9.1 to run this
Please let me know what you think.