Skip to content

Commit

Permalink
Fix Laravel 9 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarpsvo committed Apr 8, 2022
1 parent 444cc68 commit 5992591
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/LoadsNovaTranslations.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,20 @@ protected function loadTranslations($packageTranslationsDir, $packageName, $publ
$this->translations($packageTranslationsDir, $packageName, $publishTranslations);
}

private function getLangPath($pckgName)
{
$appVersion = app()->version();
$isLaravel9 = $appVersion >= '9.0.0';

return $isLaravel9
? lang_path("vendor/{$pckgName}")
: resource_path("lang/vendor/{$pckgName}");
}

private function translations($pckgTransDir, $pckgName, $publish)
{
if (app()->runningInConsole() && $publish) {
$this->publishes([$pckgTransDir => resource_path("lang/vendor/{$pckgName}")], 'translations');
$this->publishes([$pckgTransDir => $this->getLangPath($pckgName)], 'translations');
return;
}

Expand Down Expand Up @@ -95,13 +105,13 @@ private function loadLaravelTranslationsForLocale($locale, $pckgTransDir, $pckgN
return true;
}

private function getTranslationsFile($locale, $from, $packageTranslationsDir, $packageName)
private function getTranslationsFile($locale, $from, $packageTranslationsDir, $pckgName)
{
if (empty($locale)) return null;

$fileDir = $from === 'local'
? $packageTranslationsDir
: resource_path("lang/vendor/{$packageName}");
: $this->getLangPath($pckgName);

$filePath = "$fileDir/{$locale}.json";

Expand Down

0 comments on commit 5992591

Please sign in to comment.