Skip to content

Commit

Permalink
Modified publish path for lang files
Browse files Browse the repository at this point in the history
  • Loading branch information
sadegh19b committed Jun 21, 2022
1 parent 113c038 commit dd2e406
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/PersianValidationServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,17 @@ class PersianValidationServiceProvider extends ServiceProvider
public function boot()
{
$vendorLangPath = $langLoaderPath = __DIR__.'/../lang/';
$laravelVersion = explode('.', app()->version());
// In Laravel 9+, lang files are in root path of app.
$baseLangPath = base_path('lang/');
$langPath = $laravelVersion[0] >= '9' ? base_path('lang/') : resource_path('lang/');
$langFileName = 'persian-validation';
$langNamespace = 'sbpValidation';

// publish language file to resources/lang/{AppLocale}/persian-validation.php
$this->publishes([ $vendorLangPath => $resourceLangPath ]);
$this->publishes([ $vendorLangPath => $langPath ]);

if (count(glob($resourceLangPath . "*/{$langFileName}.php")) !== 0)
$langLoaderPath = $resourceLangPath;
if (count(glob($langPath . "*/{$langFileName}.php")) !== 0)
$langLoaderPath = $langPath;

$this->loadTranslationsFrom($langLoaderPath, $langNamespace);

Expand Down

0 comments on commit dd2e406

Please sign in to comment.