_locale_import_po
- Versions
- 4.6 – 5
_locale_import_po($file,$lang, $mode)- 6 – 7
_locale_import_po($file, $langcode, $mode, $group = NULL)
Parses Gettext Portable Object file information and inserts into database
Parameters
$file Object contains properties of local file to be imported
$lang Language code
$mode should existing translations be replaced?
Code
includes/locale.inc, line 448
<?php
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($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('report', $mode);
if (!$headerdone) {
drupal_set_message(t('The translation file %filename appears to have a missing or malformed header.', array('%filename' => theme('placeholder', $file->filename))), 'error');
}
// rebuild locale cache
cache_clear_all("locale:$lang");
// 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' => theme('placeholder', $file->filename), '%locale' => theme('placeholder', $lang), '%number' => $additions, '%update' => $updates)));
return TRUE;
}
?>Login or register to post comments 