Skip to content

Fix issues with "null" locale#37

Open
gildastema wants to merge 2 commits into
GENL:1.1.xfrom
gildastema:fix/for_l9
Open

Fix issues with "null" locale#37
gildastema wants to merge 2 commits into
GENL:1.1.xfrom
gildastema:fix/for_l9

Conversation

@gildastema
Copy link
Copy Markdown
Contributor

  • 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

@gildastema gildastema changed the title fix locale null and resource path for laravel 9 fix locale null and make small clean Nov 10, 2022
Comment on lines +45 to 47
$locale = $locale ?? config('app.locale');
$translations = json_encode($this->translations($locale));
$appLocale = $locale ?? app()->getLocale();
Copy link
Copy Markdown
Owner

@GENL GENL Jan 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() ?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for removing unused stuffs.

Comment on lines -22 to -26
// $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'matice');
// $this->loadViewsFrom(__DIR__.'/../resources/views', 'matice');
// $this->loadMigrationsFrom(__DIR__.'/../database/migrations');
// $this->loadRoutesFrom(__DIR__.'/routes.php');

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They were mainly there for documenting purpose. Maybe we can keep them so that future PR makers know them easily.

Comment on lines -32 to -45
// 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');*/
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, prevent as a code documentation.

@GENL GENL changed the title fix locale null and make small clean Fix issues with "null" locale Jan 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants