function i18n_Strings_Test::testStringsAPI in Internationalization 6
Test base i18nstrings API
File
- tests/
i18n_strings.test, line 34
Class
Code
function testStringsAPI() {
// Create a bunch of strings for three languages
$strings = $this
->stringCreateAll(10);
// Save source strings and store translations
foreach ($strings['en'] as $key => $string) {
$name = "test:string:{$key}:name";
i18nstrings_update($name, $string);
$count = $this
->stringSaveTranslation($name, 'es', $strings['es'][$key]);
$count += $this
->stringSaveTranslation($name, 'pt-br', $strings['pt-br'][$key]);
$this
->assertEqual($count, 2, "Two translatins have been saved");
}
// Check translations
$language_list = language_list();
foreach (array(
'pt-br',
'es',
) as $lang) {
$language = $language_list[$lang];
foreach ($strings[$lang] as $key => $value) {
$name = "test:string:{$key}:name";
$translation = i18nstrings($name, 'NOT FOUND', $lang);
$this
->assertEqual($translation, $value, "The right {$language->language} translation has been retrieved for {$name}, {$translation}");
}
}
}