Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Thrown When Keyword "link" Used As I18n Key #1711

Open
4 tasks done
TNGD-YQ opened this issue Jan 24, 2024 · 0 comments
Open
4 tasks done

Error Thrown When Keyword "link" Used As I18n Key #1711

TNGD-YQ opened this issue Jan 24, 2024 · 0 comments
Labels
🔨 p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage Type: Bug Bug or Bug fixes

Comments

@TNGD-YQ
Copy link

TNGD-YQ commented Jan 24, 2024

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

https://ibb.co/MVd2S4n

Additional context

No response

Validations

@TNGD-YQ TNGD-YQ added the Status: Review Needed Request for review comments label Jan 24, 2024
@kazupon kazupon added Type: Bug Bug or Bug fixes 🔨 p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage and removed Status: Review Needed Request for review comments labels Feb 28, 2024 — with Volta.net
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage Type: Bug Bug or Bug fixes
Projects
None yet
Development

No branches or pull requests

2 participants