Skip to content

Instantly share code, notes, and snippets.

@felix
Created January 21, 2009 17:19
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 felix/50045 to your computer and use it in GitHub Desktop.
Save felix/50045 to your computer and use it in GitHub Desktop.
class Application < Merb::Controller
before :set_lang
def _template_location(action, type = nil, controller = controller_name)
lang = params[:language]
action = "#{action}.#{lang}" unless lang == 'en'
_conditionally_append_extension(controller ? "#{controller}/#{action}" : "#{action}", type)
end
protected
def set_lang
lang = params[:language] || request.subdomains(Merb::Config[:domain].split('.').count-1).last
# this should ensure we don't get anything strange
params[:language] = %w(en th).include?(lang) ? lang : 'en'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment