panter / vue-i18next

Internationalization for vue using the i18next i18n ecosystem.
https://panter.github.io/vue-i18next/
176 stars 47 forks source link

How to configure backend.loadPath with vue-cli 3.x? #20

Closed DenniLa2 closed 6 years ago

DenniLa2 commented 6 years ago

Hello! I use i18next with vue-cli 2.x with this config:

import Vue from 'vue'
import i18next from 'i18next'
import VueI18Next from '@panter/vue-i18next'
import XHR from 'i18next-xhr-backend'

Vue.use(VueI18Next);

i18next
  .use(XHR)
  .init({
    lng: 'ru',
    preload: ['ru'],
    fallbackLng: 'en',
    debug: true,
    backend: {
      loadPath: '/static/i18n/{{ns}}.{{lng}}.json',
      addPath: '/static/i18n/{{ns}}-{{lng}}',
    },

    ns: [
      'common',
    ],
    defaultNS: ['common']
  });

export default new VueI18Next(i18next);

But with vue-cli 3.x this config not working:

i18next::backendConnector: loading namespace common for language ru failed failed parsing /static/i18n/common.ru.json to json
i18next::backendConnector: loading namespace common for language en failed failed parsing /public/i18n/common.en.json to json

How to configure load path to load translations with vue-cli 3.x?

claudiocro commented 6 years ago

Hi

this seems to be a problem related to i18next in combination with vue-cli 3.x. Try to ask the vue-cli comunity how they handle their proxy,

cj-prog commented 6 years ago

@DenniLa2 Did you find a solution to load paths to translation files with vue-cli 3? It would be nice if you could publish a solution.