diff options
author | David Cabo <david@calibea.com> | 2011-09-20 02:11:53 +0200 |
---|---|---|
committer | David Cabo <david@calibea.com> | 2011-09-20 02:11:53 +0200 |
commit | 992a0b8acc4556fa1687bdf7bc66d63a51d410b3 (patch) | |
tree | d5760dbdf3668708c699387fbedece23d41617a6 /app/controllers/application_controller.rb | |
parent | 6f7d9187d6d851e4e26c7f0c494d87d56c664834 (diff) |
Ugly hack to fix _() in production when themes define controllers (kind of)
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r-- | app/controllers/application_controller.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f34f6e388..239145944 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -14,7 +14,7 @@ class ApplicationController < ActionController::Base # Standard headers, footers and navigation for whole site layout "default" include FastGettext::Translation # make functions like _, n_, N_ etc available) - + # Note: a filter stops the chain if it redirects or renders something before_filter :authentication_check before_filter :set_gettext_locale @@ -488,6 +488,20 @@ class ApplicationController < ActionController::Base # Site-wide access to configuration settings include ConfigHelper + + # XXX: patch to improve usability of gettext's _(), which by default accepts only + # one parameter. This is normally done in a monkey patch file named 'i18n_fixes.rb'. + # For some reason - and only when running in production -, after adding a new controller + # in a theme, the monkey patch in 'i18n_fixes.rb' doesn't seem to take effect. + # But it works just fine in the views. + # It's probably related to the loading order of classes, but including the + # monkey patch before or after the theme makes no difference. Even more bizarrely, + # require'ing or load'ing the patch file here doesn't work (!?), I need to redefine + # the method explicitely. I'm going crazy... + def _(key, options = {}) + translation = FastGettext._(key) || key + gettext_interpolate(translation, options) + end end |