protected function L10nUpdateTestBase::setCurrentTranslations in Localization update 7.2
Setup existing translations in the database and their status.
4 calls to L10nUpdateTestBase::setCurrentTranslations()
- L10nUpdateTest::testUpdateImportModeNonCustomized in tests/
L10nUpdateTest.test - Tests translation import and only overwrite non-customized translations.
- L10nUpdateTest::testUpdateImportModeNone in tests/
L10nUpdateTest.test - Tests translation import and don't overwrite any translation.
- L10nUpdateTest::testUpdateImportSourceLocal in tests/
L10nUpdateTest.test - Tests translation import from local sources.
- L10nUpdateTest::testUpdateImportSourceRemote in tests/
L10nUpdateTest.test - Tests translation import from remote sources.
File
- tests/
L10nUpdateTestBase.test, line 190 - Contains L10nUpdateTest.
Class
- L10nUpdateTestBase
- Tests for update translations.
Code
protected function setCurrentTranslations() {
// Setup to add German translations to the database.
$langcode = 'de';
$writer = new PoDatabaseWriter();
$writer
->setLangcode($langcode);
$writer
->setOptions(array(
'overwrite_options' => array(
'not_customized' => TRUE,
'customized' => TRUE,
),
));
// Add non customized translations to the database.
$writer
->setOptions(array(
'customized' => L10N_UPDATE_NOT_CUSTOMIZED,
));
$non_customized_translations = array(
'March' => 'Marz',
'June' => 'Juni',
);
foreach ($non_customized_translations as $source => $translation) {
$poItem = new PoItem();
$poItem
->setFromArray(array(
'source' => $source,
'translation' => $translation,
));
$writer
->writeItem($poItem);
}
// Add customized translations to the database.
$writer
->setOptions(array(
'customized' => L10N_UPDATE_CUSTOMIZED,
));
$customized_translations = array(
'January' => 'Januar_customized',
'February' => 'Februar_customized',
'May' => 'Mai_customized',
);
foreach ($customized_translations as $source => $translation) {
$poItem = new PoItem();
$poItem
->setFromArray(array(
'source' => $source,
'translation' => $translation,
));
$writer
->writeItem($poItem);
}
// Add a state of current translations in l10n_update_files.
$default = array(
'language' => $langcode,
'uri' => '',
'timestamp' => $this->timestamp_medium,
'last_checked' => $this->timestamp_medium,
);
$data[] = array(
'project' => 'contrib_module_one',
'filename' => 'contrib_module_one-7.x-1.1.de._po',
'version' => '7.x-1.1',
);
$data[] = array(
'project' => 'contrib_module_two',
'filename' => 'contrib_module_two-7.x-2.0-beta4.de._po',
'version' => '7.x-2.0-beta4',
);
$data[] = array(
'project' => 'contrib_module_three',
'filename' => 'contrib_module_three-7.x-1.0.de._po',
'version' => '7.x-1.0',
);
$data[] = array(
'project' => 'custom_module_one',
'filename' => 'custom_module_one.de.po',
'version' => '',
);
foreach ($data as $file) {
$file = (object) array_merge($default, $file);
drupal_write_record('l10n_update_file', $file);
}
}