Error Thrown When Keyword "link" Used As I18n Key
TNGD-YQ opened this issue · comments
Reporting a bug?
const messages = {
en: {
test: "hello",
"test.link": "world",
},
};
// 2. Create i18n instance with options
const i18n = createI18n({
locale: "en", // set locale
fallbackLocale: "en", // set fallback locale
messages, // set locale messages
// If you need to specify other options, you can set other options
// ...
});
In case above, as u can see our team is using the message key in form of "a.b.c.d", instead of nested object.
When we upgrade vue-i18n from v9.2.2 to latest version 9.8, we noticed a lots of breaking changes, which is expected according to the release notes.
But there is one issue cannot be explained. Error thrown when the message key end with "link", such as "test.link".
vue-i18n.js?v=a4320ed3:2863 Uncaught (in promise) TypeError: String.prototype.link called on null or undefined
at link (<anonymous>)
at evaluateMessage (vue-i18n.js?v=a4320ed3:2863:20)
at translate (vue-i18n.js?v=a4320ed3:2705:20)
at vue-i18n.js?v=a4320ed3:3662:46
at wrapWithDeps (vue-i18n.js?v=a4320ed3:3623:13)
at Proxy.t (vue-i18n.js?v=a4320ed3:3662:12)
Expected behavior
No error thrown.
"link" is not a keyword, it should be allowed to use.
Reproduction
https://stackblitz.com/edit/vitejs-vite-b9zukn?file=src%2FApp.vue
System Info
System:
OS: macOS 14.2
CPU: (10) arm64 Apple M1 Pro
Memory: 100.61 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm
pnpm: 7.28.0 - /opt/homebrew/bin/pnpm
Browsers:
Chrome: 120.0.6099.234
Safari: 17.2
npmPackages:
@vitejs/plugin-legacy: ^5.2.0 => 5.2.0
@vitejs/plugin-vue: ^4.5.2 => 4.6.2
@vue/test-utils: ^2.4.3 => 2.4.3
vite: ^5.0.10 => 5.0.11
vitest: ^1.1.0 => 1.2.0
vitest-sonar-reporter: ^1.0.0 => 1.0.0
vue: ^3.3.13 => 3.4.13
vue-dompurify-html: ^3.1.1 => 3.1.2
vue-i18n: ^9.8.0 => 9.9.0
vue-router: ^4.2.5 => 4.2.5
vue-tsc: ^1.8.26 => 1.8.27
Screenshot
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 Discussions