Skip to content

Styling my i18n strings: is it even possible? #226

Answered by ivanhofer
lucavenir asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @lucavenir

thank you @ivanhofer for this awesome package.

Thanks for your kind words.

typesafe-i18n doesn't handle stylung of strings by itself. But you can write the messages however you like. You can write them with HTML markup and use Svelte's @html to render it.

{
   sentence: "Hi! This is a sentence. I'd like to write this <strong>sentence</strong> at least <span class="colorful">{number}</span> times.
}
<p>
   {@html $LL.sentence("one")}
</p>

<style>
   p global(.colorful) {
      color: yellow;
   }
</style>

You need to be carefully when styling classes that are located inside the @html part. They need to be defined in a global way. Buf if you are using Tailwind's utility cla…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@lucavenir
Comment options

@ivanhofer
Comment options

@lucavenir
Comment options

Answer selected by ivanhofer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants