I am developing an add-on in Firefox 83 and I am wondering how we should use non-breaking spaces in the i18n
API.
First of all, two requirements:
- As the docs always recommend, I use no HTML, but
.textContent
for inserting the text. - I want to make it translatable, so I use the
browser.i18n
API. - Also, the literal
_ _
is probably not good, because it is not readable and translators could overlook that this is a “special” space. So I want to show it somehow.
I have this text:
Awesome Emoji Picker
What I’ve tried:
– obviously does not work, because I need an HTML-less version\xa0
and\u00a0
– these JavaScript codepoints usually work, but if I place them in themessages.json
and then the JSON was broken and I thought I had to escape this. After all, writing\A
in a translation also just returnsA
.\\xa0
and\\u00a0
surprisingly, however, kept the backslash when doing abrowser.i18n.getMessage
, which broke it again.
And yes I could of course workaround by using a replacement character (and doing a replace afterwards), but I wonder why this does not work…