mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-06 09:38:23 +01:00
NEW Can select language from combo list on page to overwrite a
translation
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
require '../main.inc.php';
|
require '../main.inc.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
|
||||||
|
|
||||||
$langs->load("companies");
|
$langs->load("companies");
|
||||||
$langs->load("products");
|
$langs->load("products");
|
||||||
@@ -107,6 +108,8 @@ if ($action == 'delete')
|
|||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$formadmin = new FormAdmin($db);
|
||||||
|
|
||||||
$wikihelp='EN:Setup|FR:Paramétrage|ES:Configuración';
|
$wikihelp='EN:Setup|FR:Paramétrage|ES:Configuración';
|
||||||
llxHeader('',$langs->trans("Setup"),$wikihelp);
|
llxHeader('',$langs->trans("Setup"),$wikihelp);
|
||||||
|
|
||||||
@@ -146,7 +149,10 @@ print "</tr>\n";
|
|||||||
$var=false;
|
$var=false;
|
||||||
print "\n";
|
print "\n";
|
||||||
|
|
||||||
print '<tr '.$bc[$var].'><td><input type="text" class="flat" size="24" name="langcode" value="'.GETPOST('langcode').'"></td>'."\n";
|
print '<tr '.$bc[$var].'><td>';
|
||||||
|
print $formadmin->select_language(GETPOST('langcode'),'langcode',0,null,1,0,0,'',1);
|
||||||
|
//print '<input type="text" class="flat" size="24" name="langcode" value="'.GETPOST('langcode').'">';
|
||||||
|
print '</td>'."\n";
|
||||||
print '<td>';
|
print '<td>';
|
||||||
print '<input type="text" class="flat" size="30" name="transkey" value="">';
|
print '<input type="text" class="flat" size="30" name="transkey" value="">';
|
||||||
print '</td><td>';
|
print '</td><td>';
|
||||||
|
|||||||
@@ -47,17 +47,18 @@ class FormAdmin
|
|||||||
/**
|
/**
|
||||||
* Return html select list with available languages (key='en_US', value='United States' for example)
|
* Return html select list with available languages (key='en_US', value='United States' for example)
|
||||||
*
|
*
|
||||||
* @param string $selected Langue pre-selectionnee
|
* @param string $selected Language pre-selected
|
||||||
* @param string $htmlname Nom de la zone select
|
* @param string $htmlname Name of HTML select
|
||||||
* @param int $showauto Affiche choix auto
|
* @param int $showauto Show 'auto' choice
|
||||||
* @param array $filter Array of keys to exclude in list
|
* @param array $filter Array of keys to exclude in list
|
||||||
* @param int $showempty Add empty value
|
* @param int $showempty Add empty value
|
||||||
* @param int $showwarning Show a warning if language is not complete
|
* @param int $showwarning Show a warning if language is not complete
|
||||||
* @param int $disabled Disable edit of select
|
* @param int $disabled Disable edit of select
|
||||||
* @param string $morecss Add more css styles
|
* @param string $morecss Add more css styles
|
||||||
|
* @param int $showcode Add language code into label
|
||||||
* @return string Return HTML select string with list of languages
|
* @return string Return HTML select string with list of languages
|
||||||
*/
|
*/
|
||||||
function select_language($selected='',$htmlname='lang_id',$showauto=0,$filter=0,$showempty=0,$showwarning=0,$disabled=0,$morecss='')
|
function select_language($selected='',$htmlname='lang_id',$showauto=0,$filter=null,$showempty=0,$showwarning=0,$disabled=0,$morecss='',$showcode=0)
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
@@ -84,6 +85,9 @@ class FormAdmin
|
|||||||
$uncompletelanguages=array('da_DA','fi_FI','hu_HU','is_IS','pl_PL','ro_RO','ru_RU','sv_SV','tr_TR','zh_CN');
|
$uncompletelanguages=array('da_DA','fi_FI','hu_HU','is_IS','pl_PL','ro_RO','ru_RU','sv_SV','tr_TR','zh_CN');
|
||||||
foreach ($langs_available as $key => $value)
|
foreach ($langs_available as $key => $value)
|
||||||
{
|
{
|
||||||
|
$valuetoshow=$value;
|
||||||
|
if ($showcode) $valuetoshow=$key.' - '.$value;
|
||||||
|
|
||||||
if ($showwarning && in_array($key,$uncompletelanguages))
|
if ($showwarning && in_array($key,$uncompletelanguages))
|
||||||
{
|
{
|
||||||
//$value.=' - '.$langs->trans("TranslationUncomplete",$key);
|
//$value.=' - '.$langs->trans("TranslationUncomplete",$key);
|
||||||
@@ -92,16 +96,16 @@ class FormAdmin
|
|||||||
{
|
{
|
||||||
if ( ! array_key_exists($key, $filter))
|
if ( ! array_key_exists($key, $filter))
|
||||||
{
|
{
|
||||||
$out.= '<option value="'.$key.'">'.$value.'</option>';
|
$out.= '<option value="'.$key.'">'.$valuetoshow.'</option>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ($selected == $key)
|
else if ($selected == $key)
|
||||||
{
|
{
|
||||||
$out.= '<option value="'.$key.'" selected>'.$value.'</option>';
|
$out.= '<option value="'.$key.'" selected>'.$valuetoshow.'</option>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$out.= '<option value="'.$key.'">'.$value.'</option>';
|
$out.= '<option value="'.$key.'">'.$valuetoshow.'</option>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$out.= '</select>';
|
$out.= '</select>';
|
||||||
|
|||||||
Reference in New Issue
Block a user