Is there a good practice for localizations which include some structure in the returned text, like spans with text attributes (emphasis, color, links, etc.)? Messages like:
- This is a very dangerous operation, are you sure?
- Please visit your account status page to enable this feature
The practice I’ve most often seen has been to embed markers in the string and search for them after translation, or (shudder) to parse the translations as HTML. Neither strike me as very good approaches. It would be nice to have some way for the message catalog to return translations with some (small, well-controlled) amount of structure, but I’m not sure what this would look like, exactly.
The usual i18n difficulties apply: an attribute-bearing span in one translation might not appear at all in another language, or may even be disjoint. Spans could potentially overlap or be nested (e.g. links vs emphasis) and the “topology” could differ between languages.
Are there any examples of i18n systems that handle this well? Is there any work on this kind of thing in the Fluent ecosystem?