i18n: lazy-loading
This commit is contained in:
parent
de753502c9
commit
bddb950beb
|
@ -9,6 +9,7 @@
|
||||||
<div class="three wide column">
|
<div class="three wide column">
|
||||||
<h4 class="ui header">Links</h4>
|
<h4 class="ui header">Links</h4>
|
||||||
<div class="ui link list">
|
<div class="ui link list">
|
||||||
|
<p>{{ $t('Hello, world!') }}</p>
|
||||||
<router-link class="item" to="/about">
|
<router-link class="item" to="/about">
|
||||||
About this instance
|
About this instance
|
||||||
</router-link>
|
</router-link>
|
||||||
|
@ -49,7 +50,8 @@ export default {
|
||||||
PlaylistModal
|
PlaylistModal
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
console.log(this.$t('hello'))
|
this.$i18n.i18next.changeLanguage('fr')
|
||||||
|
console.log(this.$t('Hello, world!'))
|
||||||
this.$store.dispatch('instance/fetchSettings')
|
this.$store.dispatch('instance/fetchSettings')
|
||||||
let self = this
|
let self = this
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
|
|
|
@ -12,7 +12,7 @@ import axios from 'axios'
|
||||||
import {VueMasonryPlugin} from 'vue-masonry'
|
import {VueMasonryPlugin} from 'vue-masonry'
|
||||||
import VueLazyload from 'vue-lazyload'
|
import VueLazyload from 'vue-lazyload'
|
||||||
import i18next from 'i18next'
|
import i18next from 'i18next'
|
||||||
// import i18nextFetch from 'i18next-fetch-backend'
|
import i18nextFetch from 'i18next-fetch-backend'
|
||||||
import VueI18Next from '@panter/vue-i18next'
|
import VueI18Next from '@panter/vue-i18next'
|
||||||
import store from './store'
|
import store from './store'
|
||||||
import config from './config'
|
import config from './config'
|
||||||
|
@ -83,21 +83,15 @@ axios.interceptors.response.use(function (response) {
|
||||||
store.dispatch('auth/check')
|
store.dispatch('auth/check')
|
||||||
|
|
||||||
// i18n
|
// i18n
|
||||||
i18next.init({
|
i18next
|
||||||
lng: 'en',
|
.use(i18nextFetch)
|
||||||
resources: {
|
.init({
|
||||||
en: {
|
lng: 'en',
|
||||||
translation: {
|
preload: ['en'],
|
||||||
'hello': 'Hello'
|
backend: {
|
||||||
}
|
loadPath: '/static/translations/{{lng}}.json'
|
||||||
},
|
|
||||||
fr: {
|
|
||||||
translation: {
|
|
||||||
'hello': 'Bonjour'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
})
|
|
||||||
const i18n = new VueI18Next(i18next)
|
const i18n = new VueI18Next(i18next)
|
||||||
|
|
||||||
/* eslint-disable no-new */
|
/* eslint-disable no-new */
|
||||||
|
|
|
@ -1 +1,3 @@
|
||||||
{}
|
{
|
||||||
|
"Hello, world!": "Hello, world!"
|
||||||
|
}
|
|
@ -1 +1,3 @@
|
||||||
{}
|
{
|
||||||
|
"Hello, world!": "Bonjour tout le monde !"
|
||||||
|
}
|
3
po/en.po
3
po/en.po
|
@ -11,3 +11,6 @@ msgstr ""
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||||
|
|
||||||
|
msgid "Hello, world!"
|
||||||
|
msgstr "Hello, world!"
|
||||||
|
|
3
po/fr.po
3
po/fr.po
|
@ -11,3 +11,6 @@ msgstr ""
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||||
|
|
||||||
|
msgid "Hello, world!"
|
||||||
|
msgstr "Bonjour tout le monde !"
|
||||||
|
|
|
@ -11,3 +11,6 @@ msgstr ""
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
|
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
|
||||||
|
|
||||||
|
msgid "Hello, world!"
|
||||||
|
msgstr "Hello, world!"
|
||||||
|
|
Loading…
Reference in New Issue