Closed Wuraim closed 1 month ago
Would you be able to provide a reproduction? 🙏
Did you update vue-i18n
to v10? Nuxt i18n v8 does not support this version, but vue-i18n
removed tc
among other breaking changes, please refer to the documentation for more details on this https://vue-i18n.intlify.dev/guide/migration/breaking10.html.
I can't understand what your solution may be :
Sorry if my previous message was confusing. The tc
function is only available as legacy API in vue-i18n
v9, and has been fully replaced with an oveload of t
in vue-i18n
v10.
If you're using composition API, that means you likely don't want to use the legacy API, refer to this section to see a mapping of their equivalents: https://vue-i18n.intlify.dev/guide/advanced/composition.html#mapping-between-vuei18n-instance-and-composer-instance and this section on pluralization using the t
function: https://vue-i18n.intlify.dev/guide/advanced/composition#pluralization.
Basically, this is not a bug, the API has changed. If you're still experiencing issues you will have to provide more information about your project and preferably a minimal reproduction.
EDIT - I just noticed the comment was not by the original author, but the information is applicable to both
Thanks a lot for your detailed answer, I understand now.
What took me some effort to realize is that when migrating from $tc
to the new $t
, you need to swap the 2nd and 3rd arguments:
$tc('banana', 100, { n: 'too many' })
should become:
$t('banana', { n: 'too many' }, 100)
However, the two-argument syntax remains unchanged:
$tc('apple', 100)
becomes:
$t('apple', 100)
Environment
Build Modules: -
Reproduction
You just have to notice that the keys 'tc' of the object returned by useI18n() is not declared.
Describe the bug
When using the composable useI18n() to get access to the tc method for the pluralization, that function is not defined. (Unlike the function t, which is defined)
We are forced to use the $tc or other methods to do it
Additional context
No response
Logs
No response