Skip to content

Commit

Permalink
Rename and README
Browse files Browse the repository at this point in the history
  • Loading branch information
Henrik B Hansen committed Jun 18, 2020
1 parent f8ed11d commit ccc061f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ To upload your translation terms to poeditor run this command:
php artisan translation:upload {--scan : Whether the job should scan before uploading}
```

You are also able to upload your local translations if you have locale changes
```bash
php artisan translation:upload {--translations=all : Upload translations for language sv,da,...}
```


**Download translation languages**

To download languages from poeditor run this command:
Expand Down
6 changes: 3 additions & 3 deletions src/Commands/Upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Upload extends Command
{
protected $signature = 'translation:upload
{--scan : Whether the job should scan before uploading}
{--translations-for-language=all : Upload translations for language sv,da,...}
{--translations=all : Upload translations for language sv,da,...}
';

protected $description = 'Upload all translations to POEditor';
Expand All @@ -26,8 +26,8 @@ public function handle(): void

app(Translation::class)->syncTerms();

if ($this->hasOption('translations-for-language')) {
$language = $this->option('translations-for-language') === null ? null : explode(',', $this->option('translations-for-language'));
if ($this->hasOption('translations')) {
$language = in_array($this->option('translations'), [null, 'all'], true) ? null : explode(',', $this->option('translations'));
app(Translation::class)->syncTranslations($language);
}

Expand Down
15 changes: 7 additions & 8 deletions src/Translation.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,13 @@ public function syncTerms(): void

public function syncTranslations(?array $languages = null): void
{
$translations = $this->getTranslations($languages);

$this->setupPoeditorCredentials();
try {
$this->setupPoeditorCredentials();
$translations = $this->getTranslations($languages);

foreach ($translations as $language => $entries) {
try {
foreach ($translations as $language => $entries) {
$json = collect($entries)
->mapToGroups(function ($value, $key) {
->mapToGroups(static function ($value, $key) {
return [[
'term' => $key,
'translation' => [
Expand All @@ -181,9 +180,9 @@ public function syncTranslations(?array $languages = null): void
'data' => $json,
]
], 'POST');
} catch (Exception $e) {
throw $e;
}
} catch (Exception $e) {
throw $e;
}
}

Expand Down

0 comments on commit ccc061f

Please sign in to comment.