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 ($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 '<br>';
346 print $langs->trans("TranslationOverwriteDesc", $langs->transnoentitiesnoconv("Language"), $langs->transnoentitiesnoconv("TranslationKey"), $langs->transnoentitiesnoconv("NewTranslationStringToShow"))."\n";
347 print ' ('.$langs->trans("TranslationOverwriteDesc2").').'."<br>\n";
348 print '</span></div>';
349
350 print '<br>';
351
352
353 print '<input type="hidden" name="action" value="'.($action == 'edit' ? 'update' : 'add').'">';
354 print '<input type="hidden" id="mode" name="mode" value="'.$mode.'">';
355
356 print '<div class="div-table-responsive-no-min">';
357 print '<table class="noborder centpercent">';
358 print '<tr class="liste_titre">';
359 print_liste_field_titre("Language_en_US_es_MX_etc", $_SERVER["PHP_SELF"], 'lang,transkey', '', $param, '', $sortfield, $sortorder);
360 print_liste_field_titre("TranslationKey", $_SERVER["PHP_SELF"], 'transkey', '', $param, '', $sortfield, $sortorder);
361 print_liste_field_titre("NewTranslationStringToShow", $_SERVER["PHP_SELF"], 'transvalue', '', $param, '', $sortfield, $sortorder);
362 //if (isModEnabled('multicompany') && !$user->entity) print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,transkey', '', $param, '', $sortfield, $sortorder);
363 print '<td align="center"></td>';
364 print "</tr>\n";
365
366
367 // Line to add new record
368 print "\n";
369
370 print '<tr class="oddeven"><td>';
371 print $formadmin->select_language(GETPOST('langcode'), 'langcode', 0, array(), 1, 0, $disablededit ? 1 : 0, 'maxwidth250', 1);
372 print '</td>'."\n";
373 print '<td>';
374 print '<input type="text" class="flat maxwidthonsmartphone"'.$disablededit.' name="transkey" id="transkey" value="'.(!empty($transkey) ? $transkey : "").'">';
375 print '</td><td>';
376 print '<input type="text" class="quatrevingtpercent"'.$disablededit.' name="transvalue" id="transvalue" value="'.(!empty($transvalue) ? $transvalue : "").'">';
377 print '</td>';
378 print '<td class="center">';
379 print '<input type="hidden" name="entity" value="'.$conf->entity.'">';
380 print '<input type="submit" class="button"'.$disabled.' value="'.$langs->trans("Add").'" name="add" title="'.dol_escape_htmltag($langs->trans("YouMustEnableTranslationOverwriteBefore")).'">';
381 print "</td>\n";
382 print '</tr>';
383
384
385 // Show constants
386 $sql = "SELECT rowid, entity, lang, transkey, transvalue";
387 $sql .= " FROM ".MAIN_DB_PREFIX."overwrite_trans";
388 $sql .= " WHERE 1 = 1";
389 $sql .= " AND entity IN (".getEntity('overwrite_trans').")";
390 $sql .= $db->order($sortfield, $sortorder);
391
392 dol_syslog("translation::select from table", LOG_DEBUG);
393 $result = $db->query($sql);
394 if ($result) {
395 $num = $db->num_rows($result);
396 $i = 0;
397
398 while ($i < $num) {
399 $obj = $db->fetch_object($result);
400
401 print "\n";
402
403 print '<tr class="oddeven">';
404
405 print '<td>'.dol_escape_htmltag($obj->lang).'</td>'."\n";
406 print '<td>';
407 if ($action == 'edit' && $obj->rowid == GETPOSTINT('rowid')) {
408 print '<input type="text" class="quatrevingtpercent" name="transkey" value="'.dol_escape_htmltag($obj->transkey).'">';
409 } else {
410 print dol_escape_htmltag($obj->transkey);
411 }
412 print '</td>'."\n";
413
414 // Value
415 print '<td class="small">';
416 /*print '<input type="hidden" name="const['.$i.'][rowid]" value="'.$obj->rowid.'">';
417 print '<input type="hidden" name="const['.$i.'][lang]" value="'.$obj->lang.'">';
418 print '<input type="hidden" name="const['.$i.'][name]" value="'.$obj->transkey.'">';
419 print '<input type="text" id="value_'.$i.'" class="flat inputforupdate" size="30" name="const['.$i.'][value]" value="'.dol_escape_htmltag($obj->transvalue).'">';
420 */
421 if ($action == 'edit' && $obj->rowid == GETPOSTINT('rowid')) {
422 print '<input type="text" class="quatrevingtpercent" name="transvalue" value="'.dol_escape_htmltag($obj->transvalue).'">';
423 } else {
424 //print $obj->transkey.' '.$langsenfileonly->tab_translate[$obj->transkey];
425 $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>');
426 /*if ($obj->lang != 'en_US') {
427 $titleforvalue .= '<br>'.$langs->trans("Translation").' '.$obj->lang.' '...;
428 }*/
429 print '<span title="'.dol_escape_htmltag($titleforvalue).'" class="classfortooltip">';
430 print dol_escape_htmltag($obj->transvalue);
431 print '</span>';
432 }
433 print '</td>';
434
435 print '<td class="center">';
436 if ($action == 'edit' && $obj->rowid == GETPOSTINT('rowid')) {
437 print '<input type="hidden" class="button" name="rowid" value="'.$obj->rowid.'">';
438 print '<input type="submit" class="button buttongen button-save" name="save" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
439 print ' &nbsp; ';
440 print '<input type="submit" class="button buttongen button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
441 } else {
442 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>';
443 print ' &nbsp; ';
444 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&mode='.urlencode($mode).'&action=delete&token='.newToken().'">'.img_delete().'</a>';
445 }
446 print '</td>';
447
448 print "</tr>\n";
449 print "\n";
450 $i++;
451 }
452 }
453
454 print '</table>';
455 print '</div>';
456}
457
458if ($mode == 'searchkey') {
459 $nbempty = 0;
460 //var_dump($langcode);
461 //var_dump($transkey);
462 //var_dump($transvalue);
463 if (empty($langcode) || $langcode == '-1') {
464 $nbempty++;
465 }
466 if (empty($transkey)) {
467 $nbempty++;
468 }
469 if (empty($transvalue)) {
470 $nbempty++;
471 }
472
473 if ($action == 'search' && ($nbempty > 999)) { // 999 to disable this @phpstan-ignore-line
474 setEventMessages($langs->trans("WarningAtLeastKeyOrTranslationRequired"), null, 'warnings');
475 } else {
476 // Now search into translation array
477 foreach ($newlang->tab_translate as $key => $val) {
478 $newtranskey = preg_replace('/\$$/', '', preg_replace('/^\^/', '', $transkey));
479 $newtranskeystart = preg_match('/^\^/', $transkey);
480 $newtranskeyend = preg_match('/\$$/', $transkey);
481 $regexstring = ($newtranskeystart ? '^' : '').preg_quote($newtranskey, '/').($newtranskeyend ? '$' : '');
482 if ($transkey && !preg_match('/'.$regexstring.'/i', $key)) {
483 continue;
484 }
485 if ($transvalue && !preg_match('/'.preg_quote($transvalue, '/').'/i', $val)) {
486 continue;
487 }
488 $recordtoshow[$key] = $val;
489 }
490 }
491
492 //print '<br>';
493 $nbtotalofrecordswithoutfilters = count($newlang->tab_translate);
494 $nbtotalofrecords = count($recordtoshow);
495 $num = $limit + 1;
496 if (($offset + $num) > $nbtotalofrecords) {
497 $num = $limit;
498 }
499
500 //print 'param='.$param.' $_SERVER["PHP_SELF"]='.$_SERVER["PHP_SELF"].' num='.$num.' page='.$page.' nbtotalofrecords='.$nbtotalofrecords." sortfield=".$sortfield." sortorder=".$sortorder;
501 $title = $langs->trans("Translation");
502 if ($nbtotalofrecords > 0) {
503 $title .= ' <span class="opacitymedium colorblack paddingleft">('.$nbtotalofrecords.' / '.$nbtotalofrecordswithoutfilters.' - <span title="'.dol_escape_htmltag(($nbtotaloffiles - $nbtotaloffilesexternal).' core - '.($nbtotaloffilesexternal).' external').'">'.$nbtotaloffiles.' '.$langs->trans("Files").'</span>)</span>';
504 }
505 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, -1 * $nbtotalofrecords, '', 0, '', '', $limit, 0, 0, 1);
506
507 $massactionbutton = '';
508
509 print '<input type="hidden" id="action" name="action" value="search">';
510 print '<input type="hidden" id="mode" name="mode" value="'.$mode.'">';
511
512 print '<div class="div-table-responsive-no-min">';
513 print '<table class="noborder centpercent">';
514
515 print '<tr class="liste_titre liste_titre_filter"><td>';
516 //print $formadmin->select_language($langcode,'langcode',0,null,$langs->trans("All"),0,0,'',1);
517 print $formadmin->select_language($langcode, 'langcode', 0, array(), 0, 0, 0, 'maxwidth250', 1);
518 print '</td>'."\n";
519 print '<td>';
520 print '<input type="text" class="flat maxwidthonsmartphone" name="transkey" value="'.dol_escape_htmltag($transkey).'">';
521 print '</td><td>';
522 print '<input type="text" class="quatrevingtpercent" name="transvalue" value="'.dol_escape_htmltag($transvalue).'">';
523 // Limit to superadmin
524 /*if (isModEnabled('multicompany') && !$user->entity)
525 {
526 print '</td><td>';
527 print '<input type="text" class="flat" size="1" name="entitysearch" value="'.$conf->entity.'">';
528 }
529 else
530 {*/
531 print '<input type="hidden" name="entitysearch" value="'.$conf->entity.'">';
532 //}
533 print '</td>';
534 // Action column
535 print '<td class="right nowraponall">';
536 $searchpicto = $form->showFilterAndCheckAddButtons(!empty($massactionbutton) ? 1 : 0, 'checkforselect', 1);
537 print $searchpicto;
538 print '</td>';
539 print '</tr>';
540
541 print '<tr class="liste_titre">';
542 print_liste_field_titre("Language_en_US_es_MX_etc", $_SERVER["PHP_SELF"], 'lang,transkey', '', $param, '', $sortfield, $sortorder);
543 print_liste_field_titre("TranslationKey", $_SERVER["PHP_SELF"], 'transkey', '', $param, '', $sortfield, $sortorder);
544 print_liste_field_titre("CurrentTranslationString", $_SERVER["PHP_SELF"], 'transvalue', '', $param, '', $sortfield, $sortorder);
545 //if (isModEnabled('multicompany') && !$user->entity) print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,transkey', '', $param, '', $sortfield, $sortorder);
546 print '<td align="center"></td>';
547 print "</tr>\n";
548
549
550 if ($sortfield == 'transkey' && strtolower($sortorder) == 'asc') {
551 ksort($recordtoshow);
552 }
553 if ($sortfield == 'transkey' && strtolower($sortorder) == 'desc') {
554 krsort($recordtoshow);
555 }
556 if ($sortfield == 'transvalue' && strtolower($sortorder) == 'asc') {
557 asort($recordtoshow);
558 }
559 if ($sortfield == 'transvalue' && strtolower($sortorder) == 'desc') {
560 arsort($recordtoshow);
561 }
562
563 // Show result
564 $i = 0;
565 foreach ($recordtoshow as $key => $val) {
566 $i++;
567 if ($i <= $offset) {
568 continue;
569 }
570 if ($limit && $i > ($offset + $limit)) {
571 break;
572 }
573 print '<tr class="oddeven"><td>'.$langcode.'</td><td>'.$key.'</td>';
574 print '<td class="small">';
575 $titleforvalue = $langs->trans("Translation").' en_US for key '.$key.':<br>';
576 if (!empty($langsenfileonly->tab_translate[$key])) {
577 if (substr_count($langsenfileonly->tab_translate[$key], '%s') <= 4) { // To avoid errors when more than 4 %s.
578 $titleforvalue .= $langsenfileonly->trans($key);
579 }
580 } else {
581 $titleforvalue .= '<span class="opacitymedium">'.$langs->trans("None").'</span>';
582 }
583 print '<span title="'.dolPrintHTMLForAttribute($titleforvalue).'" class="classfortooltip">';
584 print dolPrintHTML($val);
585 if (substr_count($langsenfileonly->tab_translate[$key], '%s') > 4) {
586 print '<br><div class="warning">Error, more than 4 %s in the source</div>';
587 }
588 print '</span>';
589 print '</td>';
590 print '<td class="right nowraponall">';
591 if (!empty($newlangfileonly->tab_translate[$key])) {
592 if ($val != $newlangfileonly->tab_translate[$key]) {
593 // retrieve rowid
594 $sql = "SELECT rowid";
595 $sql .= " FROM ".MAIN_DB_PREFIX."overwrite_trans";
596 $sql .= " WHERE entity IN (".getEntity('overwrite_trans').")";
597 $sql .= " AND transkey = '".$db->escape($key)."'";
598 dol_syslog("translation::select from table", LOG_DEBUG);
599 $result = $db->query($sql);
600 $obj = null;
601 if ($result) {
602 $obj = $db->fetch_object($result);
603 }
604 if (is_object($obj)) {
605 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>';
606 print ' ';
607 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>';
608 print '&nbsp;&nbsp;';
609 $htmltext = $langs->trans("OriginalValueWas", '<i>'.$newlangfileonly->tab_translate[$key].'</i>');
610 print $form->textwithpicto('', $htmltext, 1, 'info');
611 }
612 } elseif (getDolGlobalString('MAIN_ENABLE_OVERWRITE_TRANSLATION')) {
613 //print $key.'-'.$val;
614 print '<a class="reposition paddingrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=overwrite&langcode='.urlencode($langcode).'&transkey='.urlencode($key).'">'.img_edit_add($langs->trans("TranslationOverwriteKey")).'</a>';
615 }
616
617 if (getDolGlobalInt('MAIN_FEATURES_LEVEL')) {
618 $transifexlangfile = '$'; // $ means 'All'
619 //$transifexurl = 'https://www.transifex.com/dolibarr-association/dolibarr/translate/#'.$langcode.'/'.$transifexlangfile.'?key='.$key;
620 $transifexurl = 'https://www.transifex.com/dolibarr-association/dolibarr/translate/#'.$langcode.'/'.$transifexlangfile.'?q=key%3A'.$key;
621
622 print ' &nbsp; <a href="'.$transifexurl.'" target="transifex">'.img_picto($langs->trans('FixOnTransifex'), 'globe').'</a>';
623 }
624 } else {
625 // retrieve rowid
626 $sql = "SELECT rowid";
627 $sql .= " FROM ".MAIN_DB_PREFIX."overwrite_trans";
628 $sql .= " WHERE entity IN (".getEntity('overwrite_trans').")";
629 $sql .= " AND transkey = '".$db->escape($key)."'";
630 dol_syslog("translation::select from table", LOG_DEBUG);
631 $result = $db->query($sql);
632 $obj = null;
633 if ($result) {
634 $obj = $db->fetch_object($result);
635 }
636 if (is_object($obj)) {
637 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>';
638 print ' ';
639 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>';
640 print '&nbsp;&nbsp;';
641
642 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
643 $htmltext = $langs->trans("TransKeyWithoutOriginalValue", $key);
644 print $form->textwithpicto('', $htmltext, 1, 'warning');
645 }
646 }
647 /*if (isModEnabled('multicompany') && !$user->entity)
648 {
649 print '<td>'.$val.'</td>';
650 }*/
651 print '</td></tr>'."\n";
652 }
653
654 if (empty($recordtoshow)) {
655 print '<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
656 }
657
658 print '</table>';
659 print '</div>';
660}
661
662print dol_get_fiche_end();
663
664print "</form>\n";
665
666if (!empty($langcode)) {
667 dol_set_focus('#transvalue');
668}
669
670// End of page
671llxFooter();
672$db->close();
$id
Definition account.php:39
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
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)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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 a 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.