Skip to content

Commit

Permalink
Use logger method in locale:import-all (#5738)
Browse files Browse the repository at this point in the history
  • Loading branch information
weitzman committed Aug 23, 2023
1 parent 6ab5d13 commit a87defb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Commands/core/LocaleCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ public function exportValidate(CommandData $commandData): void
#[CLI\Option(name: 'override', description: 'Whether and how imported strings will override existing translations. Defaults to the Import behavior configured in the admin interface. Recognized values: <info>none</info>, <info>customized</info>, <info>not-customized</info>, <info>all</info>', suggestedValues: ['none', 'not-customized', 'customized', 'all'])]
#[CLI\Usage(name: 'drush locale:import-all /var/www/translations', description: 'Import all translations from the defined directory (non-recursively). Supported filename patterns are: {project}-{version}.{langcode}.po, {prefix}.{langcode}.po or {langcode}.po.')]
#[CLI\Usage(name: 'drush locale:import-all /var/www/translations/custom --types=customized --override=all', description: 'Import all custom translations from the defined directory (non-recursively) and override any existing translation. Supported filename patterns are: {project}-{version}.{langcode}.po, {prefix}.{langcode}.po or {langcode}.po.')]
#[CLI\Version(version: '12.2')]
#[CLI\ValidateModulesEnabled(modules: ['locale'])]
public function importAll($directory, $options = ['type' => self::REQ, 'override' => self::REQ])
{
Expand Down Expand Up @@ -247,7 +248,7 @@ public function importAll($directory, $options = ['type' => self::REQ, 'override
foreach ($poFiles as $file) {
// Ensure we have the file intended for upload.
if (!file_exists($file)) {
$this->logger->warning(dt('Can not read file @file.', ['@file' => $file]));
$this->logger()->warning(dt('Can not read file @file.', ['@file' => $file]));
continue;
}
$poFile = (object) [
Expand All @@ -256,13 +257,13 @@ public function importAll($directory, $options = ['type' => self::REQ, 'override
];
$poFile = locale_translate_file_attach_properties($poFile, $translationOptions);
if ($poFile->langcode == LanguageInterface::LANGCODE_NOT_SPECIFIED) {
$this->logger->warning(dt('Can not autodetect language of file @file. Supported filename patterns are: {project}-{version}.{langcode}.po, {prefix}.{langcode}.po or {langcode}.po.', [
$this->logger()->warning(dt('Can not autodetect language of file @file. Supported filename patterns are: {project}-{version}.{langcode}.po, {prefix}.{langcode}.po or {langcode}.po.', [
'@file' => $file,
]));
continue;
}
if (!$this->getLanguageManager()->getLanguage($poFile->langcode)) {
$this->logger->warning(dt('Language @language does not exist for file @file', [
$this->logger()->warning(dt('Language @language does not exist for file @file', [
'@language' => $poFile->langcode,
'@file' => $file,
]));
Expand Down Expand Up @@ -406,7 +407,7 @@ private function getTranslatableLanguage(string $langcode, bool $addLanguage = f
$language = ConfigurableLanguage::createFromLangcode($langcode);
$language->save();

$this->logger->success(dt('Added language @language', [
$this->logger()->success(dt('Added language @language', [
'@language' => $language->label(),
]));
} else {
Expand Down

0 comments on commit a87defb

Please sign in to comment.