function i18nstrings_refresh_group in Internationalization 6
Refresh all user defined strings for a given text group.
Parameters
$group: Text group to refresh
$delete: Optional, delete existing (but not refresed, strings and translations)
Return value
Boolean True if the strings have been refreshed successfully. False otherwise.
2 calls to i18nstrings_refresh_group()
- i18nstrings_admin_refresh_submit in i18nstrings/
i18nstrings.admin.inc - Form submission.
- i18n_Blocks_Test::testBlockTranslation in tests/
i18n_blocks.test
File
- i18nstrings/
i18nstrings.module, line 966 - Internationalization (i18n) package - translatable strings.
Code
function i18nstrings_refresh_group($group, $delete = FALSE) {
// Check for the refresh callback
$refresh_callback = i18nstrings_group_info($group, 'refresh callback');
if (!$refresh_callback) {
return FALSE;
}
// Delete data from i18n_strings so it is recreated
db_query("DELETE FROM {i18n_strings} WHERE lid IN (SELECT lid FROM {locales_source} WHERE textgroup = '%s')", $group);
$result = call_user_func($refresh_callback);
// Now delete all source strings that were not refreshed
if ($result && $delete) {
$result = db_query("SELECT s.* FROM {locales_source} s LEFT JOIN {i18n_strings} i ON s.lid = i.lid WHERE s.textgroup = '%s' AND i.lid IS NULL", $group);
while ($source = db_fetch_object($result)) {
db_query("DELETE FROM {locales_target} WHERE lid = %d", $source->lid);
db_query("DELETE FROM {locales_source} WHERE lid = %d", $source->lid);
}
}
cache_clear_all('locale:' . $group . ':', 'cache', TRUE);
return $result;
}