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

Translations from JSON files are not working #29

Open cedric-anne opened 3 years ago

cedric-anne commented 3 years ago
  1. Translation from JSON files are not exposed in window.translations. I was able to expose them using this following piece of code in I18nServiceProvider::translations().

        $translations = $translations->merge(
            collect(File::files(resource_path('lang')))->filter(function ($file) {
                return $file->getExtension() === 'json';
            })->mapWithKeys(function ($file) {
                return [
                    basename($file->getFilenameWithoutExtension()) => collect(json_decode($file->getContents(), true)),
                ];
            })
        );
  2. When exposing translations, thoose having a key containing a . are not working.