Rails i18n Fallback

If your application is already using the standard i18n framework, you can use Tml as i18n backend in your config/initializers/tml.rb file.

I18n.backend = I18n::Backend::Tml.new  

Now the t() function will automatically fallback onto tr() function. If you have the following in your base language config/locales/en.yml file:

  hello: "Hello world"
      key: "This is a nested key"

You can call:

<%= t(:hello) %>  
<%= t("my.nested.key") %>  

And the i18n will use Translation Exchange as the backend for your translations. You can continue using Tml's extensions together with the standard t method:

<%= t(:hello) %>  
<%= t("my.nested.key") %>  
# or
<%= tr("Hello World") %>  
<%= tr("This is a nested key") %>  

The above calls are equivalent.