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