Fix issues with "null" locale#37
Conversation
gildastema
commented
Nov 10, 2022
- when locale is null in makeMaticeObject the translations file crash
- in config i just use the lang_path() because this method already exists in laravel
- At the end i clean the comment in the service provider
| $locale = $locale ?? config('app.locale'); | ||
| $translations = json_encode($this->translations($locale)); | ||
| $appLocale = $locale ?? app()->getLocale(); |
There was a problem hiding this comment.
I understans that here you want to prevent the app from crashing when the local is missing. But what's the difference between line 45 and line 47? Can we just move line 47a bit up so that we can $appLocal be used as the default language for $this->translations() ?
There was a problem hiding this comment.
From what I see in code actually, the translations() function handles properly the case where the local is null. Can you please elaborate here how to reproduce the null local issue?
|
|
||
| use Genl\Matice\Commands\TranslationsGeneratorCommand; | ||
| use Illuminate\Support\Facades\Blade; | ||
| use Illuminate\Support\Facades\File; |
| // $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'matice'); | ||
| // $this->loadViewsFrom(__DIR__.'/../resources/views', 'matice'); | ||
| // $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); | ||
| // $this->loadRoutesFrom(__DIR__.'/routes.php'); | ||
|
|
There was a problem hiding this comment.
They were mainly there for documenting purpose. Maybe we can keep them so that future PR makers know them easily.
| // Publishing the views. | ||
| /*$this->publishes([ | ||
| __DIR__.'/../resources/views' => resource_path('views/vendor/matice'), | ||
| ], 'views');*/ | ||
|
|
||
| // Publishing assets. | ||
| /*$this->publishes([ | ||
| __DIR__.'/../resources/assets' => public_path('vendor/matice'), | ||
| ], 'assets');*/ | ||
|
|
||
| // Publishing the translation files. | ||
| /*$this->publishes([ | ||
| __DIR__.'/../resources/lang' => resource_path('lang/vendor/matice'), | ||
| ], 'lang');*/ |
There was a problem hiding this comment.
Same here, prevent as a code documentation.