Closed vegardlarsen closed 1 year ago
I don't think I've ever considered a translation being an array? What's the usecase for that? I never encountered it. I suspect that since it's not an string the AST transformer just ignores it.
Good question. We have lists of various "product features" that sometimes contains different items in different languages. In svelte-i18n
this was perfectly valid, but it may not be here.
I can probably work around this one if this is by design; and I can see that it may be problematic in terms of how the translations would interact e.g. with $json
. Feel free to close this one.
Out of curiosity, what does svelte-i18n do when you call $t('x')
? Just uses the first key in the array? What if there are several entries in this array?
I don't know that it deals with it using $t
. We used $json
to extract the array, and then getMessageFormatter
to do ICU formatting afterwards. Again, this doesn't make as much sense when precompiling.
My solution now will instead be to not use an array in the translations, and instead newline-separate the individual lines, and we can split them when using it.
👍
I tried in the playground to test something that was breaking in my project:
Output
Notice that the variable inside the
x
array is not interpolated.Expected output
This is what I expected, but it may very well need to be different.