Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple translations files per language with vue-i18n and nuxtjs

I use nuxtjs and i18n to build a static website with multiple languages. At the moment I have one json file per language. For better structure i want to split the file in multiple files per language. How can i do that? Is there a way where i can tell i18n explicit which json file it should use for a page? Or do I have to concatenatet the jsons files to one?

I used this exmaple to build my translations https://nuxtjs.org/examples/i18n/

like image 986
Gregor Voinov Avatar asked Feb 19 '18 07:02

Gregor Voinov


1 Answers

// i18n.js plugin
import Vue from 'vue'
import VueI18n from 'vue-i18n'

Vue.use(VueI18n)

export default ({ app, store }) => {
  app.i18n = new VueI18n({
    locale: store.state.locale,
    fallbackLocale: 'en-US',
    messages: {
      en: Object.assign({}, require('~/locales/en.json'), require('~/locales/en.settings.json')),
      tr: Object.assign({}, require('~/locales/tr.json'), require('~/locales/tr.settings.json')),
    },
    silentTranslationWarn: true,
  })
}
like image 160
alperk01 Avatar answered Nov 10 '22 00:11

alperk01