twitter/twitter-cldr-rb — pull request #92 by camertron (2013-01-08 01:09:46+00:00)
Title: Adding a global locale setter

Whereas before you had to rely on a third-party library like `I18n` or `FastGettext`, the global locale setter allows users to easily set `TwitterCldr.locale` to affect which locale is used globally:

```ruby
# January 7, 2013 at 4:57:04 p.m. -08:00
DateTime.now.localize.to_long_s

TwitterCldr.locale = :es

# 7 de enero de 2013 16:53:55 -08:00
DateTime.now.localize.to_long_s
```

You can use the `TwitterCldr.with_locale` method to change the locale only within the scope of a block:

```ruby
# January 7, 2013 at 4:57:04 p.m. -08:00
DateTime.now.localize.to_long_s

TwitterCldr.with_locale(:es) do
# 7 de enero de 2013 16:53:55 -08:00
DateTime.now.localize.to_long_s
end

# January 7, 2013 at 4:57:04 p.m. -08:00
DateTime.now.localize.to_long_s
```

Finally, you can now add customized locale fallbacks to control which locale is used. The most recently added fallback is applied first:

```ruby
TwitterCldr.register_locale_fallback(
lambda { nil } # fallback always fails / returns nil
)

TwitterCldr.locale # :en

TwitterCldr.register_locale_fallback(
lambda { if 1 + 1 == 2 then :ru else :pt end }
)

TwitterCldr.locale # :ru
```