Skip to content

Commit 1e71666

Browse files
committed
Add a note about double escapes
1 parent aa6088b commit 1e71666

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

guide/special.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,23 @@ tears-of-joy1 = {"\U01F602"}
114114
# character used here is.
115115
tears-of-joy2 = 😂
116116
```
117+
118+
----
119+
#### Note for Developers
120+
121+
If you're writing Fluent inside another programming language that uses
122+
backslash for escaping, you'll need to use _two_ backslashes to start an escape
123+
sequence in Fluent's quoted text. The first backslash is parsed by the host
124+
programming language and makes the second backslash a normal character _in that
125+
language_. The second backslash can then be correctly parsed by Fluent.
126+
127+
In JavaScript, for instance, the `privacy-label` message from one of the
128+
previous examples could be added programmatically to a bundle by using two
129+
backslashes in the source code:
130+
131+
```
132+
let bundle = new FluentBundle("en");
133+
bundle.addMessages(`
134+
privacy-label = Privacy{"\\u00A0"}Policy
135+
`);
136+
```

0 commit comments

Comments
 (0)