martinlindhe / laravel-vue-i18n-generator

Generates a vue-i18n compatible include file from your Laravel translations
MIT License
306 stars 207 forks source link

Fallback language #126

Open thierrydrc opened 4 years ago

thierrydrc commented 4 years ago

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 :

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 !