Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1882

How do I combine i18n-ally with Kaisermann/svelte-i18n library

$
0
0

I'm doing some internationalization with a Svelte project, and I'm using i18n-ally to do the language editing. i18n-ally does a great job of turning a block of code from:

<p>Copyright &copy; 2025 me</p>

... into ...

<p>{$_('copyright')}</p>

But I noticed that there are format options you can edit, and the original list lacked the sample you can see above (the $_ lacked curly braces) so I added it. So far, so good. But I also noticed that originally there were templates like:

"$t('{key}'{args})"

With a little tinkering, I found that I could attempt to replace something like:

<p>hello {{foo}} {{bar}}</p>

... and I could get ...

<p>{$_('hello', foo, bar)}</p>

Which is interesting, but not really useful since I get this in my en.json file:

"hello": "hello {{foo}} {{bar}}"

... and the correct format in my HTML should be:

<p>{$_('hello', {values: { foo: "text1", bar: "text2"}})}</p>

Which brings me to the question: Is it possible to have i18n-ally treat single curly braces as the argument delimiter and format the substitution values for the Kaisermann i18n library correctly?


Viewing all articles
Browse latest Browse all 1882

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>