Created
October 5, 2011 17:11
-
-
Save rubytastic/1265040 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 ApplicationController < ActionController::Base | |
protect_from_forgery | |
before_filter :check_beta | |
before_filter :set_locale | |
def check_beta | |
if APP_CONFIG['beta'] = true | |
render :layout => "beta" | |
end | |
end | |
def set_locale | |
I18n.locale = extract_locale_from_tld || I18n.default_locale | |
end | |
# Get locale from top-level domain or return nil if such locale is not available | |
# You have to put something like: | |
# 127.0.0.1 application.com | |
# 127.0.0.1 application.it | |
# 127.0.0.1 application.pl | |
# in your /etc/hosts file to try this out locally | |
def extract_locale_from_tld | |
parsed_locale = request.host.split('.').last | |
I18n.available_locales.include?(parsed_locale.to_sym) ? parsed_locale : nil | |
end | |
layout "application" | |
def sub_layout | |
"application" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment