NEW Can disable all overwrote translations in one click.

This commit is contained in:
Laurent Destailleur 2017-05-09 10:08:04 +02:00
parent 05d6c2cd75
commit 9fe28c9b2c
4 changed files with 34 additions and 2 deletions

View File

@ -79,6 +79,12 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP
$search_array_options=array();
}
if ($action == 'setMAIN_ENABLE_OVERWRITE_TRANSLATION')
{
if (GETPOST('value')) dolibarr_set_const($db, 'MAIN_ENABLE_OVERWRITE_TRANSLATION', 1, 'chaine', 0, '', $conf->entity);
else dolibarr_set_const($db, 'MAIN_ENABLE_OVERWRITE_TRANSLATION', 0, 'chaine', 0, '', $conf->entity);
}
if ($action == 'add' || (GETPOST('add') && $action != 'update'))
{
$error=0;
@ -169,6 +175,24 @@ print $langs->trans("CurrentUserLanguage").': <strong>'.$s.' '.$current_language
print '<br>';
print $langs->trans("EnableOverwriteTranslation").' ';
if (empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION))
{
// Button off, click to enable
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_OVERWRITE_TRANSLATION&amp;value=1">';
print img_picto($langs->trans("Disabled"),'switch_off');
print '</a>';
}
else
{
// Button on, click to disable
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_OVERWRITE_TRANSLATION&amp;value=0">';
print img_picto($langs->trans("Activated"),'switch_on');
print '</a>';
}
print '<br><br>';
$param='&mode='.$mode;
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;

View File

@ -297,7 +297,12 @@ class Translate
$tabtranslatedomain[$key] = $value;
}
}
} else {
}
elseif ($key[0] == '#')
{
continue;
}
else {
$this->tab_translate[$key] = $value;
//if ($domain == 'orders') print "$tab[0] value $value<br>";
if ($usecachekey) {
@ -459,7 +464,7 @@ class Translate
}
}
if (! $found)
if (! $found && ! empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION))
{
// Overwrite translation with database read
$sql="SELECT transkey, transvalue FROM ".MAIN_DB_PREFIX."overwrite_trans where lang='".$this->defaultlang."'";

View File

@ -158,6 +158,8 @@ INSERT INTO llx_const (name, entity, value, type, visible, note) VALUES ('CONTRA
INSERT INTO llx_const (name, entity, value, type, visible, note) VALUES ('USERGROUP_ADDON_PDF_ODT_PATH', 1, 'DOL_DATA_ROOT/doctemplates/usergroups', 'chaine', 0, '');
INSERT INTO llx_const (name, entity, value, type, visible, note) VALUES ('USER_ADDON_PDF_ODT_PATH', 1, 'DOL_DATA_ROOT/doctemplates/users', 'chaine', 0, '');
INSERT INTO llx_const (name, entity, value, type, visible, note) VALUES ('MAIN_ENABLE_OVERWRITE_TRANSLATION', 1, '1', 'chaine', 0, 'Enable overwrote of translation');
ALTER TABLE llx_chargesociales ADD COLUMN ref varchar(16);
ALTER TABLE llx_chargesociales ADD COLUMN fk_projet integer DEFAULT NULL;

View File

@ -434,6 +434,7 @@ PageUrlForDefaultValues=You must enter here the relative url of the page. If you
PageUrlForDefaultValuesCreate=<br>For form to create a new thirdparty, it is <strong>%s</strong>
PageUrlForDefaultValuesList=<br>For page that list thirdparties, it is <strong>%s</strong>
EnableDefaultValues=Enable usage of personalized default values
EnableOverwriteTranslation=Enable usage of overwrote translation
GoIntoTranslationMenuToChangeThis=A translation has been found for the key with this code, so to change this value, you must edit it fom Home-Setup-translation.
WarningSettingSortOrder=Warning, setting a default sort order may result in a technical error when going on the list page if field is an unknown field. If you experience such an error, come back to this page to remove the default sort order and restore default behavior.
Field=Field