Translations containing backslashes
See original GitHub issue- I am on the latest ember-intl version
- I have searched the issues of this repo and believe that this is not a duplicate
Environment
- Ember Version: 3.1.0
- Ember CLI Version: 3.1.0
- Ember Intl Version: 3.2.6
- Browser(s): Chrome latest
- Node Version: 8.9.4
Steps to Reproduce
- Add a translation that contains backslashes e.g.,
email:
formats:
default: '^.+@.+\.\w+$'
The reason we return a regex in translations it to ensure consistency in UI and API validations i.e., both the UI and API use this regex.
- Try to load the translation in your app with
intl.t('email.formats.default')
View the peg$SyntaxError
error in the console:
{
"message": "Expected \"\\\\#\", \"\\\\\\\\\", \"\\\\u\", \"\\\\{\", \"\\\\}\", \"{\", [^{}\\\\\\0-\\x1F\\x7f \\t\\n\\r], end of input or whitespace but \"\\\\\" found.",
"expected": [
{
"type": "literal",
"value": "\\#",
"description": "\"\\\\#\""
},
{
"type": "literal",
"value": "\\\\",
"description": "\"\\\\\\\\\""
},
{
"type": "literal",
"value": "\\u",
"description": "\"\\\\u\""
},
{
"type": "literal",
"value": "\\{",
"description": "\"\\\\{\""
},
{
"type": "literal",
"value": "\\}",
"description": "\"\\\\}\""
},
{
"type": "literal",
"value": "{",
"description": "\"{\""
},
{
"type": "class",
"value": "[^{}\\\\\\0-\\x1F\\x7f \\t\\n\\r]",
"description": "[^{}\\\\\\0-\\x1F\\x7f \\t\\n\\r]"
},
{
"type": "end",
"description": "end of input"
},
{
"type": "other",
"description": "whitespace"
}
],
"found": "\\",
"location": {
"start": {
"offset": 6,
"line": 1,
"column": 7
},
"end": {
"offset": 7,
"line": 1,
"column": 8
}
},
"name": "SyntaxError"
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (8 by maintainers)
Top Results From Across the Web
Backslashes removed in translation - WPML
I am trying to: Translate a post from language1 to language2. So I klick on the plus-symbol and the Translation Editor opens.
Read more >Spanish Translation of “backslash” - Collins Dictionary
Spanish Translation of “backslash” | The official Collins English-Spanish Dictionary online. Over 100000 Spanish translations of English words and phrases.
Read more >Backslash - Wikipedia
The backslash \ is a typographical mark used mainly in computing and mathematics. It is the mirror image of the common slash /....
Read more >Backslash Escapes (Guile Reference Manual) - GNU.org
For example, if Guile encounters the character sequence ' \n ' in the middle of a string while processing Scheme code, it replaces...
Read more >IV75603: BACKSLASH \ INCORRECTLY TRANSLATED ON ...
The backslash is translated to 0x5C in UTF-8 and then in error to 0x7F. Example: <cache file> (with Log File Agent v6.3 GA)...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The original parser
messageformat-parser
whichintl-messageformat-parser
was derived from has quote escaping and allows backslashes now. I’ve begun to port the logic over to the intl-messageformat-parser.This will end up being a breaking change as it removes backslash as a special character for escaping in favor of the ICU spec quote escaping. I’ll version accordingly once this is ready for me to merge.
After updating the translation parser and compiler, this should now be resolved on master. Single quotes now properly escapes characters within the ICU syntax.
There are many breaking changes so will be releasing a 5.0.0-unstable shortly while I document all the breaking changes.