vuex-i18n
vuex-i18n copied to clipboard
Translating plural statements, lack of documentation
Hello!
So far I have not been able to translate plural statements like for example:
$t('{count} car ::: {count} cars', {count: count},count)
How should my key-value pair look in the translation variable? I can't seem to find any information on this in the documentation. This is how my translation variable from English to Danish would initially look by looking at the docs, but nothing is being translated:
const da = {
"{count} cars" : "{count} biler",
"{count} car" : "{count} bil",
}
OK after a few hours at trying different stuff, i tried the following which worked:
const da = {
"{count} car ::: {count} cars" : "{count} bil ::: {count} biler"
}
Hope this is useful to anyone
Hi @jonasgroendahl
Apparently the description in the readme is not very clear. I will update the description in the coming days.
// using the translation directly (as specified in the current readme)
{{ $t('You have {count} new message ::: You have {count} new messages', {count: 5}, 5) }}
// using a key to lookup the translations
{{ $t('mykey', {count: 5}, 5) }}
const translations {
'mykey': 'You have {count} new message ::: You have {count} new messages'
}
// alternative specification with array for translations
const translations {
'mykey': [
'You have {count} new message',
'You have {count} new messages'
]
}
Hope this clarifies things for now.
Hi @tikiatua
Is it possible to add the 0 option ? Meaning having apple: [ 'no apples', 'one apple', '{count} apples' ] ?
Thank you