vgritsenko    02/02/07 06:23:15

  Modified:    src/java/org/apache/cocoon/transformation
                        I18nTransformer.java
  Log:
  Applied patch from Piroumian, Konstantin [[EMAIL PROTECTED]]
  
  Revision  Changes    Path
  1.11      +28 -38    
xml-cocoon2/src/java/org/apache/cocoon/transformation/I18nTransformer.java
  
  Index: I18nTransformer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/I18nTransformer.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- I18nTransformer.java      7 Feb 2002 07:41:24 -0000       1.10
  +++ I18nTransformer.java      7 Feb 2002 14:23:15 -0000       1.11
  @@ -229,7 +229,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Marcus Crafter</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Michael Enke</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Lassi Immonen</a>
  - * @version CVS $Id: I18nTransformer.java,v 1.10 2002/02/07 07:41:24 cziegeler Exp $
  + * @version CVS $Id: I18nTransformer.java,v 1.11 2002/02/07 14:23:15 vgritsenko Exp 
$
    *
    * @todo Move all formatting/parsing routines to I18nUtils
    */
  @@ -588,6 +588,9 @@
   
       // Date pattern types map: short, medium, long, full
       private static final Map datePatterns;
  +     
  +    // String buffer 
  +    private StringBuffer strBuffer;
   
       static {
           // initialize date types set
  @@ -899,6 +902,8 @@
           throws SAXException {
   
           debug("Start i18n element: " + name);
  +        //initialize the string buffer
  +        strBuffer = new StringBuffer();
   
           if (I18N_TEXT_ELEMENT.equals(name)) {
               if (current_state != STATE_OUTSIDE
  @@ -1028,40 +1033,11 @@
   
       private void endI18NElement(String name) throws SAXException {
           debug("End i18n element: " + name);
  -        switch (current_state) {
  -        case STATE_INSIDE_TEXT:
  -            endTextElement();
  -            break;
  -
  -        case STATE_INSIDE_TRANSLATE:
  -            endTranslateElement();
  -            break;
  -
  -        case STATE_INSIDE_PARAM:
  -            endParamElement();
  -            break;
  -
  -        case STATE_INSIDE_DATE:
  -        case STATE_INSIDE_DATE_TIME:
  -        case STATE_INSIDE_TIME:
  -            endDate_TimeElement();
  -            break;
  -
  -        case STATE_INSIDE_NUMBER:
  -            endNumberElement();
  -            break;
  -        }
  -    }
  -
  -    private void i18nCharacters(char[] ch, int start, int len)
  -        throws SAXException {
  -
  -        String textValue = new String(ch, start, len).trim();
  -        if (textValue == null || textValue.length() == 0) {
  +        
  +        if (strBuffer.length() == 0) {
               return;
           }
  -
  -        debug( "i18n message text = '" + textValue + "'" );
  +        debug( "i18n message text = '" + strBuffer.toString() + "'" );
   
           switch (current_state) {
           case STATE_INSIDE_TEXT:
  @@ -1070,39 +1046,46 @@
   
                   // If no translation found and untranslated param is null
                   if (translated_text == null) {
  -                    translated_text = textValue;  // use the key
  +                    translated_text = strBuffer.toString();  // use the key
                   }
   
                   // reset the key holding variable
                   current_key = null;
               } else {    // use text value as dictionary key
  -                translated_text = getString(textValue, (untranslated == null) ? 
textValue : untranslated);
  +                translated_text = getString(strBuffer.toString(), 
  +                    (untranslated == null) ? strBuffer.toString(): untranslated);
               }
  +            endTextElement();
               break;
   
           case STATE_INSIDE_TRANSLATE:
               // Store text for param substitution (do not translate)
               if (substitute_text == null) {
  -                substitute_text = textValue;
  +                substitute_text = strBuffer.toString();
               }
  +            endTranslateElement();
               break;
   
           case STATE_INSIDE_PARAM:
               // Store translation for param substitution
               if (param_value == null) {
  -                param_value = textValue;
  +                param_value = strBuffer.toString();
               }
  +            endParamElement();
               break;
   
           case STATE_INSIDE_DATE:
           case STATE_INSIDE_DATE_TIME:
           case STATE_INSIDE_TIME:
  +            endDate_TimeElement();
  +            break;
           case STATE_INSIDE_NUMBER:
               if (formattingParams.get(I18N_VALUE_ATTRIBUTE) == null) {
  -                formattingParams.put(I18N_VALUE_ATTRIBUTE, textValue);
  +                formattingParams.put(I18N_VALUE_ATTRIBUTE, strBuffer.toString());
               } else {
                   ; // ignore the text inside of date element
               }
  +            endNumberElement();
               break;
   
           default:
  @@ -1112,6 +1095,12 @@
           }
       }
   
  +    private void i18nCharacters(char[] ch, int start, int len)
  +        throws SAXException {
  +       
  +       strBuffer.append(new String(ch, start, len).trim());
  +    }
  +
       // Translate all attributes that are listed in i18n:attr attribute
       private Attributes translateAttributes(String name, Attributes attr)
           throws SAXException {
  @@ -1519,6 +1508,7 @@
   
           factory.release(dictionary);
           dictionary = null;
  +        strBuffer = null;
       }
   
       public void dispose() {
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to