diff options
author | Alexey Vakhov <vakhov@gmail.com> | 2011-09-15 10:41:55 +0400 |
---|---|---|
committer | Alexey Vakhov <vakhov@gmail.com> | 2011-09-15 10:41:55 +0400 |
commit | 7531aa76417a5db337287c31c1b97ad53615c8e6 (patch) | |
tree | c5771d74cbd0177cd2471d30f6f07cf45e52e241 /railties/guides/source/i18n.textile | |
parent | 49476eee781b8a8b936b425b20ee40d036053128 (diff) | |
download | rails-7531aa76417a5db337287c31c1b97ad53615c8e6.tar.gz rails-7531aa76417a5db337287c31c1b97ad53615c8e6.tar.bz2 rails-7531aa76417a5db337287c31c1b97ad53615c8e6.zip |
update guides, use html safe translations in i18n
Diffstat (limited to 'railties/guides/source/i18n.textile')
-rw-r--r-- | railties/guides/source/i18n.textile | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/railties/guides/source/i18n.textile b/railties/guides/source/i18n.textile index 4b6b08bcec..76cd14d479 100644 --- a/railties/guides/source/i18n.textile +++ b/railties/guides/source/i18n.textile @@ -448,6 +448,7 @@ Covered are features like these: * looking up translations * interpolating data into translations * pluralizing translations +* using safe HTML translations * localizing dates, numbers, currency, etc. h4. Looking up Translations @@ -599,6 +600,27 @@ The +I18n.locale+ defaults to +I18n.default_locale+ which defaults to :+en+. The I18n.default_locale = :de </ruby> +h4. Using Safe HTML Translations + +Keys with a '_html' suffix and keys named 'html' are marked as HTML safe. Use them in views without escaping. + +<ruby> +# config/locales/en.yml +en: + welcome: <b>welcome!</b> + hello_html: <b>hello!</b> + title: + html: <b>title!</b> + +# app/views/home/index.html.erb +<div><%= t('welcome') %></div> +<div><%= raw t('welcome') %></div> +<div><%= t('hello_html') %></div> +<div><%= t('title.html') %></div> +</ruby> + +!images/i18n/demo_html_safe.png(i18n demo html safe)! + h3. How to Store your Custom Translations The Simple backend shipped with Active Support allows you to store translations in both plain Ruby and YAML format. [2] |