New: Gestion de l'internationalisation de dolibar. On choisit la langue d'affichage dans Configuration - Configuration IHM - Langue par defaut. Pour ajouter une traduction, il suffit de copier un fichier du nouveau code langue dans le repertoire langs. Dans le code pour que les langues soit gres, il faut au lieu de mettre en dur le texte en franais par exemple 'Socit', mettre $langs->trans('Socit')
This commit is contained in:
parent
734f2ef97d
commit
c32cbbc626
@ -35,7 +35,7 @@ $tabid[3] = "llx_c_regions";
|
||||
$tabid[4] = "llx_c_pays";
|
||||
|
||||
$tabnom[1] = "Formes juridiques";
|
||||
$tabnom[2] = "Départements";
|
||||
$tabnom[2] = "Départements/Provinces/Cantons";
|
||||
$tabnom[3] = "Régions";
|
||||
$tabnom[4] = "Pays";
|
||||
|
||||
|
||||
@ -100,9 +100,15 @@ if ($_GET["action"] == 'edit')
|
||||
print '</select>';
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr class="pair"><td width="50%">Langue par défaut à utiliser (fr, ...)</td><td>';
|
||||
print '<tr class="pair"><td width="50%">Langue par défaut à utiliser (code langue)</td><td>';
|
||||
print '<select name="main_lang_default">';
|
||||
print '<option value="fr" selected>fr (seul le français est géré pour l\'instant)</option>';
|
||||
// On parcour le répertoire langs pour détecter les langues possibles
|
||||
$handle=opendir(DOL_DOCUMENT_ROOT ."/langs");
|
||||
while ($file = trim(readdir($handle))){
|
||||
if($file != "." && $file != ".." && $file != "CVS") {
|
||||
print '<option value="'.$file.'"'.(MAIN_LANG_DEFAULT==$file?'selected':'').'>'.$file.'</option>';
|
||||
}
|
||||
}
|
||||
print '</select>';
|
||||
print '</td></tr>';
|
||||
|
||||
@ -128,7 +134,7 @@ else
|
||||
$filelib=eregi_replace('\.php$','',MAIN_MENU_BARRETOP);
|
||||
print $filelib;
|
||||
print '</td></tr>';
|
||||
print '<tr class="pair"><td width="50%">Langue par défaut à utiliser (fr, en...)</td><td>' . MAIN_LANG_DEFAULT . '</td></tr>';
|
||||
print '<tr class="pair"><td width="50%">Langue par défaut à utiliser (code langue)</td><td>' . MAIN_LANG_DEFAULT . '</td></tr>';
|
||||
print '<tr class="impair"><td>Afficher zone de recherche Contacts dans le menu gauche</td><td>' . (MAIN_SEARCHFORM_CONTACT?"oui":"non") . '</td></tr>';
|
||||
print '<tr class="pair"><td>Afficher zone de recherche Sociétés dans le menu gauche</td><td>' . (MAIN_SEARCHFORM_SOCIETE?"oui":"non") . '</td></tr>';
|
||||
print '</table><br>';
|
||||
|
||||
@ -1,3 +1,21 @@
|
||||
#do not change next line please !
|
||||
#{@"htmltagoption"=>"nothing","charset"=>"iso-8859-1","name"=>"English"}
|
||||
User=User
|
||||
charset="iso-8859-1"
|
||||
|
||||
# Menus
|
||||
Société=Company
|
||||
|
||||
# Fiches sociétés
|
||||
Adresse=Address
|
||||
Téléphone=Phone
|
||||
|
||||
# Utilisateurs
|
||||
Auteur=Author
|
||||
Utilisateur=User
|
||||
|
||||
# Autre
|
||||
Choisissez votre langue=Please choose your language
|
||||
Ajouter=Add
|
||||
Supprimer=Delete
|
||||
Factures=Bills
|
||||
Facture=Bill
|
||||
Payé=Payed
|
||||
|
||||
@ -1,15 +1,5 @@
|
||||
#do not change next line please !
|
||||
#{@"htmltagoption"=>"nothing","charset"=>"iso-8859-1","name"=>"Français","translator_0"=>"Éric SEIGNE <erics@rycks.com>"}
|
||||
Please choose your language=Choisissez votre langue
|
||||
Add=Ajouter
|
||||
Commercial=Commercial
|
||||
Company=Société
|
||||
Date=Date
|
||||
Delete=Supprimer
|
||||
Bills=Factures
|
||||
Bill=Facture
|
||||
Propositions commerciales=Propositions commerciales
|
||||
Espace compta=Espace comptabilité
|
||||
Author=Auteur
|
||||
User=Utilisateur
|
||||
Payed=Payé
|
||||
charset="iso-8859-1"
|
||||
|
||||
# Le fichier de langue pour le francais n'a pas besoin d'etre rempli pour l'instant
|
||||
# Sa presence suffit
|
||||
|
||||
@ -395,8 +395,7 @@ if (! defined(MAIN_LANG_DEFAULT))
|
||||
define(MAIN_LANG_DEFAULT,"fr");
|
||||
}
|
||||
$conf->langage=MAIN_LANG_DEFAULT;
|
||||
$rtplang = new rtplang(DOL_DOCUMENT_ROOT ."/langs", $conf->langage, $conf->langage, $conf->langage);
|
||||
$rtplang->debug=1;
|
||||
$langs = new Translate(DOL_DOCUMENT_ROOT ."/langs", $conf->langage, $conf->langage, $conf->langage);
|
||||
|
||||
$lc=strtolower($conf->langage)."_".strtoupper($conf->langage); // lc vaut fr_FR par exemple
|
||||
setlocale(LC_TIME, $lc);
|
||||
@ -415,12 +414,12 @@ $bc[1]="class=\"pair\"";
|
||||
|
||||
function top_menu($head, $title="")
|
||||
{
|
||||
global $user, $conf, $rtplang;
|
||||
global $user, $conf, $langs;
|
||||
|
||||
print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
|
||||
print "\n<html>";
|
||||
|
||||
print $rtplang->lang_header();
|
||||
print $langs->lang_header();
|
||||
|
||||
// print "<HTML><HEAD>";
|
||||
print $head;
|
||||
|
||||
@ -86,7 +86,7 @@ if ($action == 'create')
|
||||
|
||||
print '<table class="border" cellpadding="3" cellspacing="0" width="100%">';
|
||||
print '<tr><td>Nom</td><td colspan="3"><input type="text" name="nom"></td></tr>';
|
||||
print '<tr><td>Adresse</td><td colspan="3"><textarea name="adresse" cols="30" rows="3" wrap="soft"></textarea></td></tr>';
|
||||
print '<tr><td>'.$langs->trans('Adresse').'</td><td colspan="3"><textarea name="adresse" cols="30" rows="3" wrap="soft"></textarea></td></tr>';
|
||||
print '<tr><td>CP</td><td><input size="6" type="text" name="cp"> ';
|
||||
print 'Ville <input type="text" name="ville"></td>';
|
||||
|
||||
@ -98,8 +98,8 @@ if ($action == 'create')
|
||||
print $form->select_pays($soc->pays_id);
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td>Téléphone</td><td><input type="text" name="tel"></td>';
|
||||
print '<td>Fax</td><td><input type="text" name="fax"></td></tr>';
|
||||
print '<tr><td>'.$langs->trans('Téléphone').'</td><td><input type="text" name="tel"></td>';
|
||||
print '<td>'.$langs->trans('Adresse').'</td><td><input type="text" name="fax"></td></tr>';
|
||||
|
||||
print '<tr><td>Web</td><td colspan="3">http://<input size="40" type="text" name="url"></td></tr>';
|
||||
|
||||
@ -158,7 +158,7 @@ elseif ($action == 'edit')
|
||||
|
||||
print '<table class="border" width="100%" cellpadding="3" cellspacing="0">';
|
||||
print '<tr><td>Nom</td><td colspan="3"><input type="text" size="40" name="nom" value="'.$soc->nom.'"></td></tr>';
|
||||
print '<tr><td valign="top">Adresse</td><td colspan="3"><textarea name="adresse" cols="30" rows="3" wrap="soft">';
|
||||
print '<tr><td valign="top">'.$langs->trans('Adresse').'</td><td colspan="3"><textarea name="adresse" cols="30" rows="3" wrap="soft">';
|
||||
print $soc->adresse;
|
||||
print '</textarea></td></tr>';
|
||||
|
||||
@ -172,8 +172,8 @@ elseif ($action == 'edit')
|
||||
print $form->select_pays($soc->pays_id);
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td>Téléphone</td><td><input type="text" name="tel" value="'.$soc->tel.'"></td>';
|
||||
print '<td>Fax</td><td><input type="text" name="fax" value="'.$soc->fax.'"></td></tr>';
|
||||
print '<tr><td>'.$langs->trans('Téléphone').'</td><td><input type="text" name="tel" value="'.$soc->tel.'"></td>';
|
||||
print '<td>'.$langs->trans('Fax').'</td><td><input type="text" name="fax" value="'.$soc->fax.'"></td></tr>';
|
||||
print '<tr><td>Web</td><td colspan="3">http://<input type="text" name="url" size="40" value="'.$soc->url.'"></td></tr>';
|
||||
|
||||
print '<tr><td>Siren</td><td><input type="text" name="siren" size="10" maxlength="9" value="'.$soc->siren.'"></td>';
|
||||
@ -286,16 +286,16 @@ else
|
||||
dolibarr_fiche_head($head, 0);
|
||||
|
||||
/*
|
||||
*
|
||||
* Fiche société en mode visu
|
||||
*/
|
||||
|
||||
print '<table class="border" cellpadding="3" cellspacing="0" width="100%">';
|
||||
print '<tr><td width="20%">Nom</td><td width="80%" colspan="3">'.$soc->nom.'</td></tr>';
|
||||
|
||||
print "<tr><td valign=\"top\">Adresse</td><td colspan=\"3\">".nl2br($soc->adresse)."<br>".$soc->cp." ".$soc->ville." ".$soc->pays."</td></tr>";
|
||||
print "<tr><td valign=\"top\">".$langs->trans('Adresse')."</td><td colspan=\"3\">".nl2br($soc->adresse)."<br>".$soc->cp." ".$soc->ville." ".$soc->pays."</td></tr>";
|
||||
|
||||
print '<tr><td>Téléphone</td><td>'.dolibarr_print_phone($soc->tel).'</td>';
|
||||
print '<td>Fax</td><td>'.dolibarr_print_phone($soc->fax).'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans('Téléphone').'</td><td>'.dolibarr_print_phone($soc->tel).'</td>';
|
||||
print '<td>'.$langs->trans('Fax').'</td><td>'.dolibarr_print_phone($soc->fax).'</td></tr>';
|
||||
print '<tr><td>Web</td><td colspan="3">';
|
||||
if ($soc->url) { print '<a href="http://'.$soc->url.'">http://'.$soc->url.'</a>'; }
|
||||
print '</td></tr>';
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/* ***************************************************************************
|
||||
* Copyright (C) 2001 Eric Seigne <erics@rycks.com>
|
||||
* Copyright (C) 2001 Eric Seigne <erics@rycks.com>
|
||||
* Copyright (C) 2004 Destailleur Laurent <eldy@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -16,7 +17,7 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
* ***************************************************************************
|
||||
* File : rtplang.class.php
|
||||
* File : translate.class.php
|
||||
* Author : Eric SEIGNE
|
||||
* mailto:erics@rycks.com
|
||||
* http://www.rycks.com/
|
||||
@ -28,7 +29,7 @@
|
||||
* ------------
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* @version 1.0
|
||||
* @author Eric Seigne
|
||||
* @project AbulEdu
|
||||
@ -36,84 +37,123 @@
|
||||
*
|
||||
* ************************************************************************* */
|
||||
|
||||
if(isset($RTPLANG_CLASS)){
|
||||
return;
|
||||
}
|
||||
$RTPLANG_CLASS=1;
|
||||
Class Translate {
|
||||
var $tab_langs;
|
||||
var $tab_translate;
|
||||
var $file_lang;
|
||||
/** Default language interface (isocode) */
|
||||
var $defaultiso;
|
||||
/** Source language (isocode) */
|
||||
var $sourceiso;
|
||||
/** This session language (isocode) */
|
||||
var $sessioniso;
|
||||
/** Where are languages files ? */
|
||||
var $dir;
|
||||
var $debug;
|
||||
|
||||
|
||||
Class rtplang {
|
||||
|
||||
//-------------------------------------------------
|
||||
/** Constructor */
|
||||
function rtplang($dir = "", $sourceiso = "", $defaultiso = "", $sessioniso = "")
|
||||
//-------------------------------------------------
|
||||
/** Constructor */
|
||||
function Translate($dir = "", $sourceiso = "", $defaultiso = "", $sessioniso = "")
|
||||
{
|
||||
}
|
||||
/**
|
||||
* Return translated version of parameter string
|
||||
* [fr] Retourne la version traduite du texte passé en paramètre
|
||||
* Si il n'y a pas de correspondance pour ce texte, il est retourné
|
||||
* "tel quel" précédé d'un "<b>[vo]</b> <i>" et terminé par un </i>
|
||||
*
|
||||
* @access public
|
||||
* @return string translated version of parameter string, or original version of this string with "<b>[vo]</b> <i>" before and "</i>" after
|
||||
* @param string $str original string to translate
|
||||
* @param int $mark bolean, 1 or nothing: add [vo] if this translation does not exists, 0 don't add [vo] tags
|
||||
*/
|
||||
function translate($str, $mark){
|
||||
$this->tab_langs = array();
|
||||
$this->tab_translate = array();
|
||||
$this->file_lang = "";
|
||||
$this->debug = 0;
|
||||
$this->dir = $dir;
|
||||
$this->sessioniso = $sessioniso;
|
||||
$this->sourceiso = $sourceiso;
|
||||
$this->defaultiso = $defaultiso;
|
||||
|
||||
if ($sessioniso == 'fr') {
|
||||
// Français demandé, on ne fait rien
|
||||
return;
|
||||
}
|
||||
|
||||
$retour = $str;
|
||||
//Si on a une langue par defaut
|
||||
if(($this->defaultiso != "") && ($this->sessioniso == ""))
|
||||
$this->file_lang = $this->dir . "/" . $this->defaultiso;
|
||||
else if($this->sessioniso != "")
|
||||
$this->file_lang = $this->dir . "/" . $this->sessioniso;
|
||||
|
||||
return $retour;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of available languages
|
||||
* [fr] Retourne la liste des langues disponibles
|
||||
*
|
||||
* @access public
|
||||
* @return array: list of languages
|
||||
*/
|
||||
function get_available_languages()
|
||||
{
|
||||
/* initialize tabs */
|
||||
$i = 0;
|
||||
if(is_dir($this->dir)) {
|
||||
$filet = $this->dir . "/" . $sessioniso;
|
||||
//print "Ouverture fichier $filet";
|
||||
if($fp = @fopen($filet,"rt")){
|
||||
$finded = 0;
|
||||
while (($ligne = fgets($fp,4096)) && ($finded == 0)){
|
||||
if ($ligne[0] != "\n" && $ligne[0] != " " && $ligne[0] != "#") {
|
||||
$tab=split('=',$ligne);
|
||||
//print "Found a string for $tab[0] with value $tab[1]<br>";
|
||||
$this->tab_translate[$tab[0]]=$tab[1];
|
||||
}
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Send header and return a string of html start page
|
||||
* [fr] Expédie le header correct et retourne le début de la page html
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
function lang_header()
|
||||
{
|
||||
|
||||
$charset = "iso-8859-1";
|
||||
|
||||
//header("Content-Type: text/html; charset=$charset");
|
||||
$texte .= "
|
||||
<head>
|
||||
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=$charset\">\n";
|
||||
|
||||
return $texte;
|
||||
/*
|
||||
* Return translated version of parameter string
|
||||
* [fr] Retourne la version traduite du texte passé en paramètre
|
||||
* Si il n'y a pas de correspondance pour ce texte, il est retourn
|
||||
* "tel quel" précédé d'un "<b>[vo]</b> <i>" et terminé par un </i>
|
||||
*
|
||||
* @access public
|
||||
* @return string translated version of parameter string, or original version of this string with "<b>[vo]</b> <i>" before and "</i>" after
|
||||
* @param string $str original string to translate
|
||||
* @param int $mark bolean, 1 or nothing: add [vo] if this translation does not exists, 0 don't add [vo] tags
|
||||
*/
|
||||
function trans($str) {
|
||||
if ($this->tab_translate[$str]) {
|
||||
// Si la traduction est disponible
|
||||
|
||||
return $this->tab_translate[$str];
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of available languages
|
||||
* [fr] Retourne la liste des langues disponibles
|
||||
*
|
||||
* @access public
|
||||
* @return array: list of languages
|
||||
*/
|
||||
function get_available_languages()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Send header and return a string of html start page
|
||||
* [fr] Expédie le header correct et retourne le début de la page html
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
function lang_header()
|
||||
{
|
||||
|
||||
$charset = "iso-8859-1";
|
||||
|
||||
//header("Content-Type: text/html; charset=$charset");
|
||||
$texte .= "<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=$charset\">\n";
|
||||
|
||||
return $texte;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Return translated version of parameter string
|
||||
* [fr] Retourne la version traduite du texte passé en paramètre
|
||||
* Si il n'y a pas de correspondance pour ce texte, il est retourné
|
||||
* "tel quel" précédé d'un "<b>[vo]</b> <i>" et terminé par un </i>
|
||||
*
|
||||
* @access public
|
||||
* @return string translated version of parameter string, or original version of this string with "<b>[vo]</b> <i>" before and "</i>" after
|
||||
* @param string $str original string to translate
|
||||
* @param int $mark bolean, 1 or nothing: add [vo] if this translation does not exists, 0 don't add [vo] tags
|
||||
*/
|
||||
function translate($str, $mark = 1){
|
||||
// Pour compatibilité avec l'existant. Il existe quelques appels a une fonction
|
||||
// tranlsate. On l'implémente donc ici mais il vaut mieux utiliser $langs->trans
|
||||
function translate($str) {
|
||||
|
||||
return $str;
|
||||
return $str;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user