Created
January 19, 2011 10:27
-
-
Save hemalich/785973 to your computer and use it in GitHub Desktop.
Get locale code from request subdomain
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
| # Get locale code from request subdomain (like http://it.example.local:3000) | |
| # You have to put something like: | |
| # 127.0.0.1 gr.example.local | |
| # in your /etc/hosts file to try this out locally | |
| def extract_locale_from_subdomain | |
| parsed_locale = request.subdomains.first | |
| I18n.available_locales.include?(parsed_locale.to_sym) ? parsed_locale : nil | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment