aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/i18n.md
diff options
context:
space:
mode:
authorPaul Nikitochkin <paul.nikitochkin@gmail.com>2013-09-06 21:41:04 +0300
committerPaul Nikitochkin <paul.nikitochkin@gmail.com>2013-09-06 21:42:29 +0300
commit2c8bc2cdcdb7b144b7a583d24922fd8064bcff3d (patch)
tree279e76293ba90dcc46e7716ecf78fbc1df221e79 /guides/source/i18n.md
parent97a19c6b4b71d1e12d62d880ec8c8eed357b3d3c (diff)
downloadrails-2c8bc2cdcdb7b144b7a583d24922fd8064bcff3d.tar.gz
rails-2c8bc2cdcdb7b144b7a583d24922fd8064bcff3d.tar.bz2
rails-2c8bc2cdcdb7b144b7a583d24922fd8064bcff3d.zip
Use Ruby on Rails Coding Conventions for code examples in the guides
* Indent after private/protected * Ruby >= 1.9 syntax for hashes * Prefer method { do_stuff } instead of method{do_stuff} for single-line blocks. [ci skip]
Diffstat (limited to 'guides/source/i18n.md')
-rw-r--r--guides/source/i18n.md9
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