laravel-vue-i18n-generator icon indicating copy to clipboard operation
laravel-vue-i18n-generator copied to clipboard

Fallback language

Open thierrydrc opened this issue 5 years ago • 0 comments
trafficstars

Hello,

First : thank you very much for this package ! Everything is working correctly, easy way to implement :)

However I have a request, I didn't see anyone else asking for that so : => is it possible to implement fallback language ?

I'm using vue-i18n, like you told to :

const lang = document.documentElement.lang.substr(0, 2);
// or however you determine your current app locale

const i18n = new VueInternationalization({
    locale: lang,
    messages: Locale
});

I have 2 languages :

  • FR (main & fallback)
  • EN

If I didn't provide the translation in my resources/lang/en/messages.php, only the key is displayed. Exemple : messages.menu.home

It would be very great if the package can diplay the key of the fallback language if it's not provided for the current application locale, in my case : messages.menu.home in file resources/lang/fr/messages.php

Maybe with a configuration like this :

const lang = document.documentElement.lang.substr(0, 2);
const fallbackLang = 'fr'; 

const i18n = new VueInternationalization({
    locale: lang,
    fallback: fallbackLang,
    messages: Locale
});

Thank you !

thierrydrc avatar Apr 09 '20 07:04 thierrydrc