diff options
author | Xavier Noria <fxn@hashref.com> | 2011-04-19 23:03:28 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2011-04-19 23:03:28 +0200 |
commit | 356dacbafc8590244d9da7d4d601f7064e461bc7 (patch) | |
tree | 1a8a21f181715d16b5e937d0d12bbe8fba770bc9 /railties | |
parent | 2f549b8bbd733ad0563d977e83a9b2a2b6b8e07c (diff) | |
parent | 68eb84d73562478af347d9a9924fc10ca7869a82 (diff) | |
download | rails-356dacbafc8590244d9da7d4d601f7064e461bc7.tar.gz rails-356dacbafc8590244d9da7d4d601f7064e461bc7.tar.bz2 rails-356dacbafc8590244d9da7d4d601f7064e461bc7.zip |
Merge branch 'master' of git://github.com/lifo/docrails
Diffstat (limited to 'railties')
-rw-r--r-- | railties/guides/source/i18n.textile | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/railties/guides/source/i18n.textile b/railties/guides/source/i18n.textile index 5478a80567..608643b3d3 100644 --- a/railties/guides/source/i18n.textile +++ b/railties/guides/source/i18n.textile @@ -133,9 +133,9 @@ The _setting part_ is easy. You can set the locale in a +before_filter+ in the + <ruby> before_filter :set_locale + def set_locale - # if params[:locale] is nil then I18n.default_locale will be used - I18n.locale = params[:locale] + I18n.locale = params[:locale] || I18n.default_locale end </ruby> @@ -158,7 +158,7 @@ You can implement it like this in your +ApplicationController+: before_filter :set_locale def set_locale - I18n.locale = extract_locale_from_tld + 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 @@ -182,7 +182,7 @@ We can also set the locale from the _subdomain_ in a very similar way: # 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 + I18n.available_locales.include?(parsed_locale.to_sym) ? parsed_locale : nil end </ruby> |