- Issue created by @tostinni
When mass importing XLF files, the commande drush tmti
will only import the first file and then will display a message saying that the job is finished referencing the job ID of the first file in the folder.
Export various XLF files, put them in a folder and import this folder, you will get this warning :
$ drush tmti --accept-translation xlf_files
[notice] Scanning dir xlf_files.
[notice] Successfully imported file JobID40_fr_en for translation job Ressources (#45).
[warning] Skipping JobID41_fr_en for finished job Test content (#41).
[warning] Skipping JobID42_fr_en for finished job Test content (#41).
[warning] Skipping JobID43_fr_en for finished job Test content (#41).
...
So the first file is imported and all the following are skipped saying that the job is finished.
It seems that this code will keep $job
in cache and thus won't update for each file.
$plugin = \Drupal::service('plugin.manager.tmgmt_file.format')->createInstance('xlf');
foreach ($files as $path => $info) {
$job = $plugin->validateImport($path);
if (empty($job)) {
$this->logger()->error(dt('No translation job found for @filename.', array('@filename' => $info->name)));
continue;
}
if ($job->isFinished()) {
$this->logger()->warning(dt('Skipping @filename for finished job @name (#@id).', array('@filename' => $info->name, '@name' => $job->label(), '@id' => $job->id())));
continue;
}
// ...
A quick solution that we found was to reinstantiate the plugin in the loop :
foreach ($files as $path => $info) {
$plugin = \Drupal::service('plugin.manager.tmgmt_file.format')->createInstance('xlf');
$job = $plugin->validateImport($path);
if (empty($job)) {
$this->logger()->error(dt('No translation job found for @filename.', array('@filename' => $info->name)));
continue;
}
MR to be submitted.
None
None
None
Active
1.0
Translator: File