Skip to content
Open
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
25 changes: 25 additions & 0 deletions src/Commands/core/LocaleCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ final class LocaleCommands extends DrushCommands
const UPDATE = 'locale:update';
const EXPORT = 'locale:export';
const IMPORT = 'locale:import';
const EXPORT_ALL = 'locale:export-all';
const IMPORT_ALL = 'locale:import-all';

protected function getLanguageManager(): LanguageManagerInterface
Expand Down Expand Up @@ -274,6 +275,30 @@ public function importAll($directory, $options = ['type' => self::REQ, 'override
drush_backend_batch_process();
}

/**
* Exports multiple translation files into the defined directory.
*
* @throws \Exception
*/
#[CLI\Command(name: self::EXPORT_ALL, aliases: ['locale-export-all', 'locale:export:all'])]
#[CLI\Argument(name: 'directory', description: 'Export directory for translation files.')]
#[CLI\Option(name: 'types', description: 'A comma separated list of string types to include, defaults to all types. Recognized values: <info>not-customized</info>, <info>customized</info>, </info>not-translated<info>')]
#[CLI\ValidateModulesEnabled(modules: ['locale'])]
public function exportAll($directory, $options = ['types' => self::REQ])
{
if (!is_dir($directory)) {
throw new \Exception('The defined directory does not exist.');
}

$languages = $this->getLanguageManager()->getLanguages();
$poreader_options = $this->convertTypesToPoDbReaderOptions(StringUtils::csvToArray($options['types']));
foreach ($languages as $language) {
$langcode = $language->getId();
$this->writePoFile($directory . '/' . $langcode . '.po', $language, $poreader_options);
}
}


/**
* Converts input of translation type.
*
Expand Down