gbif / hosted-portals

Support material for establishing the GBIF Hosted Portals
Apache License 2.0
10 stars 6 forks source link

Handle HTML and formatting in translation strings #180

Closed MortenHofft closed 2 years ago

MortenHofft commented 2 years ago

It often useful to be able to provide newlines and some basic styling like italics in translations. Currently all html is escaped. React-intl seem to have an approach where the individual tags need approval once per use by creating a mapping to values. This is fairly cumbersome. https://formatjs.io/docs/react-intl/components/#rich-text-formatting

We could consider a general wrapper that allowed some predefined tags. The recommended approach do not support line breaks, those are suggested handled as some translated text {linebreak} and then comes a new line. But that is quite odd to ask translators to do. If so we would need a processing step that transformed\n to {linebreak}

MortenHofft commented 2 years ago

closed by https://github.com/gbif/gbif-web/commit/55aa2d20c87f6062485a3d5136bee892fe106e67