function _locale_import_po in Drupal 5
Same name and namespace in other branches
- 4 includes/locale.inc \_locale_import_po()
- 6 includes/locale.inc \_locale_import_po()
- 7 includes/locale.inc \_locale_import_po()
Parses Gettext Portable Object file information and inserts into database
Parameters
$file: Drupal file object corresponding to the PO file to import
$lang: Language code
$mode: Should existing translations be replaced ('overwrite' or 'keep')
1 call to _locale_import_po()
- _locale_admin_import_submit in includes/
locale.inc - Process the locale import form submission.
File
- includes/
locale.inc, line 491 - Admin-related functions for locale.module.
Code
function _locale_import_po($file, $lang, $mode) {
// If not in 'safe mode', increase the maximum execution time:
if (!ini_get('safe_mode')) {
set_time_limit(240);
}
// Check if we have the language already in the database
if (!db_fetch_object(db_query("SELECT locale FROM {locales_meta} WHERE locale = '%s'", $lang))) {
drupal_set_message(t('The language selected for import is not supported.'), 'error');
return FALSE;
}
// Get strings from file (returns on failure after a partial import, or on success)
$status = _locale_import_read_po('db-store', $file, $mode, $lang);
if ($status === FALSE) {
// error messages are set in _locale_import_read_po
return FALSE;
}
// Get status information on import process
list($headerdone, $additions, $updates) = _locale_import_one_string('db-report');
if (!$headerdone) {
drupal_set_message(t('The translation file %filename appears to have a missing or malformed header.', array(
'%filename' => $file->filename,
)), 'error');
}
// rebuild locale cache
cache_clear_all("locale:{$lang}", 'cache');
// rebuild the menu, strings may have changed
menu_rebuild();
drupal_set_message(t('The translation was successfully imported. There are %number newly created translated strings and %update strings were updated.', array(
'%number' => $additions,
'%update' => $updates,
)));
watchdog('locale', t('Imported %file into %locale: %number new strings added and %update updated.', array(
'%file' => $file->filename,
'%locale' => $lang,
'%number' => $additions,
'%update' => $updates,
)));
return TRUE;
}