DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Gettext (1.93.0) Monkeypatch

11.01.2008
| 2206 views |
  • submit to reddit
        // there's a problem with this method in gettetxt 1.93.0 that will always append "_en" to fragment cache no matter what is your locale (in my case with memcache, but the problem might probably be in filestore mode too).

require 'gettext/rails'

module GetText
  module Rails
    
    def normalized_locale(locale = nil)
      locale ||= GetText.locale
      ([locale.to_general, locale.to_s, locale.language, Locale.default.language, "en"].uniq & 
       available_locales)[0]
    end
    
  end
end