1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

update guides, use html safe translations in i18n

This commit is contained in:
Alexey Vakhov 2011-09-15 10:41:55 +04:00
parent 49476eee78
commit 7531aa7641
2 changed files with 22 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View file

@ -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]