how to include tag in 18n

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


how to include <strong> tag in 18n



on my message.json file


"step5":{
"message": "Press Start.<strong>Warning:</strong>
}



it finally shows like this



Press Start.<strong>Warning:</strong>


Press Start.<strong>Warning:</strong>



but i want to show it like this Press Start Warning:
(warning should be strong in the front end, what i should do?)




1 Answer
1



I suggest you split your tag into two different tags.



So your current:


"step5":{
"message": "Press Start.<strong>Warning:</strong>"
}



Becomes:


"step5" : {
"message": "Press Start.",
"message_warning": "Warning:",
}



This way, your markup is unchanged, and whenever you need to update it, you can reuse the tags you defined before.



Let's assume you're using a template engine such as Pug, with this kind of markup:


.alert
p Press Start!
strong Warning!



Over time, you probably will need to change the markup to something like:


.new-alert
p Press Start
(...)
.another-div
button Warning!



Using tag separation, this change will not affect markup as it focuses on the text and not the actual markup.





your solution is amazing.Do we have a easier way?
– 12345GG
yesterday





@12345GG There's no point in trying to render markup inside a tag of i18n, it also gives you the ability to handle the tags without actually messing with your markup (which can change over time)
– HumbertoWoody
yesterday


i18n





?????for example?
– 12345GG
yesterday





@12345GG I updated my answer with this clarification
– HumbertoWoody
yesterday






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Keycloak server returning user_not_found error when user is already imported with LDAP

PHP parse/syntax errors; and how to solve them?

How to scale/resize CVPixelBufferRef in objective C, iOS