dolibarr 21.0.0-alpha
translation.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2007-2020 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2009-2017 Regis Houssin <regis.houssin@inodbox.com>
4 * Copyright (C) 2017 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
26// Load Dolibarr environment
27require '../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
31
32// Load translation files required by the page
33$langs->loadLangs(array("companies", "products", "admin", "sms", "other", "errors"));
34
35if (!$user->admin) {
37}
38
39$id = GETPOSTINT('rowid');
40$action = GETPOST('action', 'aZ09');
41$optioncss = GETPOST('optionscss', 'aZ09');
42$contextpage = GETPOST('contextpage', 'aZ09');
43
44$mode = GETPOST('mode', 'aZ09') ? GETPOST('mode', 'aZ09') : 'searchkey';
45
46$langcode = GETPOST('langcode', 'alphanohtml');
47$transkey = GETPOST('transkey', 'alphanohtml');
48if ($mode == 'searchkey') {
49 $transvalue = GETPOST('transvalue', 'alphanohtml');
50} else {
51 $transvalue = GETPOST('transvalue', 'restricthtml');
52}
53
54// Load variable for pagination
55$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
56$sortfield = GETPOST('sortfield', 'aZ09comma');
57$sortorder = GETPOST('sortorder', 'aZ09comma');
58$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
59if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
60 // If $page is not defined, or '' or -1 or if we click on clear filters
61 $page = 0;
62}
63$offset = $limit * $page;
64$pageprev = $page - 1;
65$pagenext = $page + 1;
66if (!$sortfield) {
67 $sortfield = 'lang,transkey';
68}
69if (!$sortorder) {
70 $sortorder = 'ASC,ASC';
71}
72
73// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
74$hookmanager->initHooks(array('admintranslation', 'globaladmin'));
75
76
77/*
78 * Actions
79 */
80
81if (GETPOST('cancel', 'alpha')) {
82 $action = 'list';
83 $massaction = '';
84}
85if (!GETPOST('confirmmassaction', 'alpha') && !empty($massaction) && $massaction != 'presend' && $massaction != 'confirm_presend') {
86 $massaction = '';
87}
88
89$parameters = array();
90$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
91if ($reshook < 0) {
92 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
93}
94
95include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
96
97// Purge search criteria
98if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
99 $transkey = '';
100 $transvalue = '';
101 $toselect = array();
102 $search_array_options = array();
103}
104
105if ($action == 'setMAIN_ENABLE_OVERWRITE_TRANSLATION') {
106 if (GETPOST('value')) {
107 dolibarr_set_const($db, 'MAIN_ENABLE_OVERWRITE_TRANSLATION', 1, 'chaine', 0, '', $conf->entity);
108 } else {
109 dolibarr_set_const($db, 'MAIN_ENABLE_OVERWRITE_TRANSLATION', 0, 'chaine', 0, '', $conf->entity);
110 }
111}
112
113if ($action == 'update') {
114 if ($transkey == '') {
115 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("TranslationKey")), null, 'errors');
116 $error++;
117 }
118 if ($transvalue == '') {
119 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NewTranslationStringToShow")), null, 'errors');
120 $error++;
121 }
122 if (!$error) {
123 $db->begin();
124
125 $sql = "UPDATE ".MAIN_DB_PREFIX."overwrite_trans set transkey = '".$db->escape($transkey)."', transvalue = '".$db->escape($transvalue)."' WHERE rowid = ".(GETPOSTINT('rowid'));
126 $result = $db->query($sql);
127 if ($result) {
128 $db->commit();
129 setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
130 $action = "";
131 $transkey = "";
132 $transvalue = "";
133 } else {
134 $db->rollback();
135 if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
136 setEventMessages($langs->trans("WarningAnEntryAlreadyExistForTransKey"), null, 'warnings');
137 } else {
138 setEventMessages($db->lasterror(), null, 'errors');
139 }
140 $action = '';
141 }
142 }
143}
144
145if ($action == 'add') {
146 $error = 0;
147
148 if (empty($langcode)) {
149 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Language")), null, 'errors');
150 $error++;
151 }
152 if ($transkey == '') {
153 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("TranslationKey")), null, 'errors');
154 $error++;
155 }
156 if ($transvalue == '') {
157 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NewTranslationStringToShow")), null, 'errors');
158 $error++;
159 }
160 if (!$error) {
161 $db->begin();
162
163 $sql = "INSERT INTO ".MAIN_DB_PREFIX."overwrite_trans(lang, transkey, transvalue, entity) VALUES ('".$db->escape($langcode)."','".$db->escape($transkey)."','".$db->escape($transvalue)."', ".((int) $conf->entity).")";
164 $result = $db->query($sql);
165 if ($result) {
166 $db->commit();
167 setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
168 $action = "";
169 $transkey = "";
170 $transvalue = "";
171 } else {
172 $db->rollback();
173 if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
174 setEventMessages($langs->trans("WarningAnEntryAlreadyExistForTransKey"), null, 'warnings');
175 } else {
176 setEventMessages($db->lasterror(), null, 'errors');
177 }
178 $action = '';
179 }
180 }
181}
182
183// Delete line from delete picto
184if ($action == 'delete') {
185 $sql = "DELETE FROM ".MAIN_DB_PREFIX."overwrite_trans WHERE rowid = ".((int) $id);
186 $result = $db->query($sql);
187 if ($result) {
188 setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
189 } else {
190 dol_print_error($db);
191 }
192}
193
194
195
196
197
198/*
199 * View
200 */
201
202$form = new Form($db);
203$formadmin = new FormAdmin($db);
204
205$wikihelp = 'EN:Setup_Translation|FR:Paramétrage_Traduction|ES:Configuración_Traducción';
206llxHeader('', $langs->trans("Setup"), $wikihelp, '', 0, 0, '', '', '', 'mod-admin page-translation');
207
208$param = '&mode='.urlencode($mode);
209
210$enabledisablehtml = '';
211$enabledisablehtml .= $langs->trans("EnableOverwriteTranslation").' ';
212if (!getDolGlobalString('MAIN_ENABLE_OVERWRITE_TRANSLATION')) {
213 // Button off, click to enable
214 $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_OVERWRITE_TRANSLATION&token='.newToken().'&value=1'.$param.'">';
215 $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
216 $enabledisablehtml .= '</a>';
217} else {
218 // Button on, click to disable
219 $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_OVERWRITE_TRANSLATION&token='.newToken().'&value=0'.$param.'">';
220 $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on');
221 $enabledisablehtml .= '</a>';
222}
223
224print load_fiche_titre($langs->trans("Translation"), $enabledisablehtml, 'title_setup');
225
226$current_language_code = $langs->defaultlang;
227$s = picto_from_langcode($current_language_code);
228print $form->textwithpicto('<span class="opacitymedium">'.$langs->trans("CurrentUserLanguage").':</span> <strong>'.$s.' '.$current_language_code.'</strong>', $langs->trans("TranslationDesc")).'</span><br>';
229
230print '<br>';
231
232if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
233 $param .= '&contextpage='.urlencode($contextpage);
234}
235if ($limit > 0 && $limit != $conf->liste_limit) {
236 $param .= '&limit='.((int) $limit);
237}
238if (isset($optioncss) && $optioncss != '') {
239 $param .= '&optioncss='.urlencode($optioncss);
240}
241if ($langcode) {
242 $param .= '&langcode='.urlencode($langcode);
243}
244if ($transkey) {
245 $param .= '&transkey='.urlencode($transkey);
246}
247if ($transvalue) {
248 $param .= '&transvalue='.urlencode($transvalue);
249}
250
251
252print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
253if (isset($optioncss) && $optioncss != '') {
254 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
255}
256print '<input type="hidden" name="token" value="'.newToken().'">';
257print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
258print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
259print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
260
262
263print dol_get_fiche_head($head, $mode, '', -1, '');
264
265
266$langcode = GETPOSTISSET('langcode') ? GETPOST('langcode') : $langs->defaultlang;
267
268$newlang = new Translate('', $conf);
269$newlang->setDefaultLang($langcode);
270
271$langsenfileonly = new Translate('', $conf);
272$langsenfileonly->setDefaultLang('en_US');
273
274$newlangfileonly = new Translate('', $conf);
275$newlangfileonly->setDefaultLang($langcode);
276
277$recordtoshow = array();
278
279// Search modules dirs
280$modulesdir = dolGetModulesDirs();
281
282$listoffiles = array();
283$listoffilesexternalmodules = array();
284
285// Search into dir of modules (the $modulesdir is already a list that loop on $conf->file->dol_document_root)
286$i = 0;
287foreach ($modulesdir as $keydir => $tmpsearchdir) {
288 $searchdir = $tmpsearchdir; // $searchdir can be '.../htdocs/core/modules/' or '.../htdocs/custom/mymodule/core/modules/'
289
290 // Directory of translation files
291 $dir_lang = dirname(dirname($searchdir))."/langs/".$langcode; // The 2 dirname is to go up in dir for 2 levels
292 $dir_lang_osencoded = dol_osencode($dir_lang);
293
294 $filearray = dol_dir_list($dir_lang_osencoded, 'files', 0, '', '', "name", SORT_ASC, 1);
295
296 foreach ($filearray as $file) {
297 $tmpfile = preg_replace('/.lang/i', '', basename($file['name']));
298 $moduledirname = (basename(dirname(dirname($dir_lang))));
299
300 $langkey = $tmpfile;
301 if ($i > 0) {
302 $langkey .= '@'.$moduledirname;
303 }
304 //var_dump($i.' - '.$keydir.' - '.$dir_lang_osencoded.' -> '.$moduledirname . ' / ' . $tmpfile.' -> '.$langkey);
305
306 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
307 $result = $newlang->load($langkey, 0, 0, '', 0); // Load translation files + database overwrite
308 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
309 $result = $newlangfileonly->load($langkey, 0, 0, '', 1); // Load translation files only
310 if ($result < 0) {
311 print 'Failed to load language file '.$tmpfile.'<br>'."\n";
312 } else {
313 $listoffiles[$langkey] = $tmpfile;
314 if (strpos($langkey, '@') !== false) {
315 $listoffilesexternalmodules[$langkey] = $tmpfile;
316 }
317 }
318 //print 'After loading lang '.$langkey.', newlang has '.count($newlang->tab_translate).' records<br>'."\n";
319
320 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
321 $result = $langsenfileonly->load($langkey, 0, 0, '', 1); // Load translation files only
322 }
323 $i++;
324}
325
326$nbtotaloffiles = count($listoffiles);
327$nbtotaloffilesexternal = count($listoffilesexternalmodules);
328
329if ($mode == 'overwrite') {
330 print '<input type="hidden" name="page" value="'.$page.'">';
331
332 $disabled = '';
333 if ($action == 'edit' || !getDolGlobalString('MAIN_ENABLE_OVERWRITE_TRANSLATION')) {
334 $disabled = ' disabled="disabled"';
335 }
336 $disablededit = '';
337 if ($action == 'edit' || !getDolGlobalString('MAIN_ENABLE_OVERWRITE_TRANSLATION')) {
338 $disablededit = ' disabled';
339 }
340
341 print '<div class="justify"><span class="opacitymedium">';
342 print img_info().' '.$langs->trans("SomeTranslationAreUncomplete");
343 $urlwikitranslatordoc = 'https://wiki.dolibarr.org/index.php/Translator_documentation';
344 print ' ('.str_replace('{s1}', '<a href="'.$urlwikitranslatordoc.'" target="_blank" rel="noopener noreferrer external">'.$langs->trans("Here").'</a>', $langs->trans("SeeAlso", '{s1}')).')<br>';
345 print $langs->trans("TranslationOverwriteDesc", $langs->transnoentitiesnoconv("Language"), $langs->transnoentitiesnoconv("TranslationKey"), $langs->transnoentitiesnoconv("NewTranslationStringToShow"))."\n";
346 print ' ('.$langs->trans("TranslationOverwriteDesc2").').'."<br>\n";
347 print '</span></div>';
348
349 print '<br>';
350
351
352 print '<input type="hidden" name="action" value="'.($action == 'edit' ? 'update' : 'add').'">';
353 print '<input type="hidden" id="mode" name="mode" value="'.$mode.'">';
354
355 print '<div class="div-table-responsive-no-min">';
356 print '<table class="noborder centpercent">';
357 print '<tr class="liste_titre">';
358 print_liste_field_titre("Language_en_US_es_MX_etc", $_SERVER["PHP_SELF"], 'lang,transkey', '', $param, '', $sortfield, $sortorder);
359 print_liste_field_titre("TranslationKey", $_SERVER["PHP_SELF"], 'transkey', '', $param, '', $sortfield, $sortorder);
360 print_liste_field_titre("NewTranslationStringToShow", $_SERVER["PHP_SELF"], 'transvalue', '', $param, '', $sortfield, $sortorder);
361 //if (isModEnabled('multicompany') && !$user->entity) print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,transkey', '', $param, '', $sortfield, $sortorder);
362 print '<td align="center"></td>';
363 print "</tr>\n";
364
365
366 // Line to add new record
367 print "\n";
368
369 print '<tr class="oddeven"><td>';
370 print $formadmin->select_language(GETPOST('langcode'), 'langcode', 0, null, 1, 0, $disablededit ? 1 : 0, 'maxwidth250', 1);
371 print '</td>'."\n";
372 print '<td>';
373 print '<input type="text" class="flat maxwidthonsmartphone"'.$disablededit.' name="transkey" id="transkey" value="'.(!empty($transkey) ? $transkey : "").'">';
374 print '</td><td>';
375 print '<input type="text" class="quatrevingtpercent"'.$disablededit.' name="transvalue" id="transvalue" value="'.(!empty($transvalue) ? $transvalue : "").'">';
376 print '</td>';
377 print '<td class="center">';
378 print '<input type="hidden" name="entity" value="'.$conf->entity.'">';
379 print '<input type="submit" class="button"'.$disabled.' value="'.$langs->trans("Add").'" name="add" title="'.dol_escape_htmltag($langs->trans("YouMustEnableTranslationOverwriteBefore")).'">';
380 print "</td>\n";
381 print '</tr>';
382
383
384 // Show constants
385 $sql = "SELECT rowid, entity, lang, transkey, transvalue";
386 $sql .= " FROM ".MAIN_DB_PREFIX."overwrite_trans";
387 $sql .= " WHERE 1 = 1";
388 $sql .= " AND entity IN (".getEntity('overwrite_trans').")";
389 $sql .= $db->order($sortfield, $sortorder);
390
391 dol_syslog("translation::select from table", LOG_DEBUG);
392 $result = $db->query($sql);
393 if ($result) {
394 $num = $db->num_rows($result);
395 $i = 0;
396
397 while ($i < $num) {
398 $obj = $db->fetch_object($result);
399
400 print "\n";
401
402 print '<tr class="oddeven">';
403
404 print '<td>'.dol_escape_htmltag($obj->lang).'</td>'."\n";
405 print '<td>';
406 if ($action == 'edit' && $obj->rowid == GETPOSTINT('rowid')) {
407 print '<input type="text" class="quatrevingtpercent" name="transkey" value="'.dol_escape_htmltag($obj->transkey).'">';
408 } else {
409 print dol_escape_htmltag($obj->transkey);
410 }
411 print '</td>'."\n";
412
413 // Value
414 print '<td class="small">';
415 /*print '<input type="hidden" name="const['.$i.'][rowid]" value="'.$obj->rowid.'">';
416 print '<input type="hidden" name="const['.$i.'][lang]" value="'.$obj->lang.'">';
417 print '<input type="hidden" name="const['.$i.'][name]" value="'.$obj->transkey.'">';
418 print '<input type="text" id="value_'.$i.'" class="flat inputforupdate" size="30" name="const['.$i.'][value]" value="'.dol_escape_htmltag($obj->transvalue).'">';
419 */
420 if ($action == 'edit' && $obj->rowid == GETPOSTINT('rowid')) {
421 print '<input type="text" class="quatrevingtpercent" name="transvalue" value="'.dol_escape_htmltag($obj->transvalue).'">';
422 } else {
423 //print $obj->transkey.' '.$langsenfileonly->tab_translate[$obj->transkey];
424 $titleforvalue = $langs->trans("Translation").' en_US for key '.$obj->transkey.':<br>'.(!empty($langsenfileonly->tab_translate[$obj->transkey]) ? $langsenfileonly->trans($obj->transkey) : '<span class="opacitymedium">'.$langs->trans("None").'</span>');
425 /*if ($obj->lang != 'en_US') {
426 $titleforvalue .= '<br>'.$langs->trans("Translation").' '.$obj->lang.' '...;
427 }*/
428 print '<span title="'.dol_escape_htmltag($titleforvalue).'" class="classfortooltip">';
429 print dol_escape_htmltag($obj->transvalue);
430 print '</span>';
431 }
432 print '</td>';
433
434 print '<td class="center">';
435 if ($action == 'edit' && $obj->rowid == GETPOSTINT('rowid')) {
436 print '<input type="hidden" class="button" name="rowid" value="'.$obj->rowid.'">';
437 print '<input type="submit" class="button buttongen button-save" name="save" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
438 print ' &nbsp; ';
439 print '<input type="submit" class="button buttongen button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
440 } else {
441 print '<a class="reposition editfielda paddingrightonly" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&mode='.urlencode($mode).'&action=edit&token='.newToken().'">'.img_edit().'</a>';
442 print ' &nbsp; ';
443 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&mode='.urlencode($mode).'&action=delete&token='.newToken().'">'.img_delete().'</a>';
444 }
445 print '</td>';
446
447 print "</tr>\n";
448 print "\n";
449 $i++;
450 }
451 }
452
453 print '</table>';
454 print '</div>';
455}
456
457if ($mode == 'searchkey') {
458 $nbempty = 0;
459 //var_dump($langcode);
460 //var_dump($transkey);
461 //var_dump($transvalue);
462 if (empty($langcode) || $langcode == '-1') {
463 $nbempty++;
464 }
465 if (empty($transkey)) {
466 $nbempty++;
467 }
468 if (empty($transvalue)) {
469 $nbempty++;
470 }
471
472 if ($action == 'search' && ($nbempty > 999)) { // 999 to disable this
473 setEventMessages($langs->trans("WarningAtLeastKeyOrTranslationRequired"), null, 'warnings');
474 } else {
475 // Now search into translation array
476 foreach ($newlang->tab_translate as $key => $val) {
477 $newtranskey = preg_replace('/\$$/', '', preg_replace('/^\^/', '', $transkey));
478 $newtranskeystart = preg_match('/^\^/', $transkey);
479 $newtranskeyend = preg_match('/\$$/', $transkey);
480 $regexstring = ($newtranskeystart ? '^' : '').preg_quote($newtranskey, '/').($newtranskeyend ? '$' : '');
481 if ($transkey && !preg_match('/'.$regexstring.'/i', $key)) {
482 continue;
483 }
484 if ($transvalue && !preg_match('/'.preg_quote($transvalue, '/').'/i', $val)) {
485 continue;
486 }
487 $recordtoshow[$key] = $val;
488 }
489 }
490
491 //print '<br>';
492 $nbtotalofrecordswithoutfilters = count($newlang->tab_translate);
493 $nbtotalofrecords = count($recordtoshow);
494 $num = $limit + 1;
495 if (($offset + $num) > $nbtotalofrecords) {
496 $num = $limit;
497 }
498
499 //print 'param='.$param.' $_SERVER["PHP_SELF"]='.$_SERVER["PHP_SELF"].' num='.$num.' page='.$page.' nbtotalofrecords='.$nbtotalofrecords." sortfield=".$sortfield." sortorder=".$sortorder;
500 $title = $langs->trans("Translation");
501 if ($nbtotalofrecords > 0) {
502 $title .= ' <span class="opacitymedium colorblack paddingleft">('.$nbtotalofrecords.' / '.$nbtotalofrecordswithoutfilters.' - <span title="'.dol_escape_htmltag(($nbtotaloffiles - $nbtotaloffilesexternal).' core - '.($nbtotaloffilesexternal).' external').'">'.$nbtotaloffiles.' '.$langs->trans("Files").'</span>)</span>';
503 }
504 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, -1 * $nbtotalofrecords, '', 0, '', '', $limit, 0, 0, 1);
505
506 $massactionbutton = '';
507
508 print '<input type="hidden" id="action" name="action" value="search">';
509 print '<input type="hidden" id="mode" name="mode" value="'.$mode.'">';
510
511 print '<div class="div-table-responsive-no-min">';
512 print '<table class="noborder centpercent">';
513
514 print '<tr class="liste_titre_filter"><td>';
515 //print $formadmin->select_language($langcode,'langcode',0,null,$langs->trans("All"),0,0,'',1);
516 print $formadmin->select_language($langcode, 'langcode', 0, null, 0, 0, 0, 'maxwidth250', 1);
517 print '</td>'."\n";
518 print '<td>';
519 print '<input type="text" class="flat maxwidthonsmartphone" name="transkey" value="'.dol_escape_htmltag($transkey).'">';
520 print '</td><td>';
521 print '<input type="text" class="quatrevingtpercent" name="transvalue" value="'.dol_escape_htmltag($transvalue).'">';
522 // Limit to superadmin
523 /*if (isModEnabled('multicompany') && !$user->entity)
524 {
525 print '</td><td>';
526 print '<input type="text" class="flat" size="1" name="entitysearch" value="'.$conf->entity.'">';
527 }
528 else
529 {*/
530 print '<input type="hidden" name="entitysearch" value="'.$conf->entity.'">';
531 //}
532 print '</td>';
533 // Action column
534 print '<td class="right nowraponall">';
535 $searchpicto = $form->showFilterAndCheckAddButtons(!empty($massactionbutton) ? 1 : 0, 'checkforselect', 1);
536 print $searchpicto;
537 print '</td>';
538 print '</tr>';
539
540 print '<tr class="liste_titre">';
541 print_liste_field_titre("Language_en_US_es_MX_etc", $_SERVER["PHP_SELF"], 'lang,transkey', '', $param, '', $sortfield, $sortorder);
542 print_liste_field_titre("TranslationKey", $_SERVER["PHP_SELF"], 'transkey', '', $param, '', $sortfield, $sortorder);
543 print_liste_field_titre("CurrentTranslationString", $_SERVER["PHP_SELF"], 'transvalue', '', $param, '', $sortfield, $sortorder);
544 //if (isModEnabled('multicompany') && !$user->entity) print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,transkey', '', $param, '', $sortfield, $sortorder);
545 print '<td align="center"></td>';
546 print "</tr>\n";
547
548
549 if ($sortfield == 'transkey' && strtolower($sortorder) == 'asc') {
550 ksort($recordtoshow);
551 }
552 if ($sortfield == 'transkey' && strtolower($sortorder) == 'desc') {
553 krsort($recordtoshow);
554 }
555 if ($sortfield == 'transvalue' && strtolower($sortorder) == 'asc') {
556 asort($recordtoshow);
557 }
558 if ($sortfield == 'transvalue' && strtolower($sortorder) == 'desc') {
559 arsort($recordtoshow);
560 }
561
562 // Show result
563 $i = 0;
564 foreach ($recordtoshow as $key => $val) {
565 $i++;
566 if ($i <= $offset) {
567 continue;
568 }
569 if ($limit && $i > ($offset + $limit)) {
570 break;
571 }
572 print '<tr class="oddeven"><td>'.$langcode.'</td><td>'.$key.'</td>';
573 print '<td class="small">';
574 $titleforvalue = $langs->trans("Translation").' en_US for key '.$key.':<br>';
575 if (!empty($langsenfileonly->tab_translate[$key])) {
576 if (substr_count($langsenfileonly->tab_translate[$key], '%s') <= 4) { // To avoid errors when more than 4 %s.
577 $titleforvalue .= $langsenfileonly->trans($key);
578 }
579 } else {
580 $titleforvalue .= '<span class="opacitymedium">'.$langs->trans("None").'</span>';
581 }
582 print '<span title="'.dolPrintHTMLForAttribute($titleforvalue).'" class="classfortooltip">';
583 print dolPrintHTML($val);
584 if (substr_count($langsenfileonly->tab_translate[$key], '%s') > 4) {
585 print '<br><div class="warning">Error, more than 4 %s in the source</div>';
586 }
587 print '</span>';
588 print '</td>';
589 print '<td class="right nowraponall">';
590 if (!empty($newlangfileonly->tab_translate[$key])) {
591 if ($val != $newlangfileonly->tab_translate[$key]) {
592 // retrieve rowid
593 $sql = "SELECT rowid";
594 $sql .= " FROM ".MAIN_DB_PREFIX."overwrite_trans";
595 $sql .= " WHERE entity IN (".getEntity('overwrite_trans').")";
596 $sql .= " AND transkey = '".$db->escape($key)."'";
597 dol_syslog("translation::select from table", LOG_DEBUG);
598 $result = $db->query($sql);
599 if ($result) {
600 $obj = $db->fetch_object($result);
601 }
602 print '<a class="editfielda reposition marginrightonly" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$conf->entity.'&mode=overwrite&action=edit&token='.newToken().'">'.img_edit().'</a>';
603 print ' ';
604 print '<a class="marginleftonly marginrightonly" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$conf->entity.'&mode='.urlencode($mode).'&action=delete&token='.newToken().'&mode='.urlencode($mode).'">'.img_delete().'</a>';
605 print '&nbsp;&nbsp;';
606 $htmltext = $langs->trans("OriginalValueWas", '<i>'.$newlangfileonly->tab_translate[$key].'</i>');
607 print $form->textwithpicto('', $htmltext, 1, 'info');
608 } elseif (getDolGlobalString('MAIN_ENABLE_OVERWRITE_TRANSLATION')) {
609 //print $key.'-'.$val;
610 print '<a class="reposition paddingrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=overwrite&langcode='.urlencode($langcode).'&transkey='.urlencode($key).'">'.img_edit_add($langs->trans("TranslationOverwriteKey")).'</a>';
611 }
612
613 if (getDolGlobalInt('MAIN_FEATURES_LEVEL')) {
614 $transifexlangfile = '$'; // $ means 'All'
615 //$transifexurl = 'https://www.transifex.com/dolibarr-association/dolibarr/translate/#'.$langcode.'/'.$transifexlangfile.'?key='.$key;
616 $transifexurl = 'https://www.transifex.com/dolibarr-association/dolibarr/translate/#'.$langcode.'/'.$transifexlangfile.'?q=key%3A'.$key;
617
618 print ' &nbsp; <a href="'.$transifexurl.'" target="transifex">'.img_picto($langs->trans('FixOnTransifex'), 'globe').'</a>';
619 }
620 } else {
621 // retrieve rowid
622 $sql = "SELECT rowid";
623 $sql .= " FROM ".MAIN_DB_PREFIX."overwrite_trans";
624 $sql .= " WHERE entity IN (".getEntity('overwrite_trans').")";
625 $sql .= " AND transkey = '".$db->escape($key)."'";
626 dol_syslog("translation::select from table", LOG_DEBUG);
627 $result = $db->query($sql);
628 if ($result) {
629 $obj = $db->fetch_object($result);
630 }
631 print '<a class="editfielda reposition marginrightonly" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$conf->entity.'&mode=overwrite&action=edit&token='.newToken().'">'.img_edit().'</a>';
632 print ' ';
633 print '<a class="marginleftonly marginrightonly" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$conf->entity.'&mode='.urlencode($mode).'&action=delete&token='.newToken().'&mode='.urlencode($mode).'">'.img_delete().'</a>';
634 print '&nbsp;&nbsp;';
635
636 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
637 $htmltext = $langs->trans("TransKeyWithoutOriginalValue", $key);
638 print $form->textwithpicto('', $htmltext, 1, 'warning');
639 }
640 /*if (isModEnabled('multicompany') && !$user->entity)
641 {
642 print '<td>'.$val.'</td>';
643 }*/
644 print '</td></tr>'."\n";
645 }
646
647 if (empty($recordtoshow)) {
648 print '<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
649 }
650
651 print '</table>';
652 print '</div>';
653}
654
655print dol_get_fiche_end();
656
657print "</form>\n";
658
659if (!empty($langcode)) {
660 dol_set_focus('#transvalue');
661}
662
663// End of page
664llxFooter();
665$db->close();
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
translation_prepare_head()
Prepare array with list of tabs.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:70
Class to generate html code for admin pages.
Class to manage generation of HTML components Only common components must be here.
Class to manage translations.
llxFooter()
Footer empty.
Definition document.php:107
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:63
dolGetModulesDirs($subdir='')
Return list of directories that contain modules.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dolPrintHTML($s, $allowiframe=0)
Return a string (that can be on several lines) ready to be output on a HTML page.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_edit_add($titlealt='default', $other='')
Show logo +.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
img_info($titlealt='default')
Show info logo.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.