Skip to content

Commit

Permalink
Should respect the locale JSON file structure set by Laravel
Browse files Browse the repository at this point in the history
  • Loading branch information
ahtinurme committed Feb 2, 2024
1 parent c1bf7f3 commit 939a204
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/TranslationsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ public function export($download = false): void

foreach ($phrasesTree as $locale => $groups) {
foreach ($groups as $file => $phrases) {
$langPath = $download ? storage_path("app/translations/$locale/$file") : lang_path("$locale/$file");
if ($file === "$locale.json") {
$langPath = $download ? storage_path("app/translations/$file") : lang_path("$file");
} else {
$langPath = $download ? storage_path("app/translations/$locale/$file") : lang_path("$locale/$file");
}

if (! $this->filesystem->isDirectory(dirname($langPath))) {
$this->filesystem->makeDirectory(dirname($langPath), 0755, true);
Expand Down
4 changes: 4 additions & 0 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ function buildPhrasesTree($phrases, $locale): array

/** @var \Outhebox\TranslationsUI\Models\Phrase $phrase */
foreach ($phrases as $phrase) {
if ($phrase->file->file_name === "$locale.json") {
$tree[$locale][$phrase->file->file_name][$phrase->key] = ! blank($phrase->value) ? $phrase->value : $phrase->source->value;
continue;
}
setArrayValue(
array: $tree[$locale][$phrase->file->file_name],
key: $phrase->key,
Expand Down

0 comments on commit 939a204

Please sign in to comment.