Skip to content

Commit

Permalink
use https://github.com/liip/laravel-langman for dumping the file when
Browse files Browse the repository at this point in the history
available
  • Loading branch information
lsmith77 committed Sep 3, 2019
1 parent 29d2a23 commit c62292f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
19 changes: 11 additions & 8 deletions src/SourceSaver.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,23 @@ public function call($sourceEdit, $sourceLocale)

if ($this->filesystem->exists($groupFile)) {
$translations = $this->filesystem->getRequire($groupFile);
dd($translations);
$translations = $this->applySourceEditInTranslations($translations, $sourceEdit);

$fileContent = <<<'EOT'
<?php
$translations = $this->applySourceEditInTranslations($translations, $sourceEdit);

if (class_exists('Themsaid\Langman\Manager')) {
$manager = new \Themsaid\Langman\Manager(new Filesystem, '', []);
$manager->writeFile($groupFile, $translations);
} else {
$fileContent = <<<'EOT'
<?php
return {{translations}};
EOT;
$fileContent = rtrim($fileContent);

$prettyTranslationsExport = $this->prettyVarExport->call($translations);
$fileContent = str_replace('{{translations}}', $prettyTranslationsExport, $fileContent);
$prettyTranslationsExport = $this->prettyVarExport->call($translations, ['array-align' => true]);
$fileContent = str_replace('{{translations}}', $prettyTranslationsExport, $fileContent);

$this->filesystem->put($groupFile, $fileContent);
$this->filesystem->put($groupFile, $fileContent);
}
}
}

Expand Down
17 changes: 10 additions & 7 deletions src/TranslationSaver.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,20 @@ private function save($locale, $group, $translations)

$this->filesystem->makeDirectory($dir, 0777, true, true);

$fileContent = <<<'EOT'
<?php
if (class_exists('Themsaid\Langman\Manager')) {
$manager = new \Themsaid\Langman\Manager(new Filesystem, '', []);
$manager->writeFile($dir . DIRECTORY_SEPARATOR . $group . '.php', $translations);
} else {
$fileContent = <<<'EOT'
<?php
return {{translations}};
EOT;
$fileContent = rtrim($fileContent);

$prettyTranslationsExport = $this->prettyVarExport->call($translations);
$fileContent = str_replace('{{translations}}', $prettyTranslationsExport, $fileContent);
$prettyTranslationsExport = $this->prettyVarExport->call($translations, ['array-align' => true]);
$fileContent = str_replace('{{translations}}', $prettyTranslationsExport, $fileContent);

$this->filesystem->put($dir . DIRECTORY_SEPARATOR . $group . '.php', $fileContent);
$this->filesystem->put($dir . DIRECTORY_SEPARATOR . $group . '.php', $fileContent);
}
}

private function localePath($locale)
Expand Down

0 comments on commit c62292f

Please sign in to comment.