Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ php artisan langman:sync
This command will look into all files in `resources/views` and `app` and find all translation keys that are not covered in your translation files, after
that it appends those keys to the files with a value equal to an empty string.

### Create missing translation files from collected keys

```
php artisan langman:sync --create
```

### Filling missing translations

```
Expand Down
17 changes: 16 additions & 1 deletion src/Commands/SyncCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class SyncCommand extends Command
*
* @var string
*/
protected $signature = 'langman:sync';
protected $signature = 'langman:sync {--create : Create missing translation files}';

/**
* The description of the console command.
Expand Down Expand Up @@ -89,6 +89,21 @@ private function syncKeysFromFiles($translationFiles)
}
}
}

// create missing translation sections files from found keys.
if ($this->option('create')) {
$missingLangFiles = array_diff(
array_keys($allKeysInFiles),
array_keys($translationFiles)
);
foreach ($missingLangFiles as $langFile) {
foreach ($translationFiles as $fileName => $languages) {
foreach ($languages as $languageKey => $path) {
$this->fillMissingKeys($langFile, $allKeysInFiles[$langFile], $languageKey);
}
}
}
}
}

/**
Expand Down