conedevelopment / i18n

Push your Laravel translations to the front-end and use them easily with JavaScript.
https://pineco.de/using-laravels-localization-js/
MIT License
129 stars 21 forks source link

Fallback locale not working #13

Closed aGirish-csq closed 4 years ago

aGirish-csq commented 4 years ago

Hi,

Thanks for this. I have followed the instructions and installed / implemented this package successfully. Everything is working fine except when the translations are not available for any key in a particular locale, it is not fetching the translation from default one. Looks like fallback locale is not working for me.

Can you kindly suggest what could I be doing wrong?

Thanks,

iamgergo commented 4 years ago

Hi,

Can you provide a concrete example, please? It would be a big help if I could understand a bit more!

Thank you!

aGirish-csq commented 4 years ago

I have all the strings/keys to be localized in messages.php under en folder. I have another locale 'fr' under which I have messages file, but it does not have all the strings which are available in en/messages. When I change the locale to 'fr' in the frontend/view, and try to fetch some of the missing strings in javascript file, it is showing 'null' instead of fetching from the en/messages file. Eg: I am using trans('messages.someString') to fetch the localized string.

Is there any additional setting I need to do to make this work?

iamgergo commented 4 years ago

I see! I'll take a look and let you know! It should not have this issue, but it's possible that I missed something.

Thanks for your help!

aGirish-csq commented 4 years ago

@iamgergo , Hi, Did you get a chance to look into this?

iamgergo commented 4 years ago

@aGirish-csq Hi,

So, the problem here is that, we don't compare the current language with the fallback language if is there any translation that is present in the fallback translation but not present in the current one.

Maybe in the future I'll add a solution that merges the missing translations from the fallback locale, but for now it's faster and easier to just add the missing keys to your french translations.

Thank you!