_locale_import_po
includes/locale.inc, строка 464
- Версии
- 5
_locale_import_po($file,
$lang, $mode)- 6
_locale_import_po($file, $langcode, $mode, $group = NULL)
Parses Gettext Portable Object file information and inserts into database
Параметры
$file
Drupal file object corresponding to the PO file to import
$lang
Language code
$mode
Should existing translations be replaced ('overwrite'
or 'keep'
)
Код
<?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('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;
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии