Fix: Correct link to forum in help center
This commit is contained in:
parent
a8543dcb34
commit
215ac8fa30
@ -175,8 +175,8 @@ OfficialWebSiteFr = lloc web oficial francòfon
|
||||
OfficialWikiFr = Wiki francòfon
|
||||
OfficialWiki = Wiki Dolibarr
|
||||
OfficialDemo = Demo en línia Dolibarr
|
||||
ForDocumentationSeeWiki = Per a la documentació d'usuari, desenvolupador o Preguntes Freqüents (FAQ), consulteu el wiki Dolibarr: <br><b><a href=\"%s\" target=\"_blank\">%s</a></b>
|
||||
ForAnswersSeeForum = Per altres qüestions o realitzar les seves pròpies consultes, pot utilitzar el fòrum Dolibarr: <br><b><a href=\"%s\" target=\"_blank\">%s</a></b>
|
||||
ForDocumentationSeeWiki = Per a la documentació d'usuari, desenvolupador o Preguntes Freqüents (FAQ), consulteu el wiki Dolibarr: <br><b><a href="%s" target="_blank">%s</a></b>
|
||||
ForAnswersSeeForum = Per altres qüestions o realitzar les seves pròpies consultes, pot utilitzar el fòrum Dolibarr: <br><b><a href="%s" target="_blank">%s</a></b>
|
||||
HelpCenterDesc1 = Aquesta aplicació, independent de Dolibarr, us permet ajudar a obtenir un servei de suport de Dolibarr.
|
||||
HelpCenterDesc2 = Alguns d'aquests serveis només estan disponibles en <b>anglès</b>.
|
||||
CurrentTopMenuHandler = Gestor de menú superior
|
||||
|
||||
@ -175,8 +175,8 @@ OfficialWebSiteFr = sitio web oficial habla francesa
|
||||
OfficialWikiFr = Wiki habla francesa
|
||||
OfficialWiki = Wiki Dolibarr
|
||||
OfficialDemo = Demo en línea Dolibarr
|
||||
ForDocumentationSeeWiki = Para la documentación de usuario, desarrollador o Preguntas Frecuentes (FAQ), consulte el wiki Dolibarr: <br><b><a href=\"%s\" target=\"_blank\">%s</a></b>
|
||||
ForAnswersSeeForum = Para otras cuestiones o realizar sus propias consultas, puede utilizar el foro Dolibarr: <br><b><a href=\"%s\" target=\"_blank\">%s</a></b>
|
||||
ForDocumentationSeeWiki = Para la documentación de usuario, desarrollador o Preguntas Frecuentes (FAQ), consulte el wiki Dolibarr: <br><b><a href="%s" target="_blank">%s</a></b>
|
||||
ForAnswersSeeForum = Para otras cuestiones o realizar sus propias consultas, puede utilizar el foro Dolibarr: <br><b><a href="%s" target="_blank">%s</a></b>
|
||||
HelpCenterDesc1 = Esta aplicación, independiente de Dolibarr, le permite ayudarle a obtener un servicio de soporte de Dolibarr.
|
||||
HelpCenterDesc2 = Algunos de estos servicios sólo están disponibles en <b>inglés</b>.
|
||||
CurrentTopMenuHandler = Gestor de menú superior
|
||||
|
||||
@ -172,8 +172,8 @@ OfficialWebSiteFr=sitio web oficial falado/escrito em francês
|
||||
OfficialWikiFr=Wiki falado/escrito em francês
|
||||
OfficialWiki=Wiki ERP
|
||||
OfficialDemo=Demo em linha ERP
|
||||
ForDocumentationSeeWiki=Para a documentação de utilizador, programador ou Perguntas Frecuentes (FAQ), consulte o wiki do ERP: <br><b><a href=\"%s\" target=\"_blank\">%s</a></b>
|
||||
ForAnswersSeeForum=Para outras questões ou realizar as suas prórpias consultas, pode utilizar o forum do ERP: <br><b><a href=\"%s\" target=\"_blank\">%s</a></b>
|
||||
ForDocumentationSeeWiki=Para a documentação de utilizador, programador ou Perguntas Frecuentes (FAQ), consulte o wiki do ERP: <br><b><a href="%s" target="_blank">%s</a></b>
|
||||
ForAnswersSeeForum=Para outras questões ou realizar as suas prórpias consultas, pode utilizar o forum do ERP: <br><b><a href="%s" target="_blank">%s</a></b>
|
||||
HelpCenterDesc1=Esta área permite ajuda-lo a obter um serviço de suporte do ERP.
|
||||
HelpCenterDesc2=Alguns destes serviços só estão disponiveis em <b>inglés</b>.
|
||||
CurrentTopMenuHandler=Gestor de menu superior
|
||||
|
||||
@ -53,20 +53,6 @@ class CMailFile
|
||||
var $error='';
|
||||
|
||||
var $smtps; // Contains SMTPs object (if this method is used)
|
||||
|
||||
var $html;
|
||||
var $image_boundary;
|
||||
var $atleastoneimage=0;
|
||||
var $html_images=array();
|
||||
var $images_encoded=array();
|
||||
var $image_types = array('gif' => 'image/gif',
|
||||
'jpg' => 'image/jpeg',
|
||||
'jpeg' => 'image/jpeg',
|
||||
'jpe' => 'image/jpeg',
|
||||
'bmp' => 'image/bmp',
|
||||
'png' => 'image/png',
|
||||
'tif' => 'image/tiff',
|
||||
'tiff' => 'image/tiff');
|
||||
|
||||
|
||||
/**
|
||||
@ -99,32 +85,13 @@ class CMailFile
|
||||
if ($msgishtml == -1)
|
||||
{
|
||||
$this->msgishtml = 0;
|
||||
if (dol_textishtml($msg)) $this->msgishtml = 1;
|
||||
if (dol_textishtml($msg,1)) $this->msgishtml = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->msgishtml = $msgishtml;
|
||||
}
|
||||
|
||||
// Detect images
|
||||
if ($this->msgishtml)
|
||||
{
|
||||
$this->html = $msg;
|
||||
$findimg = $this->findHtmlImages($conf->fckeditor->dir_output);
|
||||
// Define if there is at least one file
|
||||
if ($findimg)
|
||||
{
|
||||
foreach ($this->html_images as $i => $val)
|
||||
{
|
||||
if ($this->html_images[$i])
|
||||
{
|
||||
$this->atleastoneimage=1;
|
||||
dol_syslog("CMailFile::CMailfile: html_images[$i]['name']=".$this->html_images[$i]['name'], LOG_DEBUG);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Define if there is at least one file
|
||||
foreach ($filename_list as $i => $val)
|
||||
{
|
||||
@ -155,7 +122,7 @@ class CMailFile
|
||||
$text_encoded = "";
|
||||
|
||||
// En-tete dans $smtp_headers
|
||||
$this->subject = utf8_decode($subject);
|
||||
$this->subject = $subject;
|
||||
$this->addr_from = $from;
|
||||
$this->errors_to = $errors_to;
|
||||
$this->addr_to = $to;
|
||||
@ -165,17 +132,10 @@ class CMailFile
|
||||
$smtp_headers = $this->write_smtpheaders();
|
||||
|
||||
// En-tete suite dans $mime_headers
|
||||
if ($this->atleastonefile || $this->atleastoneimage)
|
||||
if ($this->atleastonefile)
|
||||
{
|
||||
$mime_headers = $this->write_mimeheaders($filename_list, $mimefilename_list);
|
||||
}
|
||||
|
||||
// On encode les images
|
||||
if ($this->atleastoneimage)
|
||||
{
|
||||
$images_encoded = $this->write_images($this->images_encoded);
|
||||
$msg = $this->html;
|
||||
}
|
||||
|
||||
// Corps message dans $text_body
|
||||
$text_body = $this->write_body($msg, $filename_list);
|
||||
@ -188,7 +148,7 @@ class CMailFile
|
||||
|
||||
// On defini $this->headers et $this->message
|
||||
$this->headers = $smtp_headers . $mime_headers;
|
||||
$this->message = $text_body . $images_encoded . $text_encoded;
|
||||
$this->message = $text_body . $text_encoded;
|
||||
|
||||
// On nettoie le header pour qu'il ne se termine pas par un retour chariot.
|
||||
// Ceci evite aussi les lignes vides en fin qui peuvent etre interpretees
|
||||
@ -454,22 +414,17 @@ class CMailFile
|
||||
if (isset($this->deliveryreceipt) && $this->deliveryreceipt == 1) $out .= "Disposition-Notification-To: ".getValidAddress($this->addr_from,2).$this->eol;
|
||||
|
||||
//$out .= "X-Priority: 3".$this->eol;
|
||||
$out.= "X-Mailer: Dolibarr version " . DOL_VERSION ." (using php mail)".$this->eol;
|
||||
$out.= "MIME-Version: 1.0".$this->eol;
|
||||
|
||||
if ($this->atleastoneimage)
|
||||
$out .= "X-Mailer: Dolibarr version " . DOL_VERSION ." (using php mail)".$this->eol;
|
||||
$out .= "MIME-Version: 1.0".$this->eol;
|
||||
|
||||
if ($this->msgishtml)
|
||||
{
|
||||
if (! $this->atleastonefile) $out.= "Content-Type: multipart/related; boundary=\"".$this->mime_boundary."\"".$this->eol;
|
||||
$out.= "Content-Transfer-Encoding: 8bit".$this->eol;
|
||||
}
|
||||
else if ($this->msgishtml)
|
||||
{
|
||||
if (! $this->atleastonefile) $out.= "Content-Type: text/html; boundary=\"".$this->mime_boundary."\"".$this->eol;
|
||||
if (! $this->atleastonefile) $out.= "Content-Type: text/html; charset=".$conf->file->character_set_client.$this->eol;
|
||||
$out.= "Content-Transfer-Encoding: 8bit".$this->eol;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! $this->atleastonefile) $out.= "Content-Type: text/plain; boundary=\"".$this->mime_boundary."\"".$this->eol;
|
||||
if (! $this->atleastonefile) $out.= "Content-Type: text/plain; charset=".$conf->file->character_set_client.$this->eol;
|
||||
$out.= "Content-Transfer-Encoding: 8bit".$this->eol;
|
||||
}
|
||||
|
||||
@ -487,24 +442,19 @@ class CMailFile
|
||||
{
|
||||
$mimedone=0;
|
||||
$out = "";
|
||||
|
||||
if ($filename_list)
|
||||
for ($i = 0; $i < count($filename_list); $i++)
|
||||
{
|
||||
for ($i = 0; $i < count($filename_list); $i++)
|
||||
if ($filename_list[$i])
|
||||
{
|
||||
if ($filename_list[$i])
|
||||
if (! $mimedone)
|
||||
{
|
||||
if (! $mimedone)
|
||||
{
|
||||
$out.= "Content-Type: multipart/mixed; boundary=\"".$this->mime_boundary."\"".$this->eol;
|
||||
$mimedone=1;
|
||||
}
|
||||
if ($mimefilename_list[$i]) $filename_list[$i] = $mimefilename_list[$i];
|
||||
$out.= "X-attachments: $filename_list[$i]".$this->eol;
|
||||
$out.= "Content-Type: multipart/related; boundary=\"".$this->mime_boundary."\"".$this->eol;
|
||||
$mimedone=1;
|
||||
}
|
||||
if ($mimefilename_list[$i]) $filename_list[$i] = $mimefilename_list[$i];
|
||||
$out.= "X-attachments: $filename_list[$i]".$this->eol;
|
||||
}
|
||||
}
|
||||
|
||||
//$out.= $this->eol;
|
||||
dol_syslog("CMailFile::write_mimeheaders mime_header=\n".$out, LOG_DEBUG);
|
||||
return $out;
|
||||
@ -521,16 +471,15 @@ class CMailFile
|
||||
|
||||
$out='';
|
||||
|
||||
if ($this->atleastonefile || $this->atleastoneimage)
|
||||
if ($this->atleastonefile)
|
||||
{
|
||||
$out.= "--" . $this->mime_boundary . $this->eol;
|
||||
if ($this->msgishtml)
|
||||
{
|
||||
$out.= "--" . $this->mime_boundary . $this->eol;
|
||||
$out.= "Content-Type: text/html; charset=".$conf->file->character_set_client.$this->eol;
|
||||
}
|
||||
else
|
||||
{
|
||||
$out.= "--" . $this->mime_boundary . $this->eol;
|
||||
$out.= "Content-Type: text/plain; charset=".$conf->file->character_set_client.$this->eol;
|
||||
}
|
||||
$out.= $this->eol;
|
||||
@ -544,17 +493,12 @@ class CMailFile
|
||||
if (! $htmlalreadyinmsg) $out .= "<html><head><title></title></head><body>";
|
||||
$out.= $msgtext;
|
||||
if (! $htmlalreadyinmsg) $out .= "</body></html>";
|
||||
if ($this->atleastonefile || $this->atleastoneimage)
|
||||
{
|
||||
$out.= $this->eol . "--" . $this->mime_boundary . $this->eol;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$out.= $msgtext;
|
||||
$out.= $this->eol . "--" . $this->mime_boundary . $this->eol;
|
||||
}
|
||||
|
||||
$out.= $this->eol;
|
||||
return $out;
|
||||
}
|
||||
|
||||
@ -587,7 +531,7 @@ class CMailFile
|
||||
$out.= $this->eol;
|
||||
$out.= $encoded;
|
||||
$out.= $this->eol;
|
||||
//$out.= $this->eol;
|
||||
// $out.= $this->eol;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -597,8 +541,7 @@ class CMailFile
|
||||
}
|
||||
|
||||
// Fin de tous les attachements
|
||||
$out.= "--" . $this->mime_boundary . "--" . $this->eol;
|
||||
|
||||
$out = $out . "--" . $this->mime_boundary . "--" . $this->eol;
|
||||
return $out;
|
||||
}
|
||||
|
||||
@ -668,117 +611,6 @@ class CMailFile
|
||||
|
||||
return $_retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Recherche la presence d'images dans le message html
|
||||
\param images_dir Emplacement des images
|
||||
\return int >0 if OK, <0 if KO
|
||||
*/
|
||||
function findHtmlImages($images_dir)
|
||||
{
|
||||
// Build the list of image extensions
|
||||
$extensions = array_keys($this->image_types);
|
||||
|
||||
preg_match_all('/(?:"|\')([^"\']+\.('.implode('|', $extensions).'))(?:"|\')/Ui', $this->html, $matches);
|
||||
|
||||
if ($matches)
|
||||
{
|
||||
$i=0;
|
||||
foreach ($matches[1] as $full)
|
||||
{
|
||||
eregi('file=([A-Za-z0-9_\-\/]+[.]?[A-Za-z0-9]+)?$',$full,$regs);
|
||||
$img = $regs[1];
|
||||
|
||||
if (file_exists($images_dir.'/'.$img))
|
||||
{
|
||||
// Image path
|
||||
$src = preg_quote($full);
|
||||
|
||||
// Image name
|
||||
$this->html_images[$i]["name"] = $img;
|
||||
|
||||
// Content type
|
||||
$ext = preg_replace('#^.*\.(\w{3,4})$#e', 'strtolower("$1")', $img);
|
||||
$this->html_images[$i]["content_type"] = $this->image_types[$ext];
|
||||
|
||||
// cid
|
||||
$this->html_images[$i]["cid"] = md5(uniqid(time()));
|
||||
|
||||
$this->html = preg_replace("#src=\"$src\"|src='$src'#", "src=\"cid:".$this->html_images[$i]["cid"]."\"", $this->html);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
if (!empty($this->html_images))
|
||||
{
|
||||
// If duplicate images are embedded, they may show up as attachments, so remove them.
|
||||
//$html_images = array_unique($this->html_images);
|
||||
//sort($html_images);
|
||||
$i=0;
|
||||
|
||||
foreach ($this->html_images as $img)
|
||||
{
|
||||
if ($image = file_get_contents($images_dir.'/'.$img["name"]))
|
||||
{
|
||||
$this->images_encoded[$i]['name'] = $img["name"];
|
||||
$this->images_encoded[$i]['content_type'] = $img["content_type"];
|
||||
$this->images_encoded[$i]['cid'] = $img["cid"];
|
||||
|
||||
// Encodage de l'image
|
||||
$this->images_encoded[$i]["image_encoded"] = chunk_split(base64_encode($image), 68, $this->eol);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Permet d'attacher une image
|
||||
\param images_list Tableau
|
||||
\return out Chaine images encodees
|
||||
*/
|
||||
function write_images($images_list)
|
||||
{
|
||||
$out = '';
|
||||
|
||||
if ($images_list)
|
||||
{
|
||||
foreach ($images_list as $img)
|
||||
{
|
||||
dol_syslog("CMailFile::write_images: i=$i");
|
||||
|
||||
$out.= "--" . $this->mime_boundary . $this->eol;
|
||||
$out.= "Content-Type: " . $img["content_type"] . "; name=\"".$img["name"]."\"".$this->eol;
|
||||
$out.= "Content-Transfer-Encoding: base64".$this->eol;
|
||||
$out.= "Content-Disposition: inline; filename=\"".$img["name"]."\"".$this->eol;
|
||||
$out.= "Content-ID: <".$img["cid"].">".$this->eol;
|
||||
$out.= $this->eol;
|
||||
$out.= $img["image_encoded"];
|
||||
$out.= $this->eol;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Fin de tous les attachements
|
||||
$out.= "--" . $this->mime_boundary . "--" . $this->eol;
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -802,7 +634,7 @@ function getValidAddress($adresses,$format)
|
||||
{
|
||||
if (eregi('^(.*)<(.*)>$',trim($val),$regs))
|
||||
{
|
||||
$name = trim(utf8_decode($regs[1]));
|
||||
$name = trim($regs[1]);
|
||||
$email = trim($regs[2]);
|
||||
}
|
||||
else
|
||||
|
||||
@ -71,8 +71,8 @@ print '<table class="nocellnopadd"><tr><td align="center" valign="top">';
|
||||
print img_picto_common('','who.png');
|
||||
print '</td></tr><tr><td align="center">';
|
||||
$urlwiki='http://wiki.dolibarr.org';
|
||||
if ($langs->defaultlang == 'fr_FR') $urlwiki='http://wiki.dolibarr.org/index.php/Accueil';
|
||||
if ($langs->defaultlang == 'es_ES') $urlwiki='http://wiki.dolibarr.org/index.php/Portada';
|
||||
if (eregi('fr',$langs->defaultlang)) $urlwiki='http://wiki.dolibarr.org/index.php/Accueil';
|
||||
if (eregi('es',$langs->defaultlang)) $urlwiki='http://wiki.dolibarr.org/index.php/Portada';
|
||||
print '<br>'.$langs->trans("ForDocumentationSeeWiki",$urlwiki,$urlwiki);
|
||||
print '<br>';
|
||||
print '<br>'.$langs->trans("ForAnswersSeeForum",'http://www.dolibarr.org/forum/','http://www.dolibarr.org/forum/').'<br>';
|
||||
|
||||
@ -33,26 +33,26 @@
|
||||
*/
|
||||
class Translate {
|
||||
|
||||
var $dir; // Directories that contains /langs subdirectory
|
||||
var $dir; // Directories that contains /langs subdirectory
|
||||
|
||||
var $defaultlang; // Langue courante en vigueur de l'utilisateur
|
||||
var $defaultlang; // Langue courante en vigueur de l'utilisateur
|
||||
|
||||
var $tab_loaded=array(); // Tableau pour signaler les fichiers deja charges
|
||||
var $tab_translate=array(); // Tableau des traductions
|
||||
var $tab_loaded=array(); // Tableau pour signaler les fichiers deja charges
|
||||
var $tab_translate=array(); // Tableau des traductions
|
||||
|
||||
var $cache_labels=array(); // Cache for labels
|
||||
var $cache_labels=array(); // Cache for labels
|
||||
|
||||
var $charset_inputfile=array(); // To store charset encoding used for language
|
||||
var $charset_inputfile=array(); // To store charset encoding used for language
|
||||
var $charset_output='UTF-8'; // Codage used by "trans" method outputs
|
||||
|
||||
|
||||
/**
|
||||
* \brief Constructeur de la classe
|
||||
* \param dir Force directory that contains /langs subdirectory
|
||||
* \param conf Objet qui contient la config Dolibarr
|
||||
*/
|
||||
function Translate($dir = "",$conf)
|
||||
{
|
||||
/**
|
||||
* \brief Constructeur de la classe
|
||||
* \param dir Force directory that contains /langs subdirectory
|
||||
* \param conf Objet qui contient la config Dolibarr
|
||||
*/
|
||||
function Translate($dir = "",$conf)
|
||||
{
|
||||
// If charset output is forced
|
||||
if (! empty($conf->file->character_set_client))
|
||||
{
|
||||
@ -60,7 +60,7 @@ class Translate {
|
||||
}
|
||||
if ($dir) $this->dir=array($dir);
|
||||
else $this->dir=$conf->file->dol_document_root;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -92,97 +92,97 @@ class Translate {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Set accessor for this->defaultlang
|
||||
* \param srclang Language to use
|
||||
*/
|
||||
function setDefaultLang($srclang='fr_FR')
|
||||
{
|
||||
//dol_syslog("Translate::setDefaultLang ".$this->defaultlang,LOG_DEBUG);
|
||||
/**
|
||||
* \brief Set accessor for this->defaultlang
|
||||
* \param srclang Language to use
|
||||
*/
|
||||
function setDefaultLang($srclang='fr_FR')
|
||||
{
|
||||
//dol_syslog("Translate::setDefaultLang ".$this->defaultlang,LOG_DEBUG);
|
||||
|
||||
$this->origlang=$srclang;
|
||||
$this->origlang=$srclang;
|
||||
|
||||
if (empty($srclang) || $srclang == 'auto')
|
||||
{
|
||||
$langpref=$_SERVER['HTTP_ACCEPT_LANGUAGE'];
|
||||
$langpref=eregi_replace(";[^,]*","",$langpref);
|
||||
$langpref=eregi_replace("-","_",$langpref);
|
||||
if (empty($srclang) || $srclang == 'auto')
|
||||
{
|
||||
$langpref=$_SERVER['HTTP_ACCEPT_LANGUAGE'];
|
||||
$langpref=eregi_replace(";[^,]*","",$langpref);
|
||||
$langpref=eregi_replace("-","_",$langpref);
|
||||
|
||||
$langlist=split("[;,]",$langpref);
|
||||
$langlist=split("[;,]",$langpref);
|
||||
|
||||
$langpart=split("_",$langlist[0]);
|
||||
//print "Short before _ : ".$langpart[0].'/ Short after _ : '.$langpart[1];
|
||||
$langpart=split("_",$langlist[0]);
|
||||
//print "Short before _ : ".$langpart[0].'/ Short after _ : '.$langpart[1];
|
||||
|
||||
if (isset($langpart[1])) {
|
||||
$srclang=strtolower($langpart[0])."_".strtoupper($langpart[1]);
|
||||
// Array to convert long lang code into other long code.
|
||||
$longforlong=array('no_nb'=>'nb_NO');
|
||||
if (isset($longforlong[strtolower($srclang)])) $srclang=$longforlong[strtolower($srclang)];
|
||||
}
|
||||
else {
|
||||
// Array to convert short lang code into long code.
|
||||
$longforshort=array('ca'=>'ca_ES', 'nb'=>'nb_NO', 'no'=>'nb_NO');
|
||||
if (isset($longforshort[strtolower($langpart[0])])) $srclang=$longforshort[strtolower($langpart[0])];
|
||||
else $srclang=strtolower($langpart[0])."_".strtoupper($langpart[0]);
|
||||
}
|
||||
}
|
||||
if (isset($langpart[1])) {
|
||||
$srclang=strtolower($langpart[0])."_".strtoupper($langpart[1]);
|
||||
// Array to convert long lang code into other long code.
|
||||
$longforlong=array('no_nb'=>'nb_NO');
|
||||
if (isset($longforlong[strtolower($srclang)])) $srclang=$longforlong[strtolower($srclang)];
|
||||
}
|
||||
else {
|
||||
// Array to convert short lang code into long code.
|
||||
$longforshort=array('ca'=>'ca_ES', 'nb'=>'nb_NO', 'no'=>'nb_NO');
|
||||
if (isset($longforshort[strtolower($langpart[0])])) $srclang=$longforshort[strtolower($langpart[0])];
|
||||
else $srclang=strtolower($langpart[0])."_".strtoupper($langpart[0]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->defaultlang=$srclang;
|
||||
}
|
||||
$this->defaultlang=$srclang;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Return active language code for current user
|
||||
* \remarks Accessor for this->defaultlang
|
||||
* \return string Language code used (en_US, en_AU, fr_FR, ...)
|
||||
*/
|
||||
function getDefaultLang()
|
||||
{
|
||||
return $this->defaultlang;
|
||||
}
|
||||
/**
|
||||
* \brief Return active language code for current user
|
||||
* \remarks Accessor for this->defaultlang
|
||||
* \return string Language code used (en_US, en_AU, fr_FR, ...)
|
||||
*/
|
||||
function getDefaultLang()
|
||||
{
|
||||
return $this->defaultlang;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Positionne environnement PHP en fonction du langage
|
||||
\remarks Le code langue long (fr_FR, en_US, ...) doit avoir etre positionne par setDefaultLang
|
||||
\return int >0 si ok, <0 so ko
|
||||
\deprecated
|
||||
*/
|
||||
function setPhpLang()
|
||||
{
|
||||
//dol_syslog("Translate::setPhpLang ".$this->defaultlang,LOG_DEBUG);
|
||||
/**
|
||||
\brief Positionne environnement PHP en fonction du langage
|
||||
\remarks Le code langue long (fr_FR, en_US, ...) doit avoir etre positionne par setDefaultLang
|
||||
\return int >0 si ok, <0 so ko
|
||||
\deprecated
|
||||
*/
|
||||
function setPhpLang()
|
||||
{
|
||||
//dol_syslog("Translate::setPhpLang ".$this->defaultlang,LOG_DEBUG);
|
||||
return;
|
||||
/*
|
||||
$code_lang_tiret=ereg_replace('_','-',$this->defaultlang);
|
||||
//print 'code_lang_tiret='.$code_lang_tiret;
|
||||
setlocale(LC_ALL, $this->defaultlang); // Some OS (Windows) need local with _
|
||||
setlocale(LC_ALL, $code_lang_tiret); // Other OS need local with -
|
||||
/*
|
||||
$code_lang_tiret=ereg_replace('_','-',$this->defaultlang);
|
||||
//print 'code_lang_tiret='.$code_lang_tiret;
|
||||
setlocale(LC_ALL, $this->defaultlang); // Some OS (Windows) need local with _
|
||||
setlocale(LC_ALL, $code_lang_tiret); // Other OS need local with -
|
||||
|
||||
if (defined("MAIN_FORCE_SETLOCALE_LC_ALL") && MAIN_FORCE_SETLOCALE_LC_ALL)
|
||||
$res_lc_all=setlocale(LC_ALL, MAIN_FORCE_SETLOCALE_LC_ALL.'.UTF-8', MAIN_FORCE_SETLOCALE_LC_ALL);
|
||||
if (defined("MAIN_FORCE_SETLOCALE_LC_NUMERIC") && MAIN_FORCE_SETLOCALE_LC_NUMERIC)
|
||||
$res_lc_numeric=setlocale(LC_NUMERIC, MAIN_FORCE_SETLOCALE_LC_NUMERIC.'.UTF-8', MAIN_FORCE_SETLOCALE_LC_NUMERIC);
|
||||
if (defined("MAIN_FORCE_SETLOCALE_LC_MONETARY") && MAIN_FORCE_SETLOCALE_LC_MONETARY)
|
||||
$res_lc_monetary=setlocale(LC_MONETARY, MAIN_FORCE_SETLOCALE_LC_MONETARY.'UTF-8', MAIN_FORCE_SETLOCALE_LC_MONETARY);
|
||||
//print 'x'.$res_lc_all;
|
||||
return 1;
|
||||
*/
|
||||
}
|
||||
if (defined("MAIN_FORCE_SETLOCALE_LC_ALL") && MAIN_FORCE_SETLOCALE_LC_ALL)
|
||||
$res_lc_all=setlocale(LC_ALL, MAIN_FORCE_SETLOCALE_LC_ALL.'.UTF-8', MAIN_FORCE_SETLOCALE_LC_ALL);
|
||||
if (defined("MAIN_FORCE_SETLOCALE_LC_NUMERIC") && MAIN_FORCE_SETLOCALE_LC_NUMERIC)
|
||||
$res_lc_numeric=setlocale(LC_NUMERIC, MAIN_FORCE_SETLOCALE_LC_NUMERIC.'.UTF-8', MAIN_FORCE_SETLOCALE_LC_NUMERIC);
|
||||
if (defined("MAIN_FORCE_SETLOCALE_LC_MONETARY") && MAIN_FORCE_SETLOCALE_LC_MONETARY)
|
||||
$res_lc_monetary=setlocale(LC_MONETARY, MAIN_FORCE_SETLOCALE_LC_MONETARY.'UTF-8', MAIN_FORCE_SETLOCALE_LC_MONETARY);
|
||||
//print 'x'.$res_lc_all;
|
||||
return 1;
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* \brief Load in a memory array, translation key-value for a particular file.
|
||||
* If data for file already loaded, do nothing.
|
||||
* All data in translation array are stored in UTF-8 format.
|
||||
* \param domain File name to load (.lang file). Use @ before value if domain is in a module directory.
|
||||
* \param alt Use alternate file even if file in target language is found
|
||||
* If data for file already loaded, do nothing.
|
||||
* All data in translation array are stored in UTF-8 format.
|
||||
* \param domain File name to load (.lang file). Use @ before value if domain is in a module directory.
|
||||
* \param alt Use alternate file even if file in target language is found
|
||||
* \return int <0 if KO, >0 if OK
|
||||
* \remarks tab_loaded is completed with $domain key.
|
||||
* \remarks tab_loaded is completed with $domain key.
|
||||
* Value for key is: 1:Loaded from disk, 2:Not found, 3:Loaded from cache
|
||||
*/
|
||||
function Load($domain,$alt=0)
|
||||
{
|
||||
//dol_syslog("Translate::Load domain=".$domain." alt=".$alt);
|
||||
function Load($domain,$alt=0)
|
||||
{
|
||||
//dol_syslog("Translate::Load domain=".$domain." alt=".$alt);
|
||||
|
||||
// Check parameters
|
||||
if (empty($domain))
|
||||
@ -207,30 +207,30 @@ class Translate {
|
||||
}
|
||||
else $searchdir=$searchdir."/langs";
|
||||
|
||||
// Directory of translation files
|
||||
$scandir = $searchdir."/".$this->defaultlang;
|
||||
$file_lang = $scandir . "/".$domain.".lang";
|
||||
$filelangexists=is_file($file_lang);
|
||||
// Directory of translation files
|
||||
$scandir = $searchdir."/".$this->defaultlang;
|
||||
$file_lang = $scandir . "/".$domain.".lang";
|
||||
$filelangexists=is_file($file_lang);
|
||||
//print 'Load default_lang='.$this->defaultlang.' alt='.$alt.' newalt='.$newalt.' '.$file_lang."-".$filelangexists.'<br>';
|
||||
|
||||
// Check in "always available" alternate file if not found or if asked
|
||||
if ($newalt || ! $filelangexists)
|
||||
{
|
||||
// Dir of always available alternate file (en_US or fr_FR)
|
||||
// Check in "always available" alternate file if not found or if asked
|
||||
if ($newalt || ! $filelangexists)
|
||||
{
|
||||
// Dir of always available alternate file (en_US or fr_FR)
|
||||
if ($this->defaultlang == "en_US") $scandiralt = $searchdir."/fr_FR";
|
||||
elseif (eregi('^fr',$this->defaultlang) && $this->defaultlang != 'fr_FR') $scandiralt = $searchdir."/fr_FR";
|
||||
elseif (eregi('^en',$this->defaultlang) && $this->defaultlang != 'en_US') $scandiralt = $searchdir."/en_US";
|
||||
elseif (eregi('^es',$this->defaultlang) && $this->defaultlang != 'es_ES') $scandiralt = $searchdir."/es_ES";
|
||||
else $scandiralt = $searchdir."/en_US";
|
||||
elseif (eregi('^fr',$this->defaultlang) && $this->defaultlang != 'fr_FR') $scandiralt = $searchdir."/fr_FR";
|
||||
elseif (eregi('^en',$this->defaultlang) && $this->defaultlang != 'en_US') $scandiralt = $searchdir."/en_US";
|
||||
elseif (eregi('^es',$this->defaultlang) && $this->defaultlang != 'es_ES') $scandiralt = $searchdir."/es_ES";
|
||||
else $scandiralt = $searchdir."/en_US";
|
||||
|
||||
$file_lang = $scandiralt . "/".$domain.".lang";
|
||||
$filelangexists=is_file($file_lang);
|
||||
$newalt=1;
|
||||
}
|
||||
$file_lang = $scandiralt . "/".$domain.".lang";
|
||||
$filelangexists=is_file($file_lang);
|
||||
$newalt=1;
|
||||
}
|
||||
//print 'Load alt='.$alt.' newalt='.$newalt.' '.$file_lang."-".$filelangexists.'<br>';
|
||||
|
||||
if ($filelangexists)
|
||||
{
|
||||
if ($filelangexists)
|
||||
{
|
||||
// Enable cache of lang file in session (faster but need more memory)
|
||||
// Speed gain: 40ms - Memory overusage: 200ko (Size of session cache file)
|
||||
$enablelangcacheinsession=false;
|
||||
@ -246,20 +246,20 @@ class Translate {
|
||||
else
|
||||
{
|
||||
if ($fp = @fopen($file_lang,"rt"))
|
||||
{
|
||||
if ($enablelangcacheinsession) $tabtranslatedomain=array(); // To save lang in session
|
||||
$finded = 0;
|
||||
while (($ligne = fgets($fp,4096)) && ($finded == 0))
|
||||
{
|
||||
if ($ligne[0] != "\n" && $ligne[0] != " " && $ligne[0] != "#")
|
||||
{
|
||||
$tab=split('=',$ligne,2);
|
||||
$key=trim($tab[0]);
|
||||
//print "Domain=$domain, found a string for $tab[0] with value $tab[1]<br>";
|
||||
//if (! $this->getTransFromTab($key))
|
||||
if (empty($this->tab_translate[$key]) && isset($tab[1]))
|
||||
{
|
||||
$value=trim(ereg_replace('\\\n',"\n",$tab[1]));
|
||||
{
|
||||
if ($enablelangcacheinsession) $tabtranslatedomain=array(); // To save lang in session
|
||||
$finded = 0;
|
||||
while (($ligne = fgets($fp,4096)) && ($finded == 0))
|
||||
{
|
||||
if ($ligne[0] != "\n" && $ligne[0] != " " && $ligne[0] != "#")
|
||||
{
|
||||
$tab=split('=',$ligne,2);
|
||||
$key=trim($tab[0]);
|
||||
//print "Domain=$domain, found a string for $tab[0] with value $tab[1]<br>";
|
||||
//if (! $this->getTransFromTab($key))
|
||||
if (empty($this->tab_translate[$key]) && isset($tab[1]))
|
||||
{
|
||||
$value=trim(ereg_replace('\\\n',"\n",$tab[1]));
|
||||
|
||||
if (eregi('^CHARSET$',$key))
|
||||
{
|
||||
@ -270,8 +270,8 @@ class Translate {
|
||||
else
|
||||
{
|
||||
// On stocke toujours dans le tableau Tab en UTF-8
|
||||
//if (empty($this->charset_inputfile[$domain]) || $this->charset_inputfile[$domain] == 'UTF-8') $value=utf8_decode($value);
|
||||
if (empty($this->charset_inputfile[$domain]) || $this->charset_inputfile[$domain] == 'ISO-8859-1') $value=utf8_encode($value);
|
||||
//if (empty($this->charset_inputfile[$domain]) || $this->charset_inputfile[$domain] == 'UTF-8') $value=utf8_decode($value);
|
||||
if (empty($this->charset_inputfile[$domain]) || $this->charset_inputfile[$domain] == 'ISO-8859-1') $value=utf8_encode($value);
|
||||
|
||||
// We do not load Separator values for alternate files
|
||||
if (! $newalt || (! eregi('^Separator',$key)))
|
||||
@ -281,101 +281,101 @@ class Translate {
|
||||
}
|
||||
if ($enablelangcacheinsession) $tabtranslatedomain[$key]=$value; // To save lang in session
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose($fp);
|
||||
|
||||
// Pour les langues aux fichiers parfois incomplets, on charge la langue alternative
|
||||
if (! $newalt && $this->defaultlang != "fr_FR" && $this->defaultlang != "en_US")
|
||||
{
|
||||
// This function MUST NOY contains call to syslog
|
||||
//dol_syslog("Translate::Load loading alternate translation file (to complete ".$this->defaultlang."/".$domain.".lang file)", LOG_DEBUG);
|
||||
$this->load($domain,1);
|
||||
}
|
||||
// Pour les langues aux fichiers parfois incomplets, on charge la langue alternative
|
||||
if (! $newalt && $this->defaultlang != "fr_FR" && $this->defaultlang != "en_US")
|
||||
{
|
||||
// This function MUST NOY contains call to syslog
|
||||
//dol_syslog("Translate::Load loading alternate translation file (to complete ".$this->defaultlang."/".$domain.".lang file)", LOG_DEBUG);
|
||||
$this->load($domain,1);
|
||||
}
|
||||
|
||||
$this->tab_loaded[$domain]=1; // Marque ce fichier comme charge
|
||||
$this->tab_loaded[$domain]=1; // Marque ce fichier comme charge
|
||||
|
||||
// To save lang in session
|
||||
if ($enablelangcacheinsession && sizeof($tabtranslatedomain)) $_SESSION['lang_'.$domain]=$tabtranslatedomain;
|
||||
|
||||
break; // Break loop on each root dir
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($this->tab_loaded[$domain])) $this->tab_loaded[$domain]=2; // Marque ce fichier comme non trouve
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* \brief Mark domain as not loaded to be able to load it again.
|
||||
* \param domain File name to load (.lang file). Use @ before value if domain is in a module directory.
|
||||
* \param domain File name to load (.lang file). Use @ before value if domain is in a module directory.
|
||||
*/
|
||||
function UnLoad($domain)
|
||||
{
|
||||
dol_syslog("Translate::UnLoad domain=".$domain." marked as not loaded", LOG_DEBUG);
|
||||
function UnLoad($domain)
|
||||
{
|
||||
dol_syslog("Translate::UnLoad domain=".$domain." marked as not loaded", LOG_DEBUG);
|
||||
$this->tab_loaded[$domain]=0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Retourne la liste des domaines charg<EFBFBD>es en memoire
|
||||
* \return array Tableau des domaines charg<EFBFBD>es
|
||||
*/
|
||||
function list_domainloaded()
|
||||
{
|
||||
$ret='';
|
||||
/**
|
||||
* \brief Retourne la liste des domaines charg<EFBFBD>es en memoire
|
||||
* \return array Tableau des domaines charg<EFBFBD>es
|
||||
*/
|
||||
function list_domainloaded()
|
||||
{
|
||||
$ret='';
|
||||
foreach($this->tab_loaded as $key=>$val)
|
||||
{
|
||||
if ($ret) $ret.=',';
|
||||
$ret.=$key.'='.$val;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Retourne la version traduite du texte passe en parametre en la codant en HTML
|
||||
* Si il n'y a pas de correspondance pour ce texte, on cherche dans fichier alternatif
|
||||
* et si toujours pas trouve, il est retourne tel quel
|
||||
* Les parametres de cette methode peuvent contenir de balises HTML.
|
||||
* \param key cle de chaine a traduire
|
||||
* \param param1 chaine de param1
|
||||
* \param param2 chaine de param2
|
||||
* \param param3 chaine de param3
|
||||
* \param param4 chaine de param4
|
||||
* \param maxsize taille max
|
||||
* \return string Chaine traduite et code en HTML
|
||||
*/
|
||||
function trans($key, $param1='', $param2='', $param3='', $param4='', $maxsize=0)
|
||||
{
|
||||
if ($this->getTransFromTab($key))
|
||||
{
|
||||
// Translation is available
|
||||
$str=sprintf($this->tab_translate[$key],$param1,$param2,$param3,$param4);
|
||||
if ($maxsize) $str=dol_trunc($str,$maxsize);
|
||||
// On remplace les tags HTML par __xx__ pour eviter traduction par htmlentities
|
||||
$newstr=ereg_replace('<','__lt__',$str);
|
||||
$newstr=ereg_replace('>','__gt__',$newstr);
|
||||
$newstr=ereg_replace('"','__quot__',$newstr);
|
||||
/**
|
||||
* \brief Retourne la version traduite du texte passe en parametre en la codant en HTML
|
||||
* Si il n'y a pas de correspondance pour ce texte, on cherche dans fichier alternatif
|
||||
* et si toujours pas trouve, il est retourne tel quel
|
||||
* Les parametres de cette methode peuvent contenir de balises HTML.
|
||||
* \param key cle de chaine a traduire
|
||||
* \param param1 chaine de param1
|
||||
* \param param2 chaine de param2
|
||||
* \param param3 chaine de param3
|
||||
* \param param4 chaine de param4
|
||||
* \param maxsize taille max
|
||||
* \return string Chaine traduite et code en HTML
|
||||
*/
|
||||
function trans($key, $param1='', $param2='', $param3='', $param4='', $maxsize=0)
|
||||
{
|
||||
if ($this->getTransFromTab($key))
|
||||
{
|
||||
// Translation is available
|
||||
$str=sprintf($this->tab_translate[$key],$param1,$param2,$param3,$param4);
|
||||
if ($maxsize) $str=dol_trunc($str,$maxsize);
|
||||
// On remplace les tags HTML par __xx__ pour eviter traduction par htmlentities
|
||||
$newstr=ereg_replace('<','__lt__',$str);
|
||||
$newstr=ereg_replace('>','__gt__',$newstr);
|
||||
$newstr=ereg_replace('"','__quot__',$newstr);
|
||||
|
||||
$newstr=$this->convToOutputCharset($newstr); // Convert string to $this->charset_output
|
||||
$newstr=$this->convToOutputCharset($newstr); // Convert string to $this->charset_output
|
||||
|
||||
// Cryptage en html de la chaine
|
||||
// $newstr est une chaine stockee en memoire au format $this->charset_output
|
||||
$newstr=htmlentities($newstr,ENT_QUOTES,$this->charset_output);
|
||||
// Cryptage en html de la chaine
|
||||
// $newstr est une chaine stockee en memoire au format $this->charset_output
|
||||
$newstr=htmlentities($newstr,ENT_QUOTES,$this->charset_output);
|
||||
|
||||
// On restaure les tags HTML
|
||||
$newstr=ereg_replace('__lt__','<',$newstr);
|
||||
$newstr=ereg_replace('__gt__','>',$newstr);
|
||||
$newstr=ereg_replace('__quot__','"',$newstr);
|
||||
return $newstr;
|
||||
}
|
||||
else
|
||||
{
|
||||
// On restaure les tags HTML
|
||||
$newstr=ereg_replace('__lt__','<',$newstr);
|
||||
$newstr=ereg_replace('__gt__','>',$newstr);
|
||||
$newstr=ereg_replace('__quot__','"',$newstr);
|
||||
return $newstr;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Translation is not available
|
||||
$newstr=$key;
|
||||
if (eregi('CurrencyShort([A-Z]+)$',$key,$reg))
|
||||
@ -396,192 +396,192 @@ class Translate {
|
||||
}
|
||||
return $this->convToOutputCharset($newstr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Return translated value of a text string
|
||||
* Si il n'y a pas de correspondance pour ce texte, on cherche dans fichier alternatif
|
||||
* et si toujours pas trouve, il est retourne tel quel.
|
||||
* Parameters of this method must not contains any HTML tags.
|
||||
* \param key key of string to translate
|
||||
* \param param1 chaine de param1
|
||||
* \param param2 chaine de param1
|
||||
* \param param3 chaine de param1
|
||||
* \param param4 chaine de param1
|
||||
* \return string chaine traduite
|
||||
*/
|
||||
function transnoentities($key, $param1='', $param2='', $param3='', $param4='')
|
||||
{
|
||||
$newstr=$key;
|
||||
if ($this->getTransFromTab($newstr))
|
||||
{
|
||||
// Si la traduction est disponible
|
||||
$newstr=sprintf($this->tab_translate[$newstr],$param1,$param2,$param3,$param4);
|
||||
}
|
||||
return $this->convToOutputCharset($newstr);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Return translated value of a text string
|
||||
* Si il n'y a pas de correspondance pour ce texte, on cherche dans fichier alternatif
|
||||
* et si toujours pas trouve, il est retourne tel quel.
|
||||
* No convert to encoding charset of lang object is done.
|
||||
* Parameters of this method must not contains any HTML tags.
|
||||
* \param key key of string to translate
|
||||
* \param param1 chaine de param1
|
||||
* \param param2 chaine de param1
|
||||
* \param param3 chaine de param1
|
||||
* \param param4 chaine de param1
|
||||
* \return string chaine traduite
|
||||
*/
|
||||
function transnoentitiesnoconv($key, $param1='', $param2='', $param3='', $param4='')
|
||||
{
|
||||
$newstr=$key;
|
||||
if ($this->getTransFromTab($newstr))
|
||||
{
|
||||
// Si la traduction est disponible
|
||||
$newstr=sprintf($this->tab_translate[$newstr],$param1,$param2,$param3,$param4);
|
||||
}
|
||||
return $newstr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Retourne la version traduite du texte passe en parametre complete du code pays
|
||||
* \param str chaine a traduire
|
||||
* \param countrycode code pays (FR, ...)
|
||||
* \return string chaine traduite
|
||||
*/
|
||||
function transcountry($str, $countrycode)
|
||||
{
|
||||
if ($this->tab_translate["$str$countrycode"]) return $this->trans("$str$countrycode");
|
||||
else return $this->trans($str);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Retourne la version traduite du texte passe en parametre complete du code pays
|
||||
* \param str chaine a traduire
|
||||
* \param countrycode code pays (FR, ...)
|
||||
* \return string chaine traduite
|
||||
*/
|
||||
function transcountrynoentities($str, $countrycode)
|
||||
{
|
||||
if ($this->tab_translate["$str$countrycode"]) return $this->transnoentities("$str$countrycode");
|
||||
else return $this->transnoentities($str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Convert a string into output charset (this->charset_output that should be defined to conf->file->character_set_client)
|
||||
* \param str String to convert
|
||||
* \param pagecodefrom Page code of src string
|
||||
* \return string Converted string
|
||||
*/
|
||||
function convToOutputCharset($str,$pagecodefrom='UTF-8')
|
||||
{
|
||||
if ($pagecodefrom == 'ISO-8859-1' && $this->charset_output == 'UTF-8') $str=utf8_encode($str);
|
||||
* \brief Return translated value of a text string
|
||||
* Si il n'y a pas de correspondance pour ce texte, on cherche dans fichier alternatif
|
||||
* et si toujours pas trouve, il est retourne tel quel.
|
||||
* Parameters of this method must not contains any HTML tags.
|
||||
* \param key key of string to translate
|
||||
* \param param1 chaine de param1
|
||||
* \param param2 chaine de param1
|
||||
* \param param3 chaine de param1
|
||||
* \param param4 chaine de param1
|
||||
* \return string chaine traduite
|
||||
*/
|
||||
function transnoentities($key, $param1='', $param2='', $param3='', $param4='')
|
||||
{
|
||||
$newstr=$key;
|
||||
if ($this->getTransFromTab($newstr))
|
||||
{
|
||||
// Si la traduction est disponible
|
||||
$newstr=sprintf($this->tab_translate[$newstr],$param1,$param2,$param3,$param4);
|
||||
}
|
||||
return $this->convToOutputCharset($newstr);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Return translated value of a text string
|
||||
* Si il n'y a pas de correspondance pour ce texte, on cherche dans fichier alternatif
|
||||
* et si toujours pas trouve, il est retourne tel quel.
|
||||
* No convert to encoding charset of lang object is done.
|
||||
* Parameters of this method must not contains any HTML tags.
|
||||
* \param key key of string to translate
|
||||
* \param param1 chaine de param1
|
||||
* \param param2 chaine de param1
|
||||
* \param param3 chaine de param1
|
||||
* \param param4 chaine de param1
|
||||
* \return string chaine traduite
|
||||
*/
|
||||
function transnoentitiesnoconv($key, $param1='', $param2='', $param3='', $param4='')
|
||||
{
|
||||
$newstr=$key;
|
||||
if ($this->getTransFromTab($newstr))
|
||||
{
|
||||
// Si la traduction est disponible
|
||||
$newstr=sprintf($this->tab_translate[$newstr],$param1,$param2,$param3,$param4);
|
||||
}
|
||||
return $newstr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Retourne la version traduite du texte passe en parametre complete du code pays
|
||||
* \param str chaine a traduire
|
||||
* \param countrycode code pays (FR, ...)
|
||||
* \return string chaine traduite
|
||||
*/
|
||||
function transcountry($str, $countrycode)
|
||||
{
|
||||
if ($this->tab_translate["$str$countrycode"]) return $this->trans("$str$countrycode");
|
||||
else return $this->trans($str);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Retourne la version traduite du texte passe en parametre complete du code pays
|
||||
* \param str chaine a traduire
|
||||
* \param countrycode code pays (FR, ...)
|
||||
* \return string chaine traduite
|
||||
*/
|
||||
function transcountrynoentities($str, $countrycode)
|
||||
{
|
||||
if ($this->tab_translate["$str$countrycode"]) return $this->transnoentities("$str$countrycode");
|
||||
else return $this->transnoentities($str);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Convert a string into output charset (this->charset_output that should be defined to conf->file->character_set_client)
|
||||
* \param str String to convert
|
||||
* \param pagecodefrom Page code of src string
|
||||
* \return string Converted string
|
||||
*/
|
||||
function convToOutputCharset($str,$pagecodefrom='UTF-8')
|
||||
{
|
||||
if ($pagecodefrom == 'ISO-8859-1' && $this->charset_output == 'UTF-8') $str=utf8_encode($str);
|
||||
if ($pagecodefrom == 'UTF-8' && $this->charset_output == 'ISO-8859-1') $str=utf8_decode($str);
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Retourne la liste des langues disponibles
|
||||
* \return array list of languages
|
||||
*/
|
||||
function get_available_languages($langdir=DOL_DOCUMENT_ROOT)
|
||||
{
|
||||
// We scan directory langs to detect available languages
|
||||
$handle=opendir($langdir ."/langs");
|
||||
$langs_available=array();
|
||||
while ($file = trim(readdir($handle)))
|
||||
{
|
||||
if (eregi('^[a-z]+_[A-Z]+',$file))
|
||||
{
|
||||
array_push($langs_available,$file);
|
||||
}
|
||||
}
|
||||
return $langs_available;
|
||||
}
|
||||
/**
|
||||
* \brief Retourne la liste des langues disponibles
|
||||
* \return array list of languages
|
||||
*/
|
||||
function get_available_languages($langdir=DOL_DOCUMENT_ROOT)
|
||||
{
|
||||
// We scan directory langs to detect available languages
|
||||
$handle=opendir($langdir ."/langs");
|
||||
$langs_available=array();
|
||||
while ($file = trim(readdir($handle)))
|
||||
{
|
||||
if (eregi('^[a-z]+_[A-Z]+',$file))
|
||||
{
|
||||
array_push($langs_available,$file);
|
||||
}
|
||||
}
|
||||
return $langs_available;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Renvoi si le fichier $filename existe dans la version de la langue courante ou alternative
|
||||
* \param filename nom du fichier <EFBFBD> rechercher
|
||||
* \param searchalt cherche aussi dans langue alternative
|
||||
* \return boolean true si existe, false sinon
|
||||
*/
|
||||
function file_exists($filename,$searchalt=0)
|
||||
{
|
||||
// Test si fichier dans repertoire de la langue
|
||||
/**
|
||||
* \brief Renvoi si le fichier $filename existe dans la version de la langue courante ou alternative
|
||||
* \param filename nom du fichier <EFBFBD> rechercher
|
||||
* \param searchalt cherche aussi dans langue alternative
|
||||
* \return boolean true si existe, false sinon
|
||||
*/
|
||||
function file_exists($filename,$searchalt=0)
|
||||
{
|
||||
// Test si fichier dans repertoire de la langue
|
||||
foreach($this->dir as $searchdir)
|
||||
{
|
||||
$htmlfile=$searchdir."/langs/".$this->defaultlang."/".$filename;
|
||||
if (is_readable($htmlfile)) return true;
|
||||
$htmlfile=$searchdir."/langs/".$this->defaultlang."/".$filename;
|
||||
if (is_readable($htmlfile)) return true;
|
||||
|
||||
if ($searchalt) {
|
||||
// Test si fichier dans repertoire de la langue alternative
|
||||
if ($this->defaultlang != "en_US") $htmlfilealt = $searchdir."/langs/en_US/".$filename;
|
||||
else $htmlfilealt = $searchdir."/langs/fr_FR/".$filename;
|
||||
if (is_readable($htmlfilealt)) return true;
|
||||
}
|
||||
if ($searchalt) {
|
||||
// Test si fichier dans repertoire de la langue alternative
|
||||
if ($this->defaultlang != "en_US") $htmlfilealt = $searchdir."/langs/en_US/".$filename;
|
||||
else $htmlfilealt = $searchdir."/langs/fr_FR/".$filename;
|
||||
if (is_readable($htmlfilealt)) return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Return a label for a key. Store key-label in a cache.
|
||||
* \param db Database handler
|
||||
* \param key Key to get label (key in language file)
|
||||
* \param tablename Table name without prefix
|
||||
* \param fieldkey Field for key
|
||||
* \param fieldlabel Field for label
|
||||
* \param fieldval Value to find record
|
||||
* \return string Label
|
||||
* \remarks This function can be used to get label in database but more often to get code from key id.
|
||||
*/
|
||||
function getLabelFromKey($db,$key,$tablename,$fieldkey,$fieldlabel)
|
||||
{
|
||||
// If key empty
|
||||
/**
|
||||
* \brief Return a label for a key. Store key-label in a cache.
|
||||
* \param db Database handler
|
||||
* \param key Key to get label (key in language file)
|
||||
* \param tablename Table name without prefix
|
||||
* \param fieldkey Field for key
|
||||
* \param fieldlabel Field for label
|
||||
* \param fieldval Value to find record
|
||||
* \return string Label
|
||||
* \remarks This function can be used to get label in database but more often to get code from key id.
|
||||
*/
|
||||
function getLabelFromKey($db,$key,$tablename,$fieldkey,$fieldlabel)
|
||||
{
|
||||
// If key empty
|
||||
if ($key == '') return '';
|
||||
|
||||
// Check in language array
|
||||
if ($this->transnoentities($key) != $key)
|
||||
{
|
||||
return $this->transnoentities($key); // Found in language array
|
||||
}
|
||||
if ($this->transnoentities($key) != $key)
|
||||
{
|
||||
return $this->transnoentities($key); // Found in language array
|
||||
}
|
||||
|
||||
// Check in cache
|
||||
if (isset($this->cache_labels[$tablename][$key])) // Can be defined to 0 or ''
|
||||
{
|
||||
return $this->cache_labels[$tablename][$key]; // Found in cache
|
||||
}
|
||||
if (isset($this->cache_labels[$tablename][$key])) // Can be defined to 0 or ''
|
||||
{
|
||||
return $this->cache_labels[$tablename][$key]; // Found in cache
|
||||
}
|
||||
|
||||
$sql = "SELECT ".$fieldlabel." as label";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$tablename;
|
||||
$sql.= " WHERE ".$fieldkey." = '".$key."'";
|
||||
dol_syslog('Translate::getLabelFromKey sql='.$sql,LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
if ($obj) $this->cache_labels[$tablename][$key]=$obj->label;
|
||||
else $this->cache_labels[$tablename][$key]='';
|
||||
$db->free($resql);
|
||||
return $this->cache_labels[$tablename][$key];
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "SELECT ".$fieldlabel." as label";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$tablename;
|
||||
$sql.= " WHERE ".$fieldkey." = '".$key."'";
|
||||
dol_syslog('Translate::getLabelFromKey sql='.$sql,LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
if ($obj) $this->cache_labels[$tablename][$key]=$obj->label;
|
||||
else $this->cache_labels[$tablename][$key]='';
|
||||
$db->free($resql);
|
||||
return $this->cache_labels[$tablename][$key];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$db->lasterror();
|
||||
dol_syslog("Translate::getLabelFromKey error=".$this->error,LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user