useSetI18nParams

Hi @kapa.ai if I had this definet in my setup: await slugsStore.loadSearch({type: 'family', locale: local.value.language, slug: slug}); let nuxtI18n = cloneObject(slugsStore.slugs);
console.log(nuxtI18n); if(!!Object.keys(nuxtI18n).length){ const setI18nParams = useSetI18nParams(); setI18nParams(nuxtI18n); // route.meta.nuxtI18n = nuxtI18n || {} const i18nHead = useLocaleHead({ addDirAttribute: true, addSeoAttributes: true, identifierAttribute: 'hid', });
console.log(i18nHead.value); And nuxtI18n has the right object. Why i18nHead.value.link has empty array if the nuxtI18n it's not empty and well formated?
2 Replies
kapa.ai
kapa.ai4w ago
Hi @Ivan Ortiz. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- I can see you're working with Nuxt i18n and trying to use useSetI18nParams to set route parameters, but useLocaleHead is returning an empty array for links. Based on the knowledge sources provided, I don't have specific documentation about useSetI18nParams or why useLocaleHead might return empty link arrays in this particular scenario. However, I can share some relevant context about i18n usage in Nuxt: The knowledge sources show various i18n configuration patterns and composable usage, but they don't explicitly cover the useSetI18nParams composable or troubleshooting empty link arrays in useLocaleHead. Potential considerations: 1. Timing and context: Similar to issues mentioned in the knowledge sources, composables in Nuxt require proper application context. The Stack Overflow post about using i18n in Pinia stores mentions that composables must be called within the right context (like inside setup() or <script setup>). 2. Configuration location: The knowledge sources emphasize that certain i18n configurations must be in specific files. For example, this Stack Overflow answer clarifies that locales, defaultLocale, and detectBrowserLanguage should be in nuxt.config.ts rather than i18n.config.ts. Unfortunately, the knowledge sources do not contain enough information to explain why your i18nHead.value.link is returning an empty array despite having a properly formatted nuxtI18n object. This specific behavior of useSetI18nParams and its interaction with useLocaleHead is not covered in the provided documents. I'd recommend checking the official Nuxt i18n documentation for useSetI18nParams usage patterns and ensuring your route parameters are in the expected format for generating alternate language links. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai4w ago
<@796711333285855263> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?