2

If i try to translate the following text:

{example}

like this:

$localize`{example}`

The text will disappear in the translated build.

Is there a way to escape the curly braces?

Martijn van den Bergh
  • 1,434
  • 1
  • 20
  • 40
  • I think this article can help you=)
    https://stackoverflow.com/questions/42230102/escape-special-characters-in-i18next
    – Faus Rodriguez Sep 28 '21 at 08:13
  • Sorry but this information is not helpful. Your link is about i18next while i am asking about Angular's built-in $localize function. Thanks for the effort though. – Martijn van den Bergh Sep 29 '21 at 08:59
  • Havent used angular since 8, but if you are using the bash shell (assumption due to the `$` in question), you should be escaping the braces with `\{ \}` or `'{ }'` as well. The escapes will disappear by the time it gets to Angular. Otherwise the shell will be expanding / evaluating any special characters `?`, `*`, `,`, `#`, etc. and changing the entire string as a result. Any shell will behave similarly. Chances are that angular isn't even recieving the same tokens you are sending. Single quotes ensure that the shell is blind to what is inside. – Nate T Oct 09 '21 at 21:30

1 Answers1

1

Try writing:

       $localize`${'{'}example}`      
OjtamOjtam
  • 280
  • 2
  • 8
  • As you can see in the example, mine does not have a dollar sign ($) in front of the curly braces. This issue is about something else that happens in the build process when building an other language. It uses the curly braces to replace stuff. But i can't find how to escape it. – Martijn van den Bergh Oct 06 '21 at 12:48
  • Check out this discussion https://github.com/angular/angular/issues/38569 - $localize`hello {world}` gets escaped with $localize`hello ${'{'}world}` in this comment: https://github.com/angular/angular/issues/38569#issuecomment-680041713 – OjtamOjtam Oct 06 '21 at 17:01
  • You're right, this is exactly the issue i was talking about. Marked as correct! – Martijn van den Bergh Oct 11 '21 at 06:36