This commit is contained in:
2021-03-16 19:13:14 +01:00
parent ddde9a4941
commit c5decef88c
11 changed files with 679 additions and 127 deletions

View File

@@ -15,6 +15,14 @@
</svg>
</template>
<script lang="ts">
export default {
}
</script>
<style>
.NuxtLogo {
animation: 1s appear;

View File

@@ -0,0 +1,3 @@
export default {
test: "test"
}

View File

@@ -1 +1,3 @@
export default {}
export default {
test: "teste"
}

View File

@@ -14,14 +14,12 @@
>
Documentation
</a>
<a
href="https://github.com/nuxt/nuxt.js"
target="_blank"
rel="noopener noreferrer"
<div
class="button--grey"
@click="setLocale(getLocale.toString() === 'fr' ? 'en' : 'fr')"
>
GitHub
</a>
{{ $t("test") }}
</div>
</div>
</div>
</div>
@@ -29,8 +27,18 @@
<script lang="ts">
import Vue from 'vue'
import {setLocale, getLocale} from "../services/useTranslation";
export default Vue.extend({})
export default Vue.extend({
const
setup() {
return {
setLocale, getLocale
}
}
})
</script>
<style>

View File

@@ -0,0 +1,16 @@
import {useContext} from "@nuxtjs/composition-api";
export const translate = (code: string) => {
const { $i18n } = useContext()
$i18n.t(code)
}
export const setLocale = async (locale: string) => {
const {$i18n} = useContext()
await $i18n.setLocale(locale)
}
export const getLocale = () =>{
const { $i18n } = useContext()
return $i18n.getBrowserLocale()
}