Skip to content

Explore markup-rich translations #1267

@sidvishnoi

Description

@sidvishnoi

Presently, we can only add plain text in localization strings. If we want to bold/emphasise some text or mark some text as <code>, we've few options: either use HTML or use a markdown processor, or manually split strings into HTML and plain text bits. Markdown appears best to go ahead with, but we need to convert markdown to React JSX, not HTML strings (so we can add onClick behavior to links/buttons, or other custom behavior, and also avoids HTML injection risks).

Plan:

In locales:

- "message": "Uses PostHog to collect usage and analytics data."
+ "message": "Uses [PostHog](https://posthog.com/) to collect usage and analytics data."

In components that use t = useTranslation():

- <p>{t('key')}</p>
+ <p>{md(t('key'), {
+   link: (text, url) => (<a href={url} className="...">{text}</a>) // when we want custom behavior
+ })}</p>

Such utility may also be helpful with our docs websites (that use JSX/Astro).

Further context: #1263 (comment), #1251 (review)

Metadata

Metadata

Assignees

Labels

area: pagesChanges to any of extension's pagesaria: i18nTranslations

Type

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions