mirror of
https://github.com/ArthurDanjou/website-old.git
synced 2026-01-20 23:11:43 +01:00
testing
This commit is contained in:
@@ -15,6 +15,14 @@
|
||||
</svg>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
|
||||
export default {
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.NuxtLogo {
|
||||
animation: 1s appear;
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
export default {
|
||||
test: "test"
|
||||
}
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
export default {}
|
||||
export default {
|
||||
test: "teste"
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
16
src/services/useTranslation.ts
Normal file
16
src/services/useTranslation.ts
Normal 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()
|
||||
}
|
||||
Reference in New Issue
Block a user