Fix language file of external module not visible in trans tool
This commit is contained in:
parent
c02528a479
commit
a48fe55832
@ -27,12 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
|
||||||
|
|
||||||
$langs->load("companies");
|
$langs->loadLangs(array("companies","products","admin","sms","other","errors"));
|
||||||
$langs->load("products");
|
|
||||||
$langs->load("admin");
|
|
||||||
$langs->load("sms");
|
|
||||||
$langs->load("other");
|
|
||||||
$langs->load("errors");
|
|
||||||
|
|
||||||
if (!$user->admin) accessforbidden();
|
if (!$user->admin) accessforbidden();
|
||||||
|
|
||||||
@ -406,6 +401,7 @@ if ($mode == 'searchkey')
|
|||||||
// Search modules dirs
|
// Search modules dirs
|
||||||
$modulesdir = dolGetModulesDirs();
|
$modulesdir = dolGetModulesDirs();
|
||||||
|
|
||||||
|
$nbtotaloffiles=0;
|
||||||
$nbempty=0;
|
$nbempty=0;
|
||||||
/*var_dump($langcode);
|
/*var_dump($langcode);
|
||||||
var_dump($transkey);
|
var_dump($transkey);
|
||||||
@ -420,6 +416,7 @@ if ($mode == 'searchkey')
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Search into dir of modules (the $modulesdir is already a list that loop on $conf->file->dol_document_root)
|
// Search into dir of modules (the $modulesdir is already a list that loop on $conf->file->dol_document_root)
|
||||||
|
$i=0;
|
||||||
foreach($modulesdir as $keydir => $tmpsearchdir)
|
foreach($modulesdir as $keydir => $tmpsearchdir)
|
||||||
{
|
{
|
||||||
$searchdir = $tmpsearchdir; // $searchdir can be '.../htdocs/core/modules/' or '.../htdocs/custom/mymodule/core/modules/'
|
$searchdir = $tmpsearchdir; // $searchdir can be '.../htdocs/core/modules/' or '.../htdocs/custom/mymodule/core/modules/'
|
||||||
@ -432,10 +429,19 @@ if ($mode == 'searchkey')
|
|||||||
foreach($filearray as $file)
|
foreach($filearray as $file)
|
||||||
{
|
{
|
||||||
$tmpfile=preg_replace('/.lang/i', '', basename($file['name']));
|
$tmpfile=preg_replace('/.lang/i', '', basename($file['name']));
|
||||||
$newlang->load($tmpfile, 0, 0, '', 0); // Load translation files + database overwrite
|
$moduledirname =(basename(dirname(dirname($dir_lang))));
|
||||||
$newlangfileonly->load($tmpfile, 0, 0, '', 1); // Load translation files only
|
|
||||||
//print 'After loading lang '.$tmpfile.', newlang has '.count($newlang->tab_translate).' records<br>'."\n";
|
$langkey=$tmpfile;
|
||||||
|
if ($i > 0) $langkey.='@'.$moduledirname;
|
||||||
|
//var_dump($i.' - '.$keydir.' - '.$dir_lang_osencoded.' -> '.$moduledirname . ' / ' . $tmpfile.' -> '.$langkey);
|
||||||
|
|
||||||
|
$result = $newlang->load($langkey, 0, 0, '', 0); // Load translation files + database overwrite
|
||||||
|
$result = $newlangfileonly->load($langkey, 0, 0, '', 1); // Load translation files only
|
||||||
|
if ($result < 0) print 'Failed to load language file '.$tmpfile.'<br>'."\n";
|
||||||
|
else $nbtotaloffiles++;
|
||||||
|
//print 'After loading lang '.$langkey.', newlang has '.count($newlang->tab_translate).' records<br>'."\n";
|
||||||
}
|
}
|
||||||
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now search into translation array
|
// Now search into translation array
|
||||||
@ -455,7 +461,7 @@ if ($mode == 'searchkey')
|
|||||||
|
|
||||||
//print 'param='.$param.' $_SERVER["PHP_SELF"]='.$_SERVER["PHP_SELF"].' num='.$num.' page='.$page.' nbtotalofrecords='.$nbtotalofrecords." sortfield=".$sortfield." sortorder=".$sortorder;
|
//print 'param='.$param.' $_SERVER["PHP_SELF"]='.$_SERVER["PHP_SELF"].' num='.$num.' page='.$page.' nbtotalofrecords='.$nbtotalofrecords." sortfield=".$sortfield." sortorder=".$sortorder;
|
||||||
$title = $langs->trans("TranslationKeySearch");
|
$title = $langs->trans("TranslationKeySearch");
|
||||||
if ($nbtotalofrecords > 0) $title.=' ('.$nbtotalofrecords.' / '.$nbtotalofrecordswithoutfilters.')';
|
if ($nbtotalofrecords > 0) $title.=' ('.$nbtotalofrecords.' / '.$nbtotalofrecordswithoutfilters.' - '.$nbtotaloffiles.' '.$langs->trans("Files").')';
|
||||||
print print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, -1 * $nbtotalofrecords, '', 0, '', '', $limit)."\n";
|
print print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, -1 * $nbtotalofrecords, '', 0, '', '', $limit)."\n";
|
||||||
|
|
||||||
print '<input type="hidden" id="action" name="action" value="search">';
|
print '<input type="hidden" id="action" name="action" value="search">';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user