i18next / i18next-gitbook

165 stars 172 forks source link

Using HTML tags in keys #100

Closed madeInLagny closed 5 years ago

madeInLagny commented 5 years ago

I have been trying to find how to incorporate html tags in keys, using interpolation. However, I could not get this to work.

"key": "<span class='{{class}}'>Organisor</span> subscription"

i18next.t('key',{ class: 'blue' });

This returns

[object, object]

What is the recommended way to manage HTML tags in keys ?

jamuhl commented 5 years ago

Did you read / try: https://www.i18next.com/translation-function/interpolation#unescape

madeInLagny commented 5 years ago

Hello, yes I did. I tried all options. The best I could get is this: "premiumParticipant": "Abonnement {{startSpan}} participant Premium {{endSpan}}"

i18next.t("pricing:premiumParticipant", { startSpan: "<span class='nephritis'>", endSpan: "</span>", interpolation: { escapeValue: false } }) This returns:

ABONNEMENT <SPAN CLASS='NEPHRITIS'> PARTICIPANT PREMIUM </SPAN>

Which is obviously not what I am looking for. Any hints on how I should handle this ? Thanks

jamuhl commented 5 years ago

"premiumParticipant": "Abonnement <SPAN CLASS='NEPHRITIS'> participant Premium </SPAN>" i18next.t('premiumParticipant') will return what you expect...it does not escape the tags...it's your UI framework doing that...

madeInLagny commented 5 years ago

Thank you for your reply. I will use an innerHtml method to solve the problem.

https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail Garanti sans virus. www.avast.com https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

Le lun. 30 sept. 2019 à 09:38, Jan Mühlemann notifications@github.com a écrit :

"premiumParticipant": "Abonnement participant Premium " i18next.t('premiumParticipant') will return what you expect...it does not escape the tags...it's your UI framework doing that...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/i18next/i18next-gitbook/issues/100?email_source=notifications&email_token=ANAR2M3Q4WAEP2BEZARGYKDQMG3KFA5CNFSM4IW5YOW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD744JMY#issuecomment-536462515, or mute the thread https://github.com/notifications/unsubscribe-auth/ANAR2M6665VVG75CQVMDMUDQMG3KFANCNFSM4IW5YOWQ .