New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add locale:export:all - exports all translations to po files #5781
Comments
I cannot upload patch here, but I've already created command for myself diff --git a/src/Commands/core/LocaleCommands.php b/src/Commands/core/LocaleCommands.php
index fea828a6e..903b14519 100644
--- a/src/Commands/core/LocaleCommands.php
+++ b/src/Commands/core/LocaleCommands.php
@@ -27,6 +27,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
@@ -284,6 +285,30 @@ final class LocaleCommands extends DrushCommands
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.
* |
Hi. We are in need of a new locale maintainer for Drush. Hopefully they will show up and evaluating this will be a nice first task for them. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is your feature request related to a problem? Please describe.
In deployment we rarely deploy only couple of languages, we deploy it all, so it would be useful if we have unified command for exporting all languages to directory.
Also this is nice combination with locale:import:all
Describe the solution you'd like
I think adding something like this would be nice:
The text was updated successfully, but these errors were encountered: