summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorYusuke Nemoto <kaakaa@users.noreply.github.com>2018-07-21 01:52:20 +0900
committerElias Nahum <nahumhbl@gmail.com>2018-07-20 12:52:20 -0400
commit6104c37761deb8f06ea4af8838db12b8158318be (patch)
treeb435543c08932bae6cc19415536ace1135c13f26 /utils
parent908a682fcf3bbc48db75099f636d627616757b24 (diff)
downloadchat-6104c37761deb8f06ea4af8838db12b8158318be.tar.gz
chat-6104c37761deb8f06ea4af8838db12b8158318be.tar.bz2
chat-6104c37761deb8f06ea4af8838db12b8158318be.zip
Break HTML blocks to individual strings (#8903)
* Modifying message and templates about mfa_change * Modifying message and templates about password_change * Modify message and template about password_reset * Modify message and template about singin_change * Modify message and template about email_info * Modify message and template about change_username * Modify message about change_email * Add missing props * Add argument * Modify message and template about token_added * Modify messages and template about notification_email * Modify message and template about deactivate_email * Fix style * Remove unused message * Remove br tags * Modify message and code about invite_mail * Add missing message
Diffstat (limited to 'utils')
-rw-r--r--utils/html.go6
-rw-r--r--utils/html_test.go4
2 files changed, 7 insertions, 3 deletions
diff --git a/utils/html.go b/utils/html.go
index 0de33435d..8e1a78875 100644
--- a/utils/html.go
+++ b/utils/html.go
@@ -11,6 +11,7 @@ import (
"io"
"path/filepath"
"reflect"
+ "strings"
"sync/atomic"
"github.com/fsnotify/fsnotify"
@@ -119,7 +120,10 @@ func (t *HTMLTemplate) RenderToWriter(w io.Writer) error {
}
func TranslateAsHtml(t i18n.TranslateFunc, translationID string, args map[string]interface{}) template.HTML {
- return template.HTML(t(translationID, escapeForHtml(args)))
+ message := t(translationID, escapeForHtml(args))
+ message = strings.Replace(message, "[[", "<strong>", -1)
+ message = strings.Replace(message, "]]", "</strong>", -1)
+ return template.HTML(message)
}
func escapeForHtml(arg interface{}) interface{} {
diff --git a/utils/html_test.go b/utils/html_test.go
index ba67189b6..43363488f 100644
--- a/utils/html_test.go
+++ b/utils/html_test.go
@@ -28,7 +28,7 @@ func init() {
htmlTestTranslationBundle = bundle.New()
fooBold, _ := translation.NewTranslation(map[string]interface{}{
"id": "foo.bold",
- "translation": "<b>{{ .Foo }}</b>",
+ "translation": "<p>[[{{ .Foo }}]]</p>",
})
htmlTestTranslationBundle.AddTranslation(&language.Language{Tag: "en"}, fooBold)
}
@@ -103,7 +103,7 @@ func TestHTMLTemplate_RenderError(t *testing.T) {
}
func TestTranslateAsHtml(t *testing.T) {
- assert.EqualValues(t, "<b>&lt;i&gt;foo&lt;/i&gt;</b>", TranslateAsHtml(i18n.TranslateFunc(htmlTestTranslationBundle.MustTfunc("en")), "foo.bold", map[string]interface{}{
+ assert.EqualValues(t, "<p><strong>&lt;i&gt;foo&lt;/i&gt;</strong></p>", TranslateAsHtml(i18n.TranslateFunc(htmlTestTranslationBundle.MustTfunc("en")), "foo.bold", map[string]interface{}{
"Foo": "<i>foo</i>",
}))
}