function LocaleImportFunctionalTest::testAutomaticModuleTranslationImportLanguageEnable

Test automatic import of a module's translation files when a language is enabled.

File

modules/locale/locale.test, line 1044

Class

LocaleImportFunctionalTest
Functional tests for the import of translation files.

Code

function testAutomaticModuleTranslationImportLanguageEnable() {
    // Code for the language - manually set to match the test translation file.
    $langcode = 'xx';
    // The English name for the language.
    $name = $this->randomName(16);
    // The native name for the language.
    $native = $this->randomName(16);
    // The domain prefix.
    $prefix = $langcode;
    // Create a custom language.
    $edit = array(
        'langcode' => $langcode,
        'name' => $name,
        'native' => $native,
        'prefix' => $prefix,
        'direction' => '0',
    );
    $this->drupalPost('admin/config/regional/language/add', $edit, t('Add custom language'));
    // Ensure the translation file was automatically imported when language was
    // added.
    $this->assertText(t('One translation file imported for the enabled modules.'), 'Language file automatically imported.');
    // Ensure strings were successfully imported.
    $search = array(
        'string' => 'lundi',
        'language' => $langcode,
        'translation' => 'translated',
        'group' => 'all',
    );
    $this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
    $this->assertNoText(t('No strings available.'), 'String successfully imported.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.