admin管理员组

文章数量:1122846

Using Angular's localize library (@angular/localize) to handle translations in an application. In my German copy however I have certain words that are too long and need a soft hyphen line break opportunity.

If I include the &shy character in the translation file however, it gets rendered as just that. Is there a way to render the line break character correctly, or else prevent the & character from being rendered in html as &amp?

Example translation file (using json format - can use a different format though if it makes a difference):

{
        "home-heading-text": "Folgendes Wort ist sehr lang: Abschieds­geschenk"
}
<h1 i18n="@@home-heading-text">Following word is very long: farewell gift</h1>

Using Angular's localize library (@angular/localize) to handle translations in an application. In my German copy however I have certain words that are too long and need a soft hyphen line break opportunity.

If I include the &shy character in the translation file however, it gets rendered as just that. Is there a way to render the line break character correctly, or else prevent the & character from being rendered in html as &amp?

Example translation file (using json format - can use a different format though if it makes a difference):

{
        "home-heading-text": "Folgendes Wort ist sehr lang: Abschieds&shy;geschenk"
}
<h1 i18n="@@home-heading-text">Following word is very long: farewell gift</h1>
Share Improve this question asked Nov 22, 2024 at 16:05 James JenkinsonJames Jenkinson 1,6512 gold badges17 silver badges35 bronze badges 0
Add a comment  | 

1 Answer 1

Reset to default 1

You can use the unicode value and it seems to work as expected. Please reduce the size of the stackblitz preview window to a really small size and it will be noticeable.

{
  "home.welcome": "Hello {$name}! You \u00AD have {$messageCount} messages."
}

Forked Stackblitz

Symfony Translations: Soft hyphens (­) in messages yaml file? - deceze ♦ Comment

本文标签: localizationInclude ampshy character (or equivalent) in Angular39s localize libraryStack Overflow