From 845deb9a63b9c26fb50b4b6b643deb829dbbf13f Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas <maxime@atm-consulting.fr> Date: Tue, 8 Oct 2013 09:17:04 +0200 Subject: [PATCH] Add multilang management in ODT models --- htdocs/core/class/translate.class.php | 10 ++++++++++ .../commande/doc/doc_generic_order_odt.modules.php | 14 +++++++++++++- .../doc/doc_generic_shipment_odt.modules.php | 14 +++++++++++++- .../doc/doc_generic_invoice_odt.modules.php | 14 +++++++++++++- .../pdf/doc_generic_project_odt.modules.php | 14 +++++++++++++- .../doc/doc_generic_proposal_odt.modules.php | 14 +++++++++++++- .../societe/doc/doc_generic_odt.modules.php | 12 ++++++++++++ 7 files changed, 87 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index ffa06230d20..a4830ebe0a9 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -784,6 +784,16 @@ class Translate return -1; } } + + function get_translations_for_substitutions() { + $substitutionarray = array(); + + foreach($this->tab_translate as $code => $label) { + $substitutionarray['lang_'.$code] = $label; + } + + return $substitutionarray; + } } ?> diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index b4c115bbac2..e195e55e214 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -74,7 +74,7 @@ class doc_generic_order_odt extends ModelePDFCommandes $this->option_modereg = 0; // Affiche mode reglement $this->option_condreg = 0; // Affiche conditions reglement $this->option_codeproduitservice = 0; // Affiche code produit-service - $this->option_multilang = 0; // Dispo en plusieurs langues + $this->option_multilang = 1; // Dispo en plusieurs langues $this->option_escompte = 0; // Affiche si il y a eu escompte $this->option_credit_note = 0; // Support credit notes $this->option_freetext = 1; // Support add of a personalised text @@ -534,6 +534,18 @@ class doc_generic_order_odt extends ModelePDFCommandes dol_syslog($this->error, LOG_WARNING); return -1; } + + // Replace labels translated + $tmparray=$outputlangs->get_translations_for_substitutions(); + foreach($tmparray as $key=>$value) + { + try { + $odfHandler->setVars($key, $value, true, 'UTF-8'); + } + catch(OdfException $e) + { + } + } // Call the beforeODTSave hook $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); diff --git a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php index a5b975430d3..73571a65646 100644 --- a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php +++ b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php @@ -74,7 +74,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition $this->option_modereg = 0; // Affiche mode reglement $this->option_condreg = 0; // Affiche conditions reglement $this->option_codeproduitservice = 0; // Affiche code produit-service - $this->option_multilang = 0; // Dispo en plusieurs langues + $this->option_multilang = 1; // Dispo en plusieurs langues $this->option_escompte = 0; // Affiche si il y a eu escompte $this->option_credit_note = 0; // Support credit notes $this->option_freetext = 1; // Support add of a personalised text @@ -534,6 +534,18 @@ class doc_generic_shipment_odt extends ModelePdfExpedition dol_syslog($this->error, LOG_WARNING); return -1; } + + // Replace labels translated + $tmparray=$outputlangs->get_translations_for_substitutions(); + foreach($tmparray as $key=>$value) + { + try { + $odfHandler->setVars($key, $value, true, 'UTF-8'); + } + catch(OdfException $e) + { + } + } // Call the beforeODTSave hook $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index 1f0120c2074..084dee16402 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -74,7 +74,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures $this->option_modereg = 0; // Affiche mode reglement $this->option_condreg = 0; // Affiche conditions reglement $this->option_codeproduitservice = 0; // Affiche code produit-service - $this->option_multilang = 0; // Dispo en plusieurs langues + $this->option_multilang = 1; // Dispo en plusieurs langues $this->option_escompte = 0; // Affiche si il y a eu escompte $this->option_credit_note = 0; // Support credit notes $this->option_freetext = 1; // Support add of a personalised text @@ -514,6 +514,18 @@ class doc_generic_invoice_odt extends ModelePDFFactures dol_syslog($this->error, LOG_WARNING); return -1; } + + // Replace labels translated + $tmparray=$outputlangs->get_translations_for_substitutions(); + foreach($tmparray as $key=>$value) + { + try { + $odfHandler->setVars($key, $value, true, 'UTF-8'); + } + catch(OdfException $e) + { + } + } // Call the beforeODTSave hook $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); diff --git a/htdocs/core/modules/project/pdf/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/pdf/doc_generic_project_odt.modules.php index bb1252d7dc9..3e0b9c93fb4 100644 --- a/htdocs/core/modules/project/pdf/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/pdf/doc_generic_project_odt.modules.php @@ -90,7 +90,7 @@ class doc_generic_project_odt extends ModelePDFProjects $this->option_modereg = 0; // Affiche mode reglement $this->option_condreg = 0; // Affiche conditions reglement $this->option_codeproduitservice = 0; // Affiche code produit-service - $this->option_multilang = 0; // Dispo en plusieurs langues + $this->option_multilang = 1; // Dispo en plusieurs langues $this->option_escompte = 0; // Affiche si il y a eu escompte $this->option_credit_note = 0; // Support credit notes $this->option_freetext = 1; // Support add of a personalised text @@ -976,6 +976,18 @@ class doc_generic_project_odt extends ModelePDFProjects dol_syslog($this->error, LOG_WARNING); return -1; } + + // Replace labels translated + $tmparray=$outputlangs->get_translations_for_substitutions(); + foreach($tmparray as $key=>$value) + { + try { + $odfHandler->setVars($key, $value, true, 'UTF-8'); + } + catch(OdfException $e) + { + } + } // Call the beforeODTSave hook $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index 45c4d6e9755..7843cf8e057 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -74,7 +74,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales $this->option_modereg = 0; // Affiche mode reglement $this->option_condreg = 0; // Affiche conditions reglement $this->option_codeproduitservice = 0; // Affiche code produit-service - $this->option_multilang = 0; // Dispo en plusieurs langues + $this->option_multilang = 1; // Dispo en plusieurs langues $this->option_escompte = 0; // Affiche si il y a eu escompte $this->option_credit_note = 0; // Support credit notes $this->option_freetext = 1; // Support add of a personalised text @@ -487,6 +487,18 @@ class doc_generic_proposal_odt extends ModelePDFPropales dol_syslog($this->error, LOG_WARNING); return -1; } + + // Replace labels translated + $tmparray=$outputlangs->get_translations_for_substitutions(); + foreach($tmparray as $key=>$value) + { + try { + $odfHandler->setVars($key, $value, true, 'UTF-8'); + } + catch(OdfException $e) + { + } + } // Call the beforeODTSave hook $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index d1f06c6f9ec..1259177432f 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -318,6 +318,18 @@ class doc_generic_odt extends ModeleThirdPartyDoc // setVars failed, probably because key not found } } + + // Replace labels translated + $tmparray=$outputlangs->get_translations_for_substitutions(); + foreach($tmparray as $key=>$value) + { + try { + $odfHandler->setVars($key, $value, true, 'UTF-8'); + } + catch(OdfException $e) + { + } + } // Call the beforeODTSave hook $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); -- GitLab