Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I put CSS style in my I18n locale?

I have a following translation:

welcome: Hello there, %{general_kenobi}

Now I know, that I can put HTML tags in the translation, like <em> or so. But what if I want this general_kenobi to have my custom style? How do I implement it? I've tried to google it, but didn't find anythin useful (or maybe I'm just bad at googling). Thank in advance!

like image 232
Giasod Avatar asked Dec 04 '25 17:12

Giasod


1 Answers

If you want to add something fancy like this to your locale you must add the _html extension to the key.

From the docs

Keys with a '_html' suffix and keys named 'html' are marked as HTML safe. When you use them in views the HTML will not be escaped.

en:
  welcome_html: "<b>Bolded text</b>"

then just the regular stuff in your views

<%= t('welcome_html')
like image 171
Eyeslandic Avatar answered Dec 06 '25 06:12

Eyeslandic