From 9fe28c9b2cd770a064f628cc2e298361e3a395c7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 9 May 2017 10:08:04 +0200 Subject: [PATCH] NEW Can disable all overwrote translations in one click. --- htdocs/admin/translation.php | 24 +++++++++++++++++++ htdocs/core/class/translate.class.php | 9 +++++-- .../install/mysql/migration/5.0.0-6.0.0.sql | 2 ++ htdocs/langs/en_US/admin.lang | 1 + 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index 75f151d45b9..c51d1c2435d 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -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").': '.$s.' '.$current_language print '
'; +print $langs->trans("EnableOverwriteTranslation").' '; +if (empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) +{ + // Button off, click to enable + print ''; + print img_picto($langs->trans("Disabled"),'switch_off'); + print ''; +} +else +{ + // Button on, click to disable + print ''; + print img_picto($langs->trans("Activated"),'switch_on'); + print ''; +} + +print '

'; + $param='&mode='.$mode; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 0f2e6a837ef..88b001ba093 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -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
"; 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."'"; diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index d96210dcbfe..d2431186ed7 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -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; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 5fd5cb57c8b..71e5b614abb 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -434,6 +434,7 @@ PageUrlForDefaultValues=You must enter here the relative url of the page. If you PageUrlForDefaultValuesCreate=
For form to create a new thirdparty, it is %s PageUrlForDefaultValuesList=
For page that list thirdparties, it is %s 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