summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWinnie Hellmann <winnie@gitlab.com>2018-01-25 13:36:04 +0000
committerWinnie Hellmann <winnie@gitlab.com>2018-01-25 13:36:04 +0000
commitcba72369592c3ac29d304f9aa72c30bb5f6af412 (patch)
tree7ac43406704da0410382c1c36f27e357c58e3b55
parent1f5af51b476a36a72759e7560c125c2b9602b145 (diff)
downloadgitlab-ce-winh-sprintf-no-escape.tar.gz
Document example for sprintf without escapingwinh-sprintf-no-escape
-rw-r--r--doc/development/i18n/externalization.md10
1 files changed, 9 insertions, 1 deletions
diff --git a/doc/development/i18n/externalization.md b/doc/development/i18n/externalization.md
index f493ad4ae66..b2a2eef216d 100644
--- a/doc/development/i18n/externalization.md
+++ b/doc/development/i18n/externalization.md
@@ -211,10 +211,18 @@ There is also and alternative method to [translate messages from validation erro
- In JavaScript:
```js
- import { __, sprintf } from '../../../locale';
+ import { __, sprintf } from '~/locale';
sprintf(__('Hello %{username}'), { username: 'Joe' }) => 'Hello Joe'
```
+By default, `sprintf` escapes the placeholder values.
+If you want to take care of that yourself, you can pass `false` as third argument.
+
+ ```js
+ import { __, sprintf } from '~/locale';
+ sprintf(__('This is %{value}'), { value: '<strong>bold</strong>' }, false) => 'This is <strong>bold</strong>'
+ ```
+
The placeholders should match the code style of the respective source file.
For example use `%{created_at}` in Ruby but `%{createdAt}` in JavaScript.