diff options
Diffstat (limited to 'guides/source/i18n.md')
-rw-r--r-- | guides/source/i18n.md | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/guides/source/i18n.md b/guides/source/i18n.md index ead9c6b94d..cbc2683a00 100644 --- a/guides/source/i18n.md +++ b/guides/source/i18n.md @@ -282,10 +282,11 @@ def set_locale I18n.locale = extract_locale_from_accept_language_header logger.debug "* Locale set to '#{I18n.locale}'" end + private -def extract_locale_from_accept_language_header - request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first -end + def extract_locale_from_accept_language_header + request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first + end ``` Of course, in a production environment you would need much more robust code, and could use a plugin such as Iain Hecker's [http_accept_language](https://github.com/iain/http_accept_language/tree/master) or even Rack middleware such as Ryan Tomayko's [locale](https://github.com/rack/rack-contrib/blob/master/lib/rack/contrib/locale.rb). @@ -742,7 +743,7 @@ en: other: Dudes ``` -Then `User.model_name.human(:count => 2)` will return "Dudes". With `:count => 1` or without params will return "Dude". +Then `User.model_name.human(count: 2)` will return "Dudes". With `count: 1` or without params will return "Dude". #### Error Message Scopes |