Skip to content

SyntaxError: Duplicate useI18n calling by local scope. Please don't call it on local scope #2223

Open
@mrleblanc101

Description

@mrleblanc101

Reporting a bug?

11.1.6 seems to have introduced a breaking change.
The update broke multiple of our projets because of #2203.
We now have a blank page with this error in the console:

SyntaxError: Duplicate useI18n calling by local scope. Please don't call it on local scope

This seems to come from const { t } = useI18n() inside a Pinia Store.

After a bit of bebugging, this seems to be an error on our end, but it's not clear !
Simply changing from const { t } = useI18n(); to const { t } = useI18n({ useScope: 'global' }); fixed the problem.
It make sense, since a composable or Pinia store don't have a customBlock, so they don't have a local scope...

Expected behavior

Shouldn't vue-i18n ignore those case instead of crashing the whole app ?
Otherwise, the error should like to the documentation with a detailed explanation, and potential fix.

Reproduction

https://stackblitz.com/edit/vitejs-vite-ojad5ibc?file=src%2FApp.vue

System Info

System:
    OS: macOS 15.5
    CPU: (8) arm64 Apple M1 Pro
    Memory: 123.94 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.12.2 - ~/.nvm/versions/node/v20.12.2/bin/node
    npm: 10.5.0 - ~/.nvm/versions/node/v20.12.2/bin/npm
    pnpm: 8.15.5 - ~/.nvm/versions/node/v20.12.2/bin/pnpm
  Browsers:
    Chrome: 138.0.7204.93
    Chrome Canary: 140.0.7272.0
    Edge: 138.0.3351.55
    Safari: 18.5
    Safari Technology Preview: 26.0
  npmPackages:
    @intlify/unplugin-vue-i18n: ^6.0.8 => 6.0.8
    @vitejs/plugin-vue: ^5.2.4 => 5.2.4
    @vue/server-renderer: ^3.5.17 => 3.5.17
    vite: ^5.4.19 => 5.4.19
    vite-plugin-eslint2: ^4.4.2 => 4.4.2
    vite-svg-loader: ^5.1.0 => 5.1.0
    vue: ^3.5.17 => 3.5.17
    vue-eslint-parser: ^9.4.3 => 9.4.3
    vue-i18n: ^11.1.8 => 11.1.8

Screenshot

No response

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions