protected function TwigTransTest::installLanguages in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/system/src/Tests/Theme/TwigTransTest.php \Drupal\system\Tests\Theme\TwigTransTest::installLanguages()
Helper function: install languages.
1 call to TwigTransTest::installLanguages()
- TwigTransTest::setUp in core/
modules/ system/ src/ Tests/ Theme/ TwigTransTest.php - Sets up a Drupal site for running functional and integration tests.
File
- core/
modules/ system/ src/ Tests/ Theme/ TwigTransTest.php, line 175 - Contains \Drupal\system\Tests\Theme\TwigTransTest.
Class
- TwigTransTest
- Tests Twig "trans" tags.
Namespace
Drupal\system\Tests\ThemeCode
protected function installLanguages() {
foreach ($this->languages as $langcode => $name) {
// Generate custom .po contents for the language.
$contents = $this
->poFileContents($langcode);
if ($contents) {
// Add test language for translation testing.
$edit = array(
'predefined_langcode' => 'custom',
'langcode' => $langcode,
'label' => $name,
'direction' => LanguageInterface::DIRECTION_LTR,
);
// Install the language in Drupal.
$this
->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
$this
->assertRaw('"edit-languages-' . $langcode . '-weight"', 'Language code found.');
// Import the custom .po contents for the language.
$filename = tempnam('temporary://', "po_") . '.po';
file_put_contents($filename, $contents);
$options = array(
'files[file]' => $filename,
'langcode' => $langcode,
'customized' => TRUE,
);
$this
->drupalPostForm('admin/config/regional/translate/import', $options, t('Import'));
drupal_unlink($filename);
}
}
$this->container
->get('language_manager')
->reset();
}