CS
CS
Explore posts from servers
NNuxt
Created by Tumulte on 8/21/2024 in #❓・help
How do you refresh a fetch with a dynamic path (/api/page/[id])
I think useAsyncData would do the trick, where your call function uses what Cake commented here earlier
11 replies
NNuxt
Created by CS on 4/21/2024 in #❓・help
Route switching when using i18n setLocale doesn't work...?
Yeah I have a lot to learn with it too :D
19 replies
NNuxt
Created by CS on 4/21/2024 in #❓・help
Route switching when using i18n setLocale doesn't work...?
Thanks for the help though! Appreciated
19 replies
NNuxt
Created by CS on 4/21/2024 in #❓・help
Route switching when using i18n setLocale doesn't work...?
And yeah, this version does seem to work, I'm just confused why the others (with switchLocalePath and all) didn't :d
19 replies
NNuxt
Created by CS on 4/21/2024 in #❓・help
Route switching when using i18n setLocale doesn't work...?
npnp
19 replies
NNuxt
Created by CS on 4/21/2024 in #❓・help
Route switching when using i18n setLocale doesn't work...?
No description
19 replies
NNuxt
Created by CS on 4/21/2024 in #❓・help
Route switching when using i18n setLocale doesn't work...?
No description
19 replies
NNuxt
Created by CS on 4/21/2024 in #❓・help
Route switching when using i18n setLocale doesn't work...?
My nuxt config (i18n) by the way, in case it helps:
i18n: {
locales: [
{
code: "en-US",
iso: "en",
file: "en-US.json",
name: "English",
icon: "emojione:flag-for-united-states",
},
{
code: "de-DE",
iso: "de",
file: "de-DE.json",
name: "Deutsch",
icon: "emojione:flag-for-germany",
},
],
defaultLocale: "en-US",
detectBrowserLanguage: {
fallbackLocale: "en-US",
},
langDir: "./locales/",
vueI18n: "./i18n.config.ts",
strategy: "prefix_except_default",
lazy: true,
},
i18n: {
locales: [
{
code: "en-US",
iso: "en",
file: "en-US.json",
name: "English",
icon: "emojione:flag-for-united-states",
},
{
code: "de-DE",
iso: "de",
file: "de-DE.json",
name: "Deutsch",
icon: "emojione:flag-for-germany",
},
],
defaultLocale: "en-US",
detectBrowserLanguage: {
fallbackLocale: "en-US",
},
langDir: "./locales/",
vueI18n: "./i18n.config.ts",
strategy: "prefix_except_default",
lazy: true,
},
19 replies
NNuxt
Created by CS on 4/21/2024 in #❓・help
Route switching when using i18n setLocale doesn't work...?
You mean with this?
19 replies
NNuxt
Created by CS on 4/21/2024 in #❓・help
Route switching when using i18n setLocale doesn't work...?
Yeah I'm pretty sure setLocale(code) was in fact setting the cookie -> but it wasn't changing the route params (the prefixes)
19 replies
NNuxt
Created by CS on 4/21/2024 in #❓・help
Route switching when using i18n setLocale doesn't work...?
After some more random testing, this here seems to work, but i'm just still stumped, why the other cases don't really seem to do it for me...?
<template>
<nav>
<div class="nav-icons">
<NuxtLink
v-for="language in locales"
:key="language.code"
class="language"
:class="{ active: locale === language.code }"
:to="localeRoute($route.path, language.code)"
>
<Icon :name="language.icon" />
<span>{{ language.name }}</span>
</NuxtLink>
</div>
<div class="links">
<NuxtLink v-for="link in links" :key="link.to" :to="localePath(link.to)">{{ link.text }}</NuxtLink>
<NuxtLink :to="localePath({ path: '/', hash: '#sport-select' })">Sport Selection</NuxtLink>
</div>
</nav>
</template>

<script lang="ts" setup>
const { locale, locales } = useI18n();
const localePath = useLocalePath();
const localeRoute = useLocaleRoute();
</script>
<template>
<nav>
<div class="nav-icons">
<NuxtLink
v-for="language in locales"
:key="language.code"
class="language"
:class="{ active: locale === language.code }"
:to="localeRoute($route.path, language.code)"
>
<Icon :name="language.icon" />
<span>{{ language.name }}</span>
</NuxtLink>
</div>
<div class="links">
<NuxtLink v-for="link in links" :key="link.to" :to="localePath(link.to)">{{ link.text }}</NuxtLink>
<NuxtLink :to="localePath({ path: '/', hash: '#sport-select' })">Sport Selection</NuxtLink>
</div>
</nav>
</template>

<script lang="ts" setup>
const { locale, locales } = useI18n();
const localePath = useLocalePath();
const localeRoute = useLocaleRoute();
</script>
19 replies
NNuxt
Created by CS on 4/21/2024 in #❓・help
Route switching when using i18n setLocale doesn't work...?
19 replies