function LocaleImportFunctionalTest::importPoFile

Helper function: import a standalone .po file in a given language.

Parameters

$contents: Contents of the .po file to import.

$options: Additional options to pass to the translation import form.

4 calls to LocaleImportFunctionalTest::importPoFile()
LocaleImportFunctionalTest::testConfigPoFile in drupal/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php
Tests .po file import with configuration translation.
LocaleImportFunctionalTest::testEmptyMsgstr in drupal/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php
Test empty msgstr at end of .po file see #611786.
LocaleImportFunctionalTest::testLanguageContext in drupal/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php
Test msgctxt context support.
LocaleImportFunctionalTest::testStandalonePoFile in drupal/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php
Test import of standalone .po files.

File

drupal/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php, line 313
Definition of Drupal\locale\Tests\LocaleImportFunctionalTest.

Class

LocaleImportFunctionalTest
Functional tests for the import of translation files.

Namespace

Drupal\locale\Tests

Code

function importPoFile($contents, array $options = array()) {
  $name = tempnam('temporary://', "po_") . '.po';
  file_put_contents($name, $contents);
  $options['files[file]'] = $name;
  $this
    ->drupalPost('admin/config/regional/translate/import', $options, t('Import'));
  drupal_unlink($name);
}