Skip to content

Instantly share code, notes, and snippets.

@tomlea
Created January 7, 2009 12:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomlea/44259 to your computer and use it in GitHub Desktop.
Save tomlea/44259 to your computer and use it in GitHub Desktop.
# t(:foo) now looks for admin.blog_controller.foo, then if not found it then goes for admin.foo, then finally just foo.
def ApplicationController.has_controler_specific_translation_helper_fu
def t(key, options = {})
controller_name = self.controller_name + "_controller"
defaults = [[:admin, controller_name, key], [:admin, key], [key]].map{|a| a.join(".").to_sym}
key, defaults = *defaults
options[:default] = defaults
I18n.t(key, options)
end
helper_method :t
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment