aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/i18n.md
diff options
context:
space:
mode:
authorecoologic <erikecoologic@gmail.com>2014-10-07 23:17:56 +1000
committerecoologic <erikecoologic@gmail.com>2014-10-07 23:17:56 +1000
commit117f09c5d1eb600908001bb7b5ee353756e56456 (patch)
tree717d45020cf652840f90c09579692e30bf31237b /guides/source/i18n.md
parent8caf16a281260fedb0677c85047469e99c48da94 (diff)
parent75780373af9a3ddd4cc1bda3d4dbfe6121102b2e (diff)
downloadrails-117f09c5d1eb600908001bb7b5ee353756e56456.tar.gz
rails-117f09c5d1eb600908001bb7b5ee353756e56456.tar.bz2
rails-117f09c5d1eb600908001bb7b5ee353756e56456.zip
Merge remote-tracking branch 'origin/master' into guides-template-inheritance
Diffstat (limited to 'guides/source/i18n.md')
-rw-r--r--guides/source/i18n.md16
1 files changed, 16 insertions, 0 deletions
diff --git a/guides/source/i18n.md b/guides/source/i18n.md
index 1023598aa4..0761d5b39c 100644
--- a/guides/source/i18n.md
+++ b/guides/source/i18n.md
@@ -676,6 +676,22 @@ en:
<div><%= t('title.html') %></div>
```
+Interpolation escapes as needed though. For example, given:
+
+```yaml
+en:
+ welcome_html: "<b>Welcome %{username}!</b>"
+```
+
+you can safely pass the username as set by the user:
+
+```erb
+<%# This is safe, it is going to be escaped if needed. %>
+<%= t('welcome_html', username: @current_user.username %>
+```
+
+Safe strings on the other hand are interpolated verbatim.
+
NOTE: Automatic conversion to HTML safe translate text is only available from the `translate` view helper method.
![i18n demo html safe](images/i18n/demo_html_safe.png)