Created
January 21, 2009 17:19
-
-
Save felix/50045 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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