Skip to content

How can I merge translations coming via a middleware from backend #2728

@christianholland

Description

@christianholland

Environment


  • Operating System: Windows_NT
  • Node Version: v18.18.1
  • Nuxt Version: 3.5.3
  • Nitro Version: 2.5.2
  • Package Manager: [email protected]
  • Builder: vite
  • User Config: ssr, app, runtimeConfig, alias, imports, css, build, modules, vue, vite
  • Runtime Modules: @nuxtjs/[email protected], @pinia/[email protected], ()
  • Build Modules: -

Reproduction

NA

Describe the bug

Hi there,

when a user enters my app some translations are loaded via a middleware from a server. I would like to use the function mergeLocaleMessage() to expand my translations with those coming from the server. However, within my middleware (*.ts) I cannot get access to i18n

const { mergeLocalMessage } = useI18n()

I get the error

Must be called at the top of a `setup` function

Any help how I could get access to i18n within a middleware would be highly appreciated

Additional context

No response

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions