vue-i18n icon indicating copy to clipboard operation
vue-i18n copied to clipboard

Simpler solution to translate key to a specific locale

Open codeflorist opened this issue 2 years ago • 0 comments
trafficstars

Clear and concise description of the problem

If one wants to translate a key to a specific locale, this is possible by stating the locale in the TranslateOptions object.

However, the only signatures available taking this parameter are:

t(key, plural, TranslateOptions)
t(key, defaultMsg, TranslateOptions)
t(key, interpolations, TranslateOptions)

So the easiest solution would be using the plural-variant. e.g.:

t('message.key', 1, { locale: 'fr' })

But i should not be required to state a plural option, if i don't need it.

Suggested solution

The solution would be to provide the following additional signature:

t(key,TranslateOptions)

Then this simple and logical solution would be possible:

t('message.key', { locale: 'fr' })

Alternative

No response

Additional context

No response

Validations

codeflorist avatar Mar 17 '23 09:03 codeflorist