Given a Laravel 5.5 project, I want to use the "single file component" of the vue-i18n plugin. Documentation. It seems simple, but I can't get it to work.
app.js
import VueI18n from 'vue-i18n'
Vue.use(VueI18n)
const i18n = new VueI18n({
locale: 'en',
messages: {
"en": {
"word1": "hello world!"
}
}
})
Vue.component('test', require('./components/test.vue'));
const app = new Vue({ i18n, el: '#apps'});
components/test.vue
<template>
{{ $t('word1') }}
{{ $t('word2') }}
</template>
<i18n>
{
"en": {
"word2": "does this work?"
}
}
</i18n>
<script>
export default {
name: "test"
data() {
return {
locale: 'en'
}
},
mounted() {},
watch: {
locale (val) {
this.$i18n.locale = val
}
}
}
</script>
word1 is being replaced, however word2 is not. Placing bad syntax between the i18n-tags in the vue file, does NOT result in an error while compiling the files (npm run dev
). This makes sense, because I'm missing the:
module.exports = {
// ...
module: {
rules: [
...
This is supposed to go in the Webpack configuration
. But, where is this file in laravel? All I can find is the webpack.mix.js, but placing this code in there, does not do much... Also making it mix.module.exports
does not do the trick. Searching led me to this topic, but i'm not sure if he's asking the same as I am.
The problem: the i18n-tags aren't loaded. The solution is to add the code from the documentation.
My question: Where do I add this code?