-
-
Notifications
You must be signed in to change notification settings - Fork 377
Description
Reporting a bug?
There's a very high probability of me simply misunderstanding how it's supposed to work but after some debugging I was not able to find a way to do that.
Based on the documentation we should be able to call:
$t("translation.key", "default value")
However the "default value" is always interpreted as a locale key.
Next I tried:
$t("translation.key", null, {default: "default value")})
But options object is never taken into consideration.
After some debugging I was able to find what (I believe) is the culprit:
in t(...args) {
:
else if (isPlainObject(arg2)) {
named = arg2;
}
if (isArray(arg3)) {
list = arg3;
}
else if (isPlainObject(arg3)) {
named = arg3;
}
Shouldn't it be:
else if (isPlainObject(arg3)) {
assign(options, arg3);
}
Since named interpolation object is expected as arg2?
This is sort of further confirmed by looking at $rt which passes options object as the third argument further down and after calling $rt with the options object as the third argument i can confirm that options are passed down the line.
Expected behavior
I expect to be able to pass options object or default value when using $t function
Reproduction
To reproduce try passing default value to the $t function
System Info
Using vue-i18n v9.1.6 with vue 3 in the browser context
Screenshot
No response
Additional context
No response
Validations
- Read the Contributing Guidelines
- Read the Documentation
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion