adbrosaci / vue-lang-router

Vue language routing with (optional) localized URLs.
MIT License
66 stars 8 forks source link

any other way to get translation file other then LOAD: () => {import.... ? #4

Closed SkyRideRq closed 4 years ago

SkyRideRq commented 4 years ago

hi, I'm getting [vue-i18n] Cannot translate the value of keypath 'global.logOut'. Use the value of keypath as default. i think it's because language file is loaded async and its creating warn above and translation lag (first app is dislaying variables and after short time translated values) is there another way to load default loanguage file without async load function?

radek-altof commented 4 years ago

Hi @SkyRideRq, you're right, it's exactly because of that. I don't consider it an issue, in fact, I prefer not to have default translations loaded, as it adds more kB to users who use different language.

Right now there's no other way to pass in the translations, you have to use the async load function. However, I understand that someone might like to load translations upfront, so I'll take a look at it and try to add some option for it.

radek-altof commented 4 years ago

Solved in https://github.com/adbrosaci/vue-lang-router/commit/4b825aed1bf63d40124adc12702b051eed109470. Run npm update vue-lang-router and you should get the changes.

You can now specify messages object instead of load function whenever you wish to pass in messages upfront. It's going to look something like this:

import enMessages from './en.json';

export default {
  en: {
    name: 'English',
    messages: enMessages,
    // load: () => { return import('./en.json'); }, // Not needed anymore
  },
};
SkyRideRq commented 4 years ago

o thx 👍 :)