5 use Drupal\Core\Language\Language;
6 use Drupal\language\Entity\ConfigurableLanguage;
7 use Webmozart\PathUtil\Path;
13 class PmEnLocaleImportCase extends CommandUnishTestCase
16 public function testBatchImportTranslations()
18 $sites = $this->setUpDrupal(1, true);
20 $root = $this->webroot();
26 $this->drush('pm-enable', ['language', 'locale', 'dblog'], $options);
27 $this->drush('config-set', ['locale.settings', 'translation.import_enabled', true], $options);
29 // Setup the interface translation system and prepare a source translation file.
30 // The test uses a local po file as translation source. This po file will be
31 // imported from the translations directory when a module is enabled.
32 $this->drush('config-set', ['locale.settings', 'translation.use_source', 'locale'], $options);
33 $this->drush('config-set', ['locale.settings', 'translation.default_filename', '%project.%language.po'], $options);
34 $this->drush('config-set', ['locale.settings', 'translation.path', '../translations'], $options);
35 $source = Path::join(__DIR__, '/resources/devel.nl.po');
36 $translationDir = Path::join($root, '../translations');
37 $this->mkdir($translationDir);
38 copy($source, $translationDir . '/devel.nl.po');
40 $this->drush('php-eval', ['\Drupal\language\Entity\ConfigurableLanguage::create([
45 $this->drush('pm-enable', ['devel'], $options);
46 $this->drush('watchdog-show', [], $options);
47 $this->assertContains('Translations imported:', $this->getSimplifiedOutput());
49 // Clean up the mess this test creates.
50 unlink($translationDir . '/devel.nl.po');
51 rmdir($translationDir);