fixed bug 009353: With the application in spanish, terms of some reports are in English
authorAsier Lostalé <asier.lostale@openbravo.com>
Mon, 22 Jun 2009 08:04:09 +0200
changeset 4047 906b65e00d8e
parent 4046 57ea1a88ce44
child 4048 d516efd4a732
fixed bug 009353: With the application in spanish, terms of some reports are in English
Fixed several problems in online translation:
-Template was not properly selected for files not ending in .html
-Langauge was not taken for templates without language tag (reported as issue 8070)
-Text was not properly trimmed when doing the online translation
src-core/src/org/openbravo/base/HttpBaseServlet.java
src-core/src/org/openbravo/uiTranslation/TranslationUtils.java
src-core/src/org/openbravo/xmlEngine/XmlDocument.java
src-core/src/org/openbravo/xmlEngine/XmlEngine.java
--- a/src-core/src/org/openbravo/base/HttpBaseServlet.java	Fri Jun 19 12:30:17 2009 +0200
+++ b/src-core/src/org/openbravo/base/HttpBaseServlet.java	Mon Jun 22 08:04:09 2009 +0200
@@ -195,6 +195,7 @@
       strLanguage = "";
     }
     xmlEngine.fileBaseLocation = new File(getBaseDesignPath(strLanguage));
+    xmlEngine.sessionLanguage = strLanguage;
     strReplaceWith = globalParameters.strLocalReplaceWith.replace("@actual_url@", strActualUrl)
         .replace("@actual_url_context@", strDireccion);
     strReplaceWithFull = strReplaceWith;
--- a/src-core/src/org/openbravo/uiTranslation/TranslationUtils.java	Fri Jun 19 12:30:17 2009 +0200
+++ b/src-core/src/org/openbravo/uiTranslation/TranslationUtils.java	Mon Jun 22 08:04:09 2009 +0200
@@ -1,3 +1,22 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SL 
+ * All portions are Copyright (C) 2008-2009 Openbravo SL 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
 package org.openbravo.uiTranslation;
 
 import java.util.ArrayList;
@@ -199,7 +218,8 @@
 
   private static void populateLabelMap() {
     for (int i = 0; i < textData.length; i++) {
-      textmap.put(textData[i].text, textData[i].trltext);
+      // trim values, in some occasions there is a character 160 representing blank spaces
+      textmap.put(textData[i].text.replace((char) 160, ' ').trim(), textData[i].trltext);
     }
   }
 }
--- a/src-core/src/org/openbravo/xmlEngine/XmlDocument.java	Fri Jun 19 12:30:17 2009 +0200
+++ b/src-core/src/org/openbravo/xmlEngine/XmlDocument.java	Mon Jun 22 08:04:09 2009 +0200
@@ -1,6 +1,6 @@
 /*
  ************************************************************************************
- * Copyright (C) 2001-2006 Openbravo S.L.
+ * Copyright (C) 2001-2009 Openbravo S.L.
  * Licensed under the Apache Software License version 2.0
  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
  * Unless required by applicable law or agreed to  in writing,  software  distributed
@@ -229,10 +229,13 @@
     if (!ignoreTranslation && xmlTemplate != null && xmlTemplate.strName != null) {
       if (log4jXmlDocument.isDebugEnabled())
         log4jXmlDocument.debug("Start of print of: " + xmlTemplate.strName);
-
       final TranslationHandler handler = new TranslationHandler(
           this.xmlTemplate.xmlEngine.connProvider, this);
-      handler.setFileName(xmlTemplate.strName.replace("designorg/", "/org/") + ".html");
+      String baseDirectory = xmlTemplate.strName.substring(0, xmlTemplate.strName.lastIndexOf("/"))
+          .replace("designorg/", "/org/");
+      String templateFileName = xmlTemplate.configuration.strTemplate;
+      String absoluteTemplateFile = baseDirectory + "/" + templateFileName;
+      handler.setFileName(absoluteTemplateFile);
 
       log4jXmlDocument.debug("print() - xmlTemplate.xmlEngine.fileBaseLocation: "
           + xmlTemplate.xmlEngine.fileBaseLocation);
@@ -252,19 +255,8 @@
           handler.setXmlDocumentType(TranslationHandler.PROCESS);
           handler.setXmlDocumentTypeId(hasParameterValue.get("processId").strValue);
         }
-        if (hasParameterValue.get("language") != null
-            && hasParameterValue.get("language").strValue != null) {
-          log4jXmlDocument.debug("print(strBlank) - language: "
-              + hasParameterValue.get("language").strValue);
-          handler.setLanguage(hasParameterValue.get("language").strValue
-              .replace("defaultLang=", "").replace("\"", ""));
-        } else if (hasParameterValue.get("paramLanguage") != null
-            && hasParameterValue.get("paramLanguage").strValue != null) {
-          log4jXmlDocument.debug("print(strBlank) - language: "
-              + hasParameterValue.get("paramLanguage").strValue);
-          handler.setLanguage(hasParameterValue.get("paramLanguage").strValue.replace(
-              "defaultLang=", "").replace("\"", ""));
-        }
+        handler.setLanguage(xmlTemplate.xmlEngine.sessionLanguage);
+
         log4jXmlDocument.debug("before running generateTranslations.");
         handler.generateTranslations();
         if (!ignoreTranslation && handler.getFormLabels() != null
@@ -319,7 +311,7 @@
               if (CharacterComponent.class.isInstance(componentTemplate)) {
                 CharacterComponent charComponent = (CharacterComponent) componentTemplate;
                 if (charComponent.character != null && !charComponent.equals("")) {
-                  String original = charComponent.character;
+                  String original = charComponent.character.trim();
                   String trl = xmlVectorValue.getTextMap().get(original);
                   if (trl != null && !trl.equals(""))
                     charComponent.character = trl;
@@ -337,7 +329,7 @@
               if (CharacterComponent.class.isInstance(componentTemplate)) {
                 CharacterComponent charComponent = (CharacterComponent) componentTemplate;
                 if (charComponent.character != null && !charComponent.equals("")) {
-                  String original = charComponent.character;
+                  String original = charComponent.character.trim();
                   String trl = xmlVectorValue.getTextMap().get(original);
                   if (trl != null && !trl.equals(""))
                     charComponent.character = trl;
--- a/src-core/src/org/openbravo/xmlEngine/XmlEngine.java	Fri Jun 19 12:30:17 2009 +0200
+++ b/src-core/src/org/openbravo/xmlEngine/XmlEngine.java	Mon Jun 22 08:04:09 2009 +0200
@@ -49,6 +49,7 @@
   String strFormatFile;
   public File fileXmlEngineFormat;
   public File fileBaseLocation;
+  public String sessionLanguage;
   public String strReplaceWhat;
   public String strReplaceWith;
   public boolean isResource = false;