aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2013-06-24 09:20:10 -0700
committerLouise Crow <louise.crow@gmail.com>2013-06-24 09:20:10 -0700
commit7c15ac4dd0e5ed27be6d75bda8de278ef45da0aa (patch)
treeb4d9c373e72b7226f3d3c503e8f08e54003fb3e1
parent6875d9942c423c1114c7a3f9b9c27ac601599f2d (diff)
Split the string interpolation and translation into two steps so that the translation gets picked up by rake gettext:find. Add a bit more explanation.
-rw-r--r--app/models/user.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 306d6ad4a..9da4ad743 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -107,8 +107,11 @@ class User < ActiveRecord::Base
end
if self.public_banned?
# Use interpolation to return a string rather than a SafeBuffer so that
- # gsub can be called on it until we upgrade to Rails 3.2
- name = "#{_("{{user_name}} (Account suspended)", :user_name=> name)}"
+ # gsub can be called on it until we upgrade to Rails 3.2. The name returned
+ # is not marked as HTML safe so will be escaped automatically in views. We
+ # do this in two steps so the string still gets picked up for translation
+ name = _("{{user_name}} (Account suspended)", :user_name=> name.html_safe)
+ name = "#{name}"
end
name
end