'mode'=>'Determine if existing translations are overwitten during import. Use "overwrite" to overwrite any existing translation, "replace" to replace previously imported translations but not overwrite edited strings, "keep" to keep any existing translation and only add new translations. Default value: keep'
),
);
return$commands;
...
...
@@ -102,8 +102,8 @@ function drush_l10n_update_validate() {
// Check provided update mode is valid.
$mode=drush_get_option('mode','keep');
if(!in_array($mode,array('keep','overwrite'))){
returndrush_set_error('L10N_UPDATE_INVALID_MODE',dt('Invalid update mode. Valid options are keep, overwrite.'));
// File not found occurs when a translation file is not yet available
// at the translation server. But also if a custom module or custom
// theme does not define the location of a translation file. By default
// the file is checked at the translation server, but it will not be
// found there.
watchdog('l10n_update','File not found: @uri.',array('@uri'=>$url));
returnTRUE;
case0:
watchdog('l10n_update','Error occurred when trying to check @remote: @errormessage.',array('@errormessage'=>$result->error,'@remote'=>$url),WATCHDOG_ERROR);
break;
default:
watchdog('l10n_update','HTTP error @errorcode occurred when trying to check @remote.',array('@errorcode'=>$result->code,'@remote'=>$url),WATCHDOG_ERROR);
break;
}
}
return$result;
}
...
...
@@ -297,7 +318,8 @@ function l10n_update_http_check($url, $headers = array()) {
* received.
* - redirect_code: If redirected, an integer containing the initial response
* status code.
* - redirect_url: If redirected, a string containing the redirection location.
* - redirect_url: If redirected, a string containing the URL of the redirect
* target.
* - error: If an error occurred, the error message. Otherwise not set.
* - headers: An array containing the response headers as name/value pairs.
* HTTP header names are case-insensitive (RFC 2616, section 4.2), so for
drupal_set_message(t('The translation file %filename appears to have a missing or malformed header.',array('%filename'=>$file->filename)),'error');
}
// Clear cache and force refresh of JavaScript translations.
_locale_invalidate_js($langcode);
cache_clear_all('locale:','cache',TRUE);
// Rebuild the menu, strings may have changed.
menu_rebuild();
watchdog('locale','Imported %file into %locale: %number new strings added, %update updated and %delete removed.',array('%file'=>$file->filename,'%locale'=>$langcode,'%number'=>$additions,'%update'=>$updates,'%delete'=>$deletes));
if($skips){
watchdog('locale','@count disallowed HTML string(s) in %file',array('@count'=>$skips,'%file'=>$file->uri),WATCHDOG_WARNING);
$translation=db_query("SELECT translation FROM {locales_target} WHERE lid = :lid AND language = :language",array(':lid'=>$lid,':language'=>$key))->fetchField();
if(!empty($value)){
// Only update or insert if we have a value to use.
if(!empty($translation)){
db_update('locales_target')
->fields(array(
'translation'=>$value,
'l10n_status'=>L10N_UPDATE_STRING_CUSTOM,
))
->condition('lid',$lid)
->condition('language',$key)
->execute();
}
else{
db_insert('locales_target')
->fields(array(
'lid'=>$lid,
'translation'=>$value,
'language'=>$key,
'l10n_status'=>L10N_UPDATE_STRING_CUSTOM,
))
->execute();
}
}
elseif(!empty($translation)){
// Empty translation entered: remove existing entry from database.
@@ -246,7 +238,7 @@ function l10n_update_client_save_string() {
// Ensure we have this source string before we attempt to save it.
// @todo: add actual context support.
$lid=db_query("SELECT lid FROM {locales_source} WHERE source = :source AND context = :context AND textgroup = :textgroup",array(':source'=>$_POST['source'],':context'=>'',':textgroup'=>$_POST['textgroup']))->fetchField();