Skip to content

Commit

Permalink
Experimental testing of translated languages, must be manually enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
worldwidepixel committed Jul 12, 2024
1 parent e3d0b30 commit 5841baf
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 3 deletions.
11 changes: 10 additions & 1 deletion i18n/i18n.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import enUS from "./lang/en-US.json"
import ruRU from "./lang/ru.json"
import deDE from "./lang/de.json"
import esES from "./lang/es-ES.json"
import noNO from "./lang/no.json"
import ptBR from "./lang/pt-BR.json"

export default defineI18nConfig(() => ({
legacy: false,
fallbackLocale: "en",
locale: "en",
messages: {
en: enUS,
ru: ruRU,
de: deDE,
"es-ES": esES,
"no-NO": noNO,
"pt-BR": ptBR,
},
strategy: "no_prefix",
}))
26 changes: 24 additions & 2 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,39 @@ export default defineNuxtConfig({
},
modules: ["@nuxtjs/tailwindcss", "nuxt-lucide-icons", "@nuxtjs/i18n"],
i18n: {
strategy: "no_prefix",
defaultLocale: "en",
locales: [
{
code: "en",
name: "English (US)",
},
{
code: "ru",
name: "русский (Russia)",
},
{
code: "de",
name: "Deutsch (Germany)",
},
{
code: "es-ES",
name: "Español (Spain)",
},
{
code: "no-NO",
name: "norsk (Norway)",
},
{
code: "pt-BR",
name: "Português (Brazil)",
},
],
detectBrowserLanguage: {
/*detectBrowserLanguage: {
useCookie: true,
cookieKey: "NE_i18nCookie",
},
}, RE-ENABLE THIS WHEN WE ACTUALLY DO RELEASE FULL i18n */
detectBrowserLanguage: false,
vueI18n: "./i18n/i18n.config",
},
})
40 changes: 40 additions & 0 deletions pages/flags.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<template>
<div class="flex flex-col gap-8">
<PageHero
:title="'Experimental Features'"
:sub-title="'For development purposes'"
/>

<div class="flex flex-col gap-2">
<span class="font-bold text-lg">
Language switcher (for testing purposes)
</span>

Current Locale:

{{ locale }}

<br /><br />

Available alternative langagues:

<a
class="indent-4"
href="#"
v-for="locale in availableLocales"
:key="locale.code"
@click.prevent.stop="setLocale(locale.code)"
>
<span>- {{ locale.name }}</span>
</a>
</div>
</div>
</template>

<script setup>
const { locale, locales, setLocale } = useI18n()
const availableLocales = computed(() => {
return locales.value.filter((i) => i.code !== locale.value)
})
</script>

0 comments on commit 5841baf

Please sign in to comment.