content icon indicating copy to clipboard operation
content copied to clipboard

Navigation content returns default language instead of specified language

Open jxk-developer opened this issue 1 year ago • 1 comments

Environment



Reproduction

Vue component file: [...slug].vue

Code snippet attempting to fetch French navigation content:

const { data: navigation } = await useAsyncData('nav', () =>
  fetchContentNavigation({ locale: 'fr' })
);

Expected Outcome: The navigation data should be in French. Actual Outcome: The navigation data is returned in the default language (English).

Link to reproduce: https://stackblitz.com/edit/nuxt-starter-aww5hu?file=pages%2F%5B...slug%5D.vue

Describe the bug

Configuration

  • File: nuxt.config.ts
  • Relevant Configuration:
    content: {
      defaultLocale: 'en',
      locales: ['en', 'fr'],
    }
    

Problem Description

When attempting to fetch navigation content in the French language from a Vue component, the expected result should be content returned in French (fr). However, the content is being returned in the default language (English) instead of the specified French language.

Additional context

It would be greatly appreciated if you could provide documentation on integrating @nuxt/i18n with @nuxt/content. This guidance would be invaluable for developers looking to leverage both modules effectively in their projects.

Logs

No response

jxk-developer avatar Feb 16 '24 06:02 jxk-developer

Try this:

const { locale } = useI18n()

const { data: navigation } = await useAsyncData(
  'navigation',
  () => fetchContentNavigation(
    queryContent()
      .where({ _locale: locale.value })
  ), {
    watch: [locale]
  })

deetz99 avatar Mar 04 '24 20:03 deetz99

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar Jul 18 '24 14:07 github-actions[bot]

This issue was closed because it has been stalled for 30 days with no activity.

github-actions[bot] avatar Aug 18 '24 01:08 github-actions[bot]