Skip to content

Commit

Permalink
update guides, use html safe translations in i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
avakhov committed Sep 15, 2011
1 parent 49476ee commit 7531aa7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions railties/guides/source/i18n.textile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 7531aa7

Please sign in to comment.