Browse files

update guides, use html safe translations in i18n

  • Loading branch information...
1 parent 4e37995 commit bcbc484b13d7fc0bed002a1cea5f5591053a8953 @avakhov avakhov committed with vijaydev Sep 15, 2011
BIN railties/guides/assets/images/i18n/demo_html_safe.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 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
+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.
+# config/locales/en.yml
+ 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>
+!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]

0 comments on commit bcbc484

Please sign in to comment.