vue-i18n
vue-i18n copied to clipboard
Vue-i18n Parameter Replacement Issue: $t Function Not Replacing Parameters in Message String
Reporting a bug?
const messages = { en: { message: { hello: "Hello {0} world" } } };
$t("message.hello", {'0': "my" })
The expected output needs to be "Hello my world" But I am getting a string "Hello world" The same example works fine if I do it like this
const messages = { en: { message: { hello: "Hello {item} world" } } };
$t("message.hello", {'item': "my" })
The version I am on is 9.6.4 Am I doing anything wrong? I tried the same with the version 8.22.3 and it is working fine.
Expected behavior
The code below const messages = { en: { message: { hello: "Hello {0} world" } } };
$t("message.hello", {'0': "my" })
should return Hello my world not Hello world
Reproduction
Create a message string with parameter name {0} and then try to replace the parameter with the value something like {'0': "my" }
System Info
{
"name": "i18n-test",
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"vue": "^3.3.4",
"vue-i18n": "^9.6.4"
},
"devDependencies": {
"@vitejs/plugin-vue": "^4.4.0",
"vite": "^4.4.11"
}
}
Screenshot
Additional context
No response
Validations
- [X] Read the Contributing Guidelines
- [X] Read the Documentation
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Check that this is a concrete bug. For Q&A open a GitHub Discussions