dims        01/06/15 08:01:22

  Modified:    src/org/apache/cocoon/transformation I18nTransformer2.java
               webapp/i18n simple.xml simple.xsl simple.xsp
               webapp/i18n/translations simple_dict.xml
               xdocs    i18n.xml
  Log:
  Patches for i18nTransformer from Konstantin
  
  Revision  Changes    Path
  1.10      +375 -75   
xml-cocoon2/src/org/apache/cocoon/transformation/I18nTransformer2.java
  
  Index: I18nTransformer2.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/org/apache/cocoon/transformation/I18nTransformer2.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- I18nTransformer2.java     2001/06/01 16:14:57     1.9
  +++ I18nTransformer2.java     2001/06/15 15:01:06     1.10
  @@ -37,8 +37,15 @@
   import java.util.StringTokenizer;
   import java.util.ArrayList;
   import java.util.Locale;
  +import java.util.Date;
   
  +import java.text.Format;
   import java.text.MessageFormat;
  +import java.text.DateFormat;
  +import java.text.SimpleDateFormat;
  +import java.text.NumberFormat;
  +import java.text.DecimalFormat;
  +import java.text.ParseException;
   
   import java.net.URL;
   import java.net.MalformedURLException;
  @@ -132,23 +139,43 @@
       public final static String I18N_DATE_ELEMENT = "date";
       public final static String I18N_NUMBER_ELEMENT = "number";
   
  +    // number and date formatting attributes
  +    public final static String I18N_SRC_PATTERN_ATTRIBUTE = "src-pattern";
  +    public final static String I18N_PATTERN_ATTRIBUTE = "pattern";
  +    public final static String I18N_VALUE_ATTRIBUTE = "value";
  +    /**
  +     * <code>sub-type</code> attribute is used with <code>i18:number</code> 
to indicate
  +     * a sub-type: <code>currency</code> or <code>percent</code>.
  +     */
  +    public final static String I18N_SUB_TYPE_ATTRIBUTE = "sub-type";
  +    /**
  +     * <code>type</code> attribute is used with <code>i18:param</code> to 
indicate
  +     * the parameter type: <code>date</code> or <code>number</code>.
  +     * If <code>type</code> is <code>number</code> then a 
<code>sub-type</code>
  +     * can be used.
  +     */
  +    public final static String I18N_TYPE_ATTRIBUTE = "type";
  +
       // States of the transformer
       private final static int STATE_OUTSIDE = 0;
       private final static int STATE_INSIDE_TEXT = 1;
       private final static int STATE_INSIDE_PARAM = 2;
       private final static int STATE_INSIDE_TRANSLATE = 3;
  -//    private final static int STATE_INSIDE_PARAM_TEXT = 4;
  -    private final static int STATE_INSIDE_TRANSLATE_TEXT = 5;
  -    private final static int STATE_TRANSLATE_KEY = 6;
  -    private final static int STATE_TRANSLATE_TEXT_KEY = 7;
  +    private final static int STATE_INSIDE_TRANSLATE_TEXT = 4;
  +    private final static int STATE_TRANSLATE_KEY = 5;
  +    private final static int STATE_TRANSLATE_TEXT_KEY = 6;
  +    private final static int STATE_INSIDE_DATE = 7;
  +    private final static int STATE_INSIDE_NUMBER = 8;
   
       /**
        * Current state of the transformer.
  +     * The value is STATE_OUTSIDE by default.
        */
       private int current_state = STATE_OUTSIDE;
   
       /**
  -     * Previous state. Used to translate text inside params and translate 
elements.
  +     * Previous state.
  +     * Used to translate text inside params and translate elements.
        */
        private int prev_state = STATE_OUTSIDE;
   
  @@ -205,13 +232,33 @@
        * Also, different encodings can be specified: ru_RU_koi8
        */
       private Locale locale;
  +
  +    /**
  +     * Date element attributes and their values.
  +     */
  +    private HashMap formattingParams;
  +
  +    public static Locale parseLocale(String locale) {
  +        StringTokenizer st = new StringTokenizer(locale, "_");
  +        String lang = null;
  +        String country = null;
  +        String variant = null;
  +        if (!st.hasMoreTokens()) {
  +            return Locale.ENGLISH;
  +        }
  +        else {
  +            lang = st.nextToken();
  +        }
   
  -    public void setLang(String lang) {
  -        this.lang = lang;
  +        country = st.hasMoreTokens() ? st.nextToken() : "";
  +        variant = st.hasMoreTokens() ? st.nextToken() : "";
  +
  +        return new Locale(lang, country, variant);
       }
   
       public void setLocale(Locale locale) {
           this.locale = locale;
  +        this.lang = locale.getLanguage();
       }
   
       /**
  @@ -228,26 +275,8 @@
           if (lang == null) {
               lang = LangSelect.getLang(objectModel, parameters);
           }
  -        setLang(lang);
   
  -        Locale locale = null;
  -        int ind = lang.indexOf("_");
  -        if (ind != -1) {
  -            int lind = lang.lastIndexOf("_");
  -            if (ind == lind) {
  -                locale = new Locale(lang.substring(0, ind - 1),
  -                    lang.substring(ind + 1));
  -            }
  -            else {
  -                locale = new Locale(lang.substring(0, ind - 1),
  -                    lang.substring(ind + 1, lind - 1),
  -                    lang.substring(lind + 1));
  -            }
  -        }
  -        else {
  -            locale = new Locale(lang, "");
  -        }
  -        setLocale(locale);
  +        setLocale(parseLocale(lang));
           formatter.setLocale(locale);
   
           // FIXME (KP)
  @@ -307,51 +336,126 @@
       private void startI18NElement(String name, Attributes attr)
       throws SAXException {
           this.getLogger().debug("Start i18n element: " + name);
  -        if (I18N_TEXT_ELEMENT.equals(name)) {
  -            if (current_state != STATE_OUTSIDE
  -                && current_state != STATE_INSIDE_PARAM
  -                && current_state != STATE_INSIDE_TRANSLATE) {
  -                throw new SAXException(this.getClass().getName()
  -                    + ": nested i18n:text elements are not allowed. Current 
state: " + current_state);
  +        try {
  +            if (I18N_TEXT_ELEMENT.equals(name)) {
  +                if (current_state != STATE_OUTSIDE
  +                    && current_state != STATE_INSIDE_PARAM
  +                    && current_state != STATE_INSIDE_TRANSLATE) {
  +                    throw new SAXException(this.getClass().getName()
  +                        + ": nested i18n:text elements are not allowed. 
Current state: " + current_state);
  +                }
  +                prev_state = current_state;
  +                current_state = STATE_INSIDE_TEXT;
  +                current_key = attr.getValue(I18N_NAMESPACE_URI, 
I18N_KEY_ATTRIBUTE);
               }
  -            prev_state = current_state;
  -            current_state = STATE_INSIDE_TEXT;
  -            current_key = attr.getValue(I18N_NAMESPACE_URI, 
I18N_KEY_ATTRIBUTE);
  -        }
  -        else if (I18N_TRANSLATE_ELEMENT.equals(name)) {
  -            if (current_state != STATE_OUTSIDE) {
  -//                throw new SAXException(this.getClass().getName()
  -//                    + ": i18n:translate element must be used "
  -//                    + "outside of other i18n elements. Current state: " + 
current_state);
  +            else if (I18N_TRANSLATE_ELEMENT.equals(name)) {
  +                if (current_state != STATE_OUTSIDE) {
  +                    throw new SAXException(this.getClass().getName()
  +                        + ": i18n:translate element must be used "
  +                        + "outside of other i18n elements. Current state: " 
+ current_state);
  +                }
  +                current_state = STATE_INSIDE_TRANSLATE;
               }
  -            current_state = STATE_INSIDE_TRANSLATE;
  -        }
  -        else if (I18N_PARAM_ELEMENT.equals(name)) {
  -            if (current_state != STATE_INSIDE_TRANSLATE) {
  -                throw new SAXException(this.getClass().getName()
  -                    + ": i18n:param element can be used only inside "
  -                    + "i18n:translate element. Current state: " + 
current_state);
  +            else if (I18N_PARAM_ELEMENT.equals(name)) {
  +                if (current_state != STATE_INSIDE_TRANSLATE) {
  +                    throw new SAXException(this.getClass().getName()
  +                        + ": i18n:param element can be used only inside "
  +                        + "i18n:translate element. Current state: " + 
current_state);
  +                }
  +                setFormattingParams(attr);
  +                current_state = STATE_INSIDE_PARAM;
               }
  -            current_state = STATE_INSIDE_PARAM;
  +            else if (I18N_DATE_ELEMENT.equals(name)) {
  +                if (current_state != STATE_OUTSIDE) {
  +                    throw new SAXException(this.getClass().getName()
  +                        + ": i18n:date elements are not allowed "
  +                        + "inside of other i18n elements.");
  +                }
  +
  +                setFormattingParams(attr);
  +                current_state = STATE_INSIDE_DATE;
  +            }
  +            else if (I18N_NUMBER_ELEMENT.equals(name)) {
  +                if (current_state != STATE_OUTSIDE) {
  +                    throw new SAXException(this.getClass().getName()
  +                        + ": i18n:number elements are not allowed "
  +                        + "inside of other i18n elements.");
  +                }
  +
  +                setFormattingParams(attr);
  +                current_state = STATE_INSIDE_NUMBER;
  +            }
  +        } catch (Exception e) {
  +            // we need it to avoid further errors if an exception occurs
  +            current_state = STATE_OUTSIDE;
  +            throw new SAXException(this.getClass().getName()
  +                + ": error in format", e);
           }
       }
   
  +    /**
  +     * Get src-pattern, pattern and value attribute values and store in a Map
  +     */
  +    private void setFormattingParams(Attributes attr) throws SAXException {
  +        formattingParams = new HashMap(3);
  +
  +        String attr_value = attr.getValue(I18N_SRC_PATTERN_ATTRIBUTE);
  +        if (attr_value != null) {
  +            formattingParams.put(I18N_SRC_PATTERN_ATTRIBUTE, attr_value);
  +        }
  +
  +        attr_value = attr.getValue(I18N_PATTERN_ATTRIBUTE);
  +        if (attr_value != null) {
  +            formattingParams.put(I18N_PATTERN_ATTRIBUTE, attr_value);
  +        }
  +
  +        attr_value = attr.getValue(I18N_VALUE_ATTRIBUTE);
  +        if (attr_value != null) {
  +            formattingParams.put(I18N_VALUE_ATTRIBUTE, attr_value);
  +        }
  +
  +        attr_value = attr.getValue(I18N_TYPE_ATTRIBUTE);
  +        if (attr_value != null) {
  +            formattingParams.put(I18N_TYPE_ATTRIBUTE, attr_value);
  +        }
  +
  +        attr_value = attr.getValue(I18N_SUB_TYPE_ATTRIBUTE);
  +        if (attr_value != null) {
  +            formattingParams.put(I18N_SUB_TYPE_ATTRIBUTE, attr_value);
  +        }
   
  +    }
  +
       private void endI18NElement(String name) throws SAXException {
           this.getLogger().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;
  -            }
  +        try {
  +            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: {
  +                    endDateElement();
  +                    break;
  +                }
  +                case STATE_INSIDE_NUMBER: {
  +                    endNumberElement();
  +                    break;
  +                }
  +            }
  +        } catch (Exception e) {
  +            // we need it to avoid further errors if an exception occurs
  +            current_state = STATE_OUTSIDE;
  +            throw new SAXException(this.getClass().getName()
  +                + ": error in format", e);
           }
       }
   
  @@ -362,9 +466,9 @@
           // FIXME (KP) Must be a better way to determine whitespace-only 
nodes.
           // trim() function does not remove spaces if string does not contain
           // anything else.
  -//        if (s == null) {
  -//            return null;
  -//        }
  +        if (s == null) {
  +            return null;
  +        }
           String result = (s + "!").trim();
           return result.substring(0, result.length() - 1);
       }
  @@ -375,7 +479,6 @@
           String text2translate = new String(ch, start, len);
           text2translate = stripWhitespace(text2translate);
           if (text2translate == null || text2translate.length() == 0) {
  -//            this.getLogger().warn(this.getClass().getName() + ": null i18n 
text found");
               return;
           }
   
  @@ -390,7 +493,7 @@
                       }
                       current_key = null;
                   }
  -                else if (len > 0) {
  +                else {
                       translated_text = 
(String)(dictionary.get(text2translate));
                   }
   
  @@ -398,19 +501,44 @@
               }
               case STATE_INSIDE_TRANSLATE: {
                   // Store text for param substitution (do not translate)
  -                if (len > 0 && substitute_text == null) {
  +                if (substitute_text == null) {
                       substitute_text = text2translate;
                   }
                   break;
               }
               case STATE_INSIDE_PARAM: {
                   // Store translation for param substitution
  -                if (len > 0 && param_value == null) {
  +                if (param_value == null) {
                       param_value = text2translate;
                   }
                   break;
               }
  -
  +            case STATE_INSIDE_DATE: {
  +                if (formattingParams != null) {
  +                    if (formattingParams.get(I18N_VALUE_ATTRIBUTE) == null) {
  +                        formattingParams.put(I18N_VALUE_ATTRIBUTE, 
text2translate);
  +                    }
  +                    else {
  +                        // how to use the text inside of date element?
  +                    }
  +                }
  +                break;
  +            }
  +            case STATE_INSIDE_NUMBER: {
  +                if (formattingParams != null) {
  +                    if (formattingParams.get(I18N_PATTERN_ATTRIBUTE) == 
null) {
  +                        formattingParams.put(I18N_PATTERN_ATTRIBUTE, 
text2translate);
  +                    }
  +                    else {
  +                        // how to use the text inside of number element?
  +                    }
  +                }
  +                break;
  +            }
  +            default: {
  +                throw new SAXException(this.getClass().getName()
  +                    + "Something's really wrong!!!");
  +            }
           }
       }
   
  @@ -471,9 +599,8 @@
                           0, translated_text.length());
                   }
                   else {
  -                    // Translation not found.
  -                    super.contentHandler.characters("".toCharArray(),
  -                        0, 0);
  +                 // else - translation not found
  +                    this.getLogger().debug("--- Translation not found! ---");
                   }
                   break;
               }
  @@ -491,8 +618,28 @@
           prev_state = STATE_OUTSIDE;
       }
   
  -    private void endParamElement() {
  +    private void endParamElement() throws SAXException {
           this.getLogger().debug("Substitution param: " + param_value);
  +        if (formattingParams != null) {
  +            String paramType = 
(String)formattingParams.get(I18N_TYPE_ATTRIBUTE);
  +            if (paramType != null) {
  +                this.getLogger().debug("Param type: " + paramType);
  +                if (formattingParams.get(I18N_VALUE_ATTRIBUTE) == null
  +                    && param_value != null) {
  +                    this.getLogger().debug("Put param value: " + 
param_value);
  +                    formattingParams.put(I18N_VALUE_ATTRIBUTE, param_value);
  +                }
  +                if ("date".equals(paramType)) {
  +                    this.getLogger().debug("Formatting date param: " + 
formattingParams);
  +                    param_value = formatDate(formattingParams);
  +                }
  +                else if ("number".equals(paramType)) {
  +                    this.getLogger().debug("Formatting number param: " + 
formattingParams);
  +                    param_value = formatNumber(formattingParams);
  +                }
  +            }
  +        }
  +        this.getLogger().debug("Added substitution param: " + param_value);
           indexedParams.add(param_value);
           param_value = null;
           current_state = STATE_INSIDE_TRANSLATE;
  @@ -520,8 +667,124 @@
           current_state = STATE_OUTSIDE;
       }
   
  +    private void endDateElement() throws SAXException {
  +        String result = formatDate(formattingParams);
  +        super.contentHandler.characters(result.toCharArray(), 0, 
result.length());
  +        current_state = STATE_OUTSIDE;
  +    }
  +
  +    private String formatDate(Map params) throws SAXException {
  +        if (params == null) {
  +            throw new SAXException(this.getClass().getName()
  +                + ": i18n:date - error in element attributes.");
  +        }
  +        // from pattern
  +        String srcPattern = (String)params.get(I18N_SRC_PATTERN_ATTRIBUTE);
  +        // to pattern
  +        String pattern = (String)params.get(I18N_PATTERN_ATTRIBUTE);
  +        // the date value
  +        String value = (String)params.get(I18N_VALUE_ATTRIBUTE);
  +
  +        // parsed date object
  +        Date dateValue = null;
  +
  +        // src format
  +        SimpleDateFormat from_fmt = 
(SimpleDateFormat)DateFormat.getInstance();
  +        if (srcPattern != null) {
  +            from_fmt.applyPattern(srcPattern);
  +        }
  +
  +        // result pattern is localized
  +        SimpleDateFormat to_fmt = 
(SimpleDateFormat)DateFormat.getDateTimeInstance(
  +            DateFormat.DEFAULT, DateFormat.DEFAULT, locale);
  +        if (pattern != null) {
  +            to_fmt.applyPattern(pattern);
  +        }
  +
  +        // get current date and time by default
  +        if (value == null) {
  +            dateValue = new Date();
  +        }
  +        else {
  +            try {
  +                dateValue = from_fmt.parse(value);
  +            } catch (ParseException pe) {
  +                throw new SAXException(this.getClass().getName()
  +                    + "i18n:date - parsing error.", pe);
  +            }
  +        }
  +
  +        // we have all necessary data here: do formatting.
  +        String result = to_fmt.format(dateValue);
  +        this.getLogger().debug("i18n:date result: " + result);
  +        return result;
  +    }
  +
  +    private void endNumberElement() throws SAXException {
  +        String result = formatNumber(formattingParams);
  +        super.contentHandler.characters(result.toCharArray(), 0, 
result.length());
  +        current_state = STATE_OUTSIDE;
  +    }
  +
  +    private String formatNumber(Map params) throws SAXException {
  +        if (params == null) {
  +            throw new SAXException(this.getClass().getName()
  +                + ": i18n:number - error in element attributes.");
  +        }
  +        // from pattern
  +        String srcPattern = (String)params.get(I18N_SRC_PATTERN_ATTRIBUTE);
  +        // to pattern
  +        String pattern = (String)params.get(I18N_PATTERN_ATTRIBUTE);
  +        // the number value
  +        String value = (String)params.get(I18N_VALUE_ATTRIBUTE);
  +        // sub-type
  +        String subType = (String)params.get(I18N_SUB_TYPE_ATTRIBUTE);
  +
  +        // parsed number
  +        Number numberValue = null;
  +
  +        // src format
  +        DecimalFormat from_fmt = (DecimalFormat)NumberFormat.getInstance();
  +        if (srcPattern != null) {
  +            from_fmt.applyPattern(srcPattern);
  +        }
  +
  +        // result pattern is localized
  +        DecimalFormat to_fmt = null;
  +        if (subType == null) {
  +            to_fmt = (DecimalFormat)NumberFormat.getInstance(locale);
  +        }
  +        else if (subType.equals("currency")) {
  +            to_fmt = (DecimalFormat)NumberFormat.getCurrencyInstance(locale);
  +        }
  +        else if (subType.equals("percent")) {
  +            to_fmt = (DecimalFormat)NumberFormat.getPercentInstance(locale);
  +        }
  +        if (pattern != null) {
  +            to_fmt.applyPattern(pattern);
  +        }
  +
  +        // get current date and time by default
  +        if (value == null) {
  +            numberValue = new Long(0);
  +        }
  +        else {
  +            try {
  +                numberValue = from_fmt.parse(value);
  +            } catch (ParseException pe) {
  +                throw new SAXException(this.getClass().getName()
  +                    + "i18n:number - parsing error.", pe);
  +            }
  +        }
  +
  +        // we have all necessary data here: do formatting.
  +        String result = to_fmt.format(numberValue);
  +        this.getLogger().debug("i18n:number result: " + result);
  +        return result;
  +    }
  +
       /**
  -     *Gets translations from xml file to dictionary.
  +     * Gets translations from xml file to dictionary.
        */
       class I18nContentHandler extends DefaultHandler {
           boolean in_entry = false;
  @@ -622,4 +885,41 @@
               if(parser != null) this.manager.release((Component) parser);
           }
       }
  +
  +    /**
  +     *
  +     */
  +    static public void main(String[] args) {
  +
  +        Locale locale = null;
  +
  +        Locale[] locales = Locale.getAvailableLocales();
  +        for (int i = 0; i < locales.length; i++) {
  +            locale = locales[i];
  +            SimpleDateFormat fmt = 
(SimpleDateFormat)DateFormat.getDateTimeInstance(
  +                DateFormat.DEFAULT, DateFormat.DEFAULT, locale
  +            );
  +
  +            String localized = fmt.format(new Date());
  +
  +            NumberFormat n_fmt = NumberFormat.getCurrencyInstance(locale);
  +            String money = n_fmt.format(1210.5);
  +
  +            System.out.println("Locale ["
  +                + locale.getLanguage() + ", "
  +                + locale.getCountry() + ", "
  +                + locale.getVariant() + "] : "
  +                + locale.getDisplayName()
  +                + " \t Date: " + localized
  +                + " \t Money: " + money);
  +        }
  +    }
  +
   }
  +
  +
  +
  +
  +
  +
  +
  
  
  
  1.4       +43 -5     xml-cocoon2/webapp/i18n/simple.xml
  
  Index: simple.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/webapp/i18n/simple.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- simple.xml        2001/05/23 12:32:20     1.3
  +++ simple.xml        2001/06/15 15:01:09     1.4
  @@ -1,15 +1,18 @@
   <?xml version="1.0" encoding="UTF-8"?>
   <root xmlns:i18n="http://apache.org/cocoon/i18n/2.0";>
        <title>
  -             <i18n:text>Hello, internationalization!</i18n:text>
  +             <i18n:text>Hello, internationalization!</i18n:text> 
        </title>
  +     <sub-title>
  +             <i18n:date pattern="EEE, MMMM dd, yyyy zzz" />
  +     </sub-title>    
        <annotation>
                <i18n:text>Documentation link:</i18n:text> 
                <link>
  -                     
<href>http://xml.apache.org/cocoon/cocoon2/i18n.html</href>
  +                     <href>http://xml.apache.org/cocoon2/i18n.html</href>
                        <title>Cocoon 2 Web Site</title>
  -             </link>         
  -      </annotation>
  +             </link>
  +      </annotation>  
        <menu>
                <item>
                        <title><i18n:text>language</i18n:text></title>
  @@ -55,6 +58,32 @@
                        </link>
                </item>         
        </menu>
  +     <menu>
  +             <item>
  +                     <link>
  +                             <href>?lang=en_US</href>
  +                             <title>English (US)</title>
  +                     </link>
  +             </item>
  +             <item>
  +                     <link>
  +                             <href>?lang=en_GB</href>
  +                             <title>English (GB)</title>
  +                     </link>
  +             </item>         
  +             <item>
  +                     <link>
  +                             <href>?lang=ru_RU</href>
  +                             <title>Russian (Russia)</title>
  +                     </link>
  +             </item>         
  +             <item>
  +                     <link>
  +                             <href>?lang=de_AT_EURO</href>
  +                             <title>German (Austria, Euro)</title>
  +                     </link>
  +             </item>
  +     </menu> 
        <content>
                <para title="first" name="article" i18n:attr="title name">
                        <i18n:text i18n:key="a_key">article_text1</i18n:text>
  @@ -77,9 +106,18 @@
                                <i18n:param 
name="one"><i18n:text>one</i18n:text></i18n:param>
                                <i18n:param 
name="two"><i18n:text>two</i18n:text></i18n:param>
                                <i18n:param name="third">baby</i18n:param>
  -                             <i18n:param name="forth">~</i18n:param>
  +                             <i18n:param name="forth"> ~ </i18n:param>
                        </i18n:translate>
                </para>
  +                     <para title="Number formatting (not translated)" 
name="article" i18n:attr="name">
  +                             <i18n:translate>
  +                                     Number : {0} | Currency: {1} | Percent: 
{2}, processed on: {3}
  +                                     <i18n:param type="number" 
value="1703.74" />
  +                                     <i18n:param type="number" 
sub-type="currency">27.24</i18n:param>
  +                                     <i18n:param type="number" 
sub-type="percent">1.2</i18n:param>                                   
  +                                     <i18n:param type="date" />
  +                             </i18n:translate>
  +                     </para>                  
        </content>
        <bottom>
                <copyright>
  
  
  
  1.3       +15 -6     xml-cocoon2/webapp/i18n/simple.xsl
  
  Index: simple.xsl
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/webapp/i18n/simple.xsl,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- simple.xsl        2001/05/18 14:05:20     1.2
  +++ simple.xsl        2001/06/15 15:01:10     1.3
  @@ -7,16 +7,25 @@
                                        <xsl:value-of select="title"/>
                                </title>
                        </head>
  -                     <body bgcolor="white">
  -                             <h1>
  +                     <body bgcolor="white" style="font-family: Verdana, 
Arial, Helvetica">
  +                             <h2>
                                        <font color="navy">
                                                <xsl:value-of select="title"/>
                                        </font>
  -                             </h1>
  -                             <small><font color="red"><xsl:apply-templates 
select="annotation"/></font></small>
  -                             <h4><xsl:value-of select="sub-title"/></h4>
  -                             <xsl:apply-templates select="menu"/>
  +                             </h2>
  +                             <h5><xsl:value-of select="sub-title"/></h5>
  +                             <table width="100%">
  +                                     <tr>
  +                                             <td align="left">
  +                                                     <xsl:apply-templates 
select="menu[1]"/>
  +                                             </td>
  +                                             <td align="right">
  +                                                     <xsl:apply-templates 
select="menu[2]"/>
  +                                             </td>                           
                
  +                                     </tr>
  +                             </table>
                                <hr align="left" noshade="noshade" size="1"/>
  +                             <small><font 
color="red"><i><xsl:apply-templates select="annotation"/></i></font></small>
                                
                                <xsl:apply-templates select="content" />
                                
  
  
  
  1.5       +148 -109  xml-cocoon2/webapp/i18n/simple.xsp
  
  Index: simple.xsp
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/webapp/i18n/simple.xsp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- simple.xsp        2001/06/01 16:14:59     1.4
  +++ simple.xsp        2001/06/15 15:01:11     1.5
  @@ -1,18 +1,15 @@
   <?xml version="1.0" encoding="UTF-8"?>
   <xsp:page language="java" xmlns:xsp="http://apache.org/xsp"; 
xmlns:xsp-request="http://apache.org/xsp/request/2.0"; 
xmlns:i18n="http://apache.org/cocoon/i18n/2.0";>
  -
  -<xsp:structure>
  -     <xsp:include>java.text.SimpleDateFormat</xsp:include>
  -     <xsp:include>java.util.Locale</xsp:include>
  -</xsp:structure>
  -
  -<xsp:logic>
  +     <xsp:structure>
  +             <xsp:include>java.text.SimpleDateFormat</xsp:include>
  +             <xsp:include>java.util.Locale</xsp:include>
  +     </xsp:structure>
  +     <xsp:logic>
        private static int count = 0;
   </xsp:logic>
  -
  -<root>
  -     <xsp-request:get-session />
  -     <xsp:logic>
  +     <root>
  +             <xsp-request:get-session/>
  +             <xsp:logic>
                synchronized (this) {
                        count++;
                }
  @@ -20,110 +17,152 @@
                Locale loc = null;
                String lang = <xsp-request:get-attribute name="lang"/>;
                if (lang != null) {
  -                     // request.setAttribute("lang", lang);
  -                     loc = new Locale(lang, lang.toUpperCase());
  +                     loc = 
org.apache.cocoon.transformation.I18nTransformer2.parseLocale(lang);
                }
  -             
  -             // here also must be a check if this locale is available
  -             // otherwise, date format will be incorrect.
  -             if (loc == null) {
  -                     loc = Locale.ENGLISH;
  -             }
  -             
  -             SimpleDateFormat df = new SimpleDateFormat("EEE, MMM dd, yyyy 
H:mm:ss", loc);
  +                     
  +             SimpleDateFormat df = new SimpleDateFormat("EEEE, MMMM dd, yyyy 
H:mm:ss", loc);
        </xsp:logic>
  -     <title>
  -             <i18n:text>Hello, internationalization!</i18n:text>
  -     </title>
  -     <annotation>
  -             <i18n:text>Documentation link:</i18n:text> 
  -             <link>
  -                     
<href>http://xml.apache.org/cocoon/cocoon2/i18n.html</href>
  -                     <title>Cocoon 2 Web Site</title>
  -             </link>         
  -      </annotation>
  -     <sub-title>
  -             <i18n:translate>
  -                     <i18n:text>count_title</i18n:text>
  -                     <i18n:param><xsp:expr>count</xsp:expr></i18n:param>
  -                     <i18n:param><xsp:expr>df.format(new 
Date())</xsp:expr></i18n:param>
  -             </i18n:translate>
  -     </sub-title>
  -     <menu>
  -             <item>
  -                     <title><i18n:text>language</i18n:text></title>
  -             </item>
  -             <item>
  -                     <link>
  -                             
<href>?lang=<i18n:text>lang_id1</i18n:text></href>
  -                             <title>
  -                                     <i18n:text>language1</i18n:text>
  -                             </title>
  -                     </link>
  -             </item>
  -             <item>
  +             <title>
  +                     <i18n:text>Hello, internationalization!</i18n:text>
  +             </title>
  +             <annotation>
  +                     <i18n:text>Documentation link:</i18n:text>
                        <link>
  -                             
<href>?lang=<i18n:text>lang_id2</i18n:text></href>
  -                             <title>
  -                                     <i18n:text>language2</i18n:text>
  -                             </title>
  -                     </link>
  -             </item>
  -             <item>
  -                     <link>
  -                             
<href>?lang=<i18n:text>lang_id3</i18n:text></href>
  -                             <title>
  -                                     <i18n:text>language3</i18n:text>
  -                             </title>
  +                             
<href>http://xml.apache.org/cocoon2/i18n.html</href>
  +                             <title>Cocoon 2 Web Site</title>
                        </link>
  -             </item> 
  -             <item>
  -                     <link>
  -                             
<href>?lang=<i18n:text>lang_id4</i18n:text></href>
  -                             <title>
  -                                     <i18n:text>language4</i18n:text>
  -                             </title>
  -                     </link>
  -             </item>         
  -             <item>
  -                     <link>
  -                             
<href>?lang=<i18n:text>lang_id5</i18n:text></href>
  -                             <title>
  -                                     <i18n:text>language5</i18n:text>
  -                             </title>
  -                     </link>
  -             </item>                         
  -     </menu>
  -     <content>
  -             <para title="first" name="article" i18n:attr="title name">
  -                     <i18n:text i18n:key="a_key">article_text1</i18n:text>
  -             </para>
  -             <para title="second" name="article" i18n:attr="title name">
  -                     <i18n:text>article_text2</i18n:text>
  -             </para>
  -             <para title="third" name="article" i18n:attr="title name">
  +             </annotation>
  +             <sub-title>
                        <i18n:translate>
  -                             <i18n:text>Hello, {0}! Glad to see 
you!</i18n:text>
  -                             <i18n:param 
name="username"><i18n:text><xsp-request:get-parameter name="user" 
default="none" as="string"/></i18n:text></i18n:param>
  +                             <i18n:text>count_title</i18n:text>
  +                             <i18n:param>
  +                                     <xsp:expr>count</xsp:expr>
  +                             </i18n:param>
  +                             <i18n:param>
  +                                     <xsp:expr>df.format(new 
Date())</xsp:expr>
  +                             </i18n:param>
                        </i18n:translate>
  -             </para>
  -             <para title="forth" name="article" i18n:attr="title name">
  -                     <i18n:translate>
  +             </sub-title>
  +             <menu>
  +                     <item>
  +                             <title>
  +                                     <i18n:text>language</i18n:text>
  +                             </title>
  +                     </item>
  +                     <item>
  +                             <link>
  +                                     
<href>?lang=<i18n:text>lang_id1</i18n:text></href>
  +                                     <title>
  +                                             <i18n:text>language1</i18n:text>
  +                                     </title>
  +                             </link>
  +                     </item>
  +                     <item>
  +                             <link>
  +                                     
<href>?lang=<i18n:text>lang_id2</i18n:text></href>
  +                                     <title>
  +                                             <i18n:text>language2</i18n:text>
  +                                     </title>
  +                             </link>
  +                     </item>
  +                     <item>
  +                             <link>
  +                                     
<href>?lang=<i18n:text>lang_id3</i18n:text></href>
  +                                     <title>
  +                                             <i18n:text>language3</i18n:text>
  +                                     </title>
  +                             </link>
  +                     </item>
  +                     <item>
  +                             <link>
  +                                     
<href>?lang=<i18n:text>lang_id4</i18n:text></href>
  +                                     <title>
  +                                             <i18n:text>language4</i18n:text>
  +                                     </title>
  +                             </link>
  +                     </item>
  +                     <item>
  +                             <link>
  +                                     
<href>?lang=<i18n:text>lang_id5</i18n:text></href>
  +                                     <title>
  +                                             <i18n:text>language5</i18n:text>
  +                                     </title>
  +                             </link>
  +                     </item>
  +             </menu>
  +             <menu>
  +                     <item>
  +                             <link>
  +                                     <href>?lang=en_US</href>
  +                                     <title>English (US)</title>
  +                             </link>
  +                     </item>
  +                     <item>
  +                             <link>
  +                                     <href>?lang=en_GB</href>
  +                                     <title>English (GB)</title>
  +                             </link>
  +                     </item>         
  +                     <item>
  +                             <link>
  +                                     <href>?lang=ru_RU</href>
  +                                     <title>Russian (Russia)</title>
  +                             </link>
  +                     </item>                                 
  +                     <item>
  +                             <link>
  +                                     <href>?lang=de_AT_EURO</href>
  +                                     <title>German (Austria, Euro)</title>
  +                             </link>
  +                     </item>                 
  +             </menu>                 
  +             <content>
  +                     <para title="first" name="article" i18n:attr="title 
name">
  +                             <i18n:text 
i18n:key="a_key">article_text1</i18n:text>
  +                     </para>
  +                     <para title="second" name="article" i18n:attr="title 
name">
  +                             <i18n:text>article_text2</i18n:text>
  +                     </para>
  +                     <para title="third" name="article" i18n:attr="title 
name">
  +                             <i18n:translate>
  +                                     <i18n:text>Hello, {0}! Glad to see 
you!</i18n:text>
  +                                     <i18n:param name="username">
  +                                             <i18n:text>
  +                                                     
<xsp-request:get-parameter name="user" default="none" as="string"/>
  +                                             </i18n:text>
  +                                     </i18n:param>
  +                             </i18n:translate>
  +                     </para>
  +                     <para title="forth" name="article" i18n:attr="title 
name">
  +                             <i18n:translate>
                                One = {0}, two = {1}, {2}! {3}
                                This line is not translated {3}
  -                             <i18n:param 
name="one"><i18n:text><xsp:expr>"ONE".toLowerCase()</xsp:expr></i18n:text></i18n:param>
  -                             <i18n:param 
name="two"><i18n:text>two</i18n:text></i18n:param>
  -                             <i18n:param name="third">baby</i18n:param>
  -                             <i18n:param name="forth">~</i18n:param>
  -                     </i18n:translate>
  -             </para>
  -     </content>
  -     <bottom>
  -             <copyright>
  -                     <i18n:text>copyright</i18n:text>
  -             </copyright>
  -     </bottom>
  -</root>
  -
  +                             <i18n:param name="one">
  +                                             <i18n:text>
  +                                                     
<xsp:expr>"ONE".toLowerCase()</xsp:expr>
  +                                             </i18n:text>
  +                                     </i18n:param>
  +                                     <i18n:param name="two">
  +                                             <i18n:text>two</i18n:text>
  +                                     </i18n:param>
  +                                     <i18n:param 
name="third">baby</i18n:param>
  +                                     <i18n:param name="forth">~</i18n:param>
  +                             </i18n:translate>
  +                     </para>
  +                     <para title="Number formatting (not translated)" 
name="article" i18n:attr="name">
  +                             <i18n:translate>
  +                                     Number : {0} | Currency: {1} | Percent: 
{2}, processed on: {3}
  +                                     <i18n:param type="number" 
value="1703.74" />
  +                                     <i18n:param type="number" 
sub-type="currency">27.24</i18n:param>
  +                                     <i18n:param type="number" 
sub-type="percent">1.2</i18n:param>                                   
  +                                     <i18n:param type="date" />
  +                             </i18n:translate>
  +                     </para>                  
  +             </content>
  +             <bottom>
  +                     <copyright>
  +                             <i18n:text>copyright</i18n:text>
  +                     </copyright>
  +             </bottom>
  +     </root>
   </xsp:page>
  -
  
  
  
  1.5       +267 -267  xml-cocoon2/webapp/i18n/translations/simple_dict.xml
  
  Index: simple_dict.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/webapp/i18n/translations/simple_dict.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- simple_dict.xml   2001/06/09 12:04:39     1.4
  +++ simple_dict.xml   2001/06/15 15:01:17     1.5
  @@ -1,267 +1,267 @@
  -<?xml version="1.0" encoding="UTF-8"?>
  -<?xml-stylesheet type="text/xsl" href="merge.xsl"?>
  -<translations>
  -     <!-- 
  -     Languages:
  -             en - English
  -             ru - Russian
  -             de - German
  -             pl - Polish (thanks to Krzysztof Zieliński)
  -             es - Spanish
  -             hy - Armenian.
  --->
  -     <!-- Language links -->
  -     <entry>
  -             <key>count_title</key>
  -             <translation lang="en">This page was accessed {0} times. Last 
at: {1}.</translation>
  -             <translation lang="ru">На эту страницу 
заходили {0} раз(а). В последний раз {1}.</translation>
  -             <translation lang="de">Auf diese Seite kamen {0} Des males 
vorbei. In das letzte {1}.</translation>
  -             <translation lang="pl">Ta strona była pobierana {0} razy. 
Ostatnio {1}</translation>
  -             <translation lang="es">Esta página fue tenida acceso {0} 
veces. Pasado en: {1}.</translation>
  -             <translation lang="hy">²Ûë ¿çÁ ³Ûó»É»É »Ý {0} 
³Ý·³Ù. ì»ñçÇÝÁ {1}.</translation>
  -     </entry>
  -     <entry>
  -             <key>a_key</key>
  -             <translation lang="en">This is a key value.</translation>
  -             <translation lang="ru">Это значение по 
ключу.</translation>
  -             <translation lang="de">Diese Bedeutung nach dem 
Schlüssel.</translation>
  -             <translation lang="pl">To jest klucz.</translation>
  -             <translation lang="es">Esto es un valor clave.</translation>
  -             <translation lang="hy">ê³ µ³Ý³ÉÇÇ ³éÅ»ùÝ 
¿£</translation>
  -     </entry>
  -     <entry>
  -             <key>lang_id1</key>
  -             <translation lang="en">ru</translation>
  -             <translation lang="ru">en</translation>
  -             <translation lang="de">en</translation>
  -             <translation lang="pl">en</translation>
  -             <translation lang="es">en</translation>
  -             <translation lang="hy">en</translation>
  -     </entry>
  -     <entry>
  -             <key>lang_id2</key>
  -             <translation lang="en">de</translation>
  -             <translation lang="ru">de</translation>
  -             <translation lang="de">ru</translation>
  -             <translation lang="pl">ru</translation>
  -             <translation lang="es">ru</translation>
  -             <translation lang="hy">ru</translation>
  -     </entry>
  -     <entry>
  -             <key>lang_id3</key>
  -             <translation lang="en">pl</translation>
  -             <translation lang="ru">pl</translation>
  -             <translation lang="de">pl</translation>
  -             <translation lang="pl">de</translation>
  -             <translation lang="es">de</translation>
  -             <translation lang="hy">de</translation>
  -     </entry>
  -     <entry>
  -             <key>lang_id4</key>
  -             <translation lang="en">es</translation>
  -             <translation lang="ru">es</translation>
  -             <translation lang="de">es</translation>
  -             <translation lang="pl">es</translation>
  -             <translation lang="es">pl</translation>
  -             <translation lang="hy">pl</translation>
  -     </entry>
  -     <entry>
  -             <key>lang_id5</key>
  -             <translation lang="en">hy</translation>
  -             <translation lang="ru">hy</translation>
  -             <translation lang="de">hy</translation>
  -             <translation lang="pl">hy</translation>
  -             <translation lang="es">hy</translation>
  -             <translation lang="hy">es</translation>
  -     </entry>
  -     <!-- current language -->
  -     <entry>
  -             <key>language</key>
  -             <translation lang="en">English</translation>
  -             <translation lang="ru">Русский</translation>
  -             <translation lang="de">Deutsch</translation>
  -             <translation lang="pl">Polski</translation>
  -             <translation lang="es">Español</translation>
  -             <translation lang="hy">гۻñ»Ý</translation>
  -     </entry>
  -     <entry>
  -             <key>language1</key>
  -             <translation lang="en">Russian</translation>
  -             <translation lang="ru">Английский</translation>
  -             <translation lang="de">Englische</translation>
  -             <translation lang="pl">Angielski</translation>
  -             <translation lang="es">Inglés</translation>
  -             <translation lang="hy">²Ý·É»ñ»Ý</translation>
  -     </entry>
  -     <entry>
  -             <key>language2</key>
  -             <translation lang="en">German</translation>
  -             <translation lang="ru">Немецкий</translation>
  -             <translation lang="de">Russe</translation>
  -             <translation lang="pl">Rosyjski</translation>
  -             <translation lang="es">Ruso</translation>
  -             <translation lang="hy">èáõë»ñ»Ý</translation>
  -     </entry>
  -     <entry>
  -             <key>language3</key>
  -             <translation lang="en">Polish</translation>
  -             <translation lang="ru">Польский</translation>
  -             <translation lang="de">Polnisch</translation>
  -             <translation lang="pl">Niemiecki</translation>
  -             <translation lang="es">Alemán</translation>
  -             <translation lang="hy">¶»ñٳݻñ»Ý</translation>
  -     </entry>
  -     <entry>
  -             <key>language4</key>
  -             <translation lang="en">Spanish</translation>
  -             <translation lang="ru">Испанский</translation>
  -             <translation lang="de">Spanisch</translation>
  -             <translation lang="pl">Hiszpañski</translation>
  -             <translation lang="es">Polaco</translation>
  -             <translation lang="hy">Ȼѻñ»Ý</translation>
  -     </entry>
  -     <entry>
  -             <key>language5</key>
  -             <translation lang="en">Armenian</translation>
  -             <translation lang="ru">Армянский</translation>
  -             <translation lang="de">Armenier</translation>
  -             <translation lang="pl">Armeñski</translation>
  -             <translation lang="es">Armenio</translation>
  -             <translation lang="hy">Æëå³Ý»ñ»Ý</translation>
  -     </entry>
  -     <entry>
  -             <key>Hello, internationalization!</key>
  -             <translation lang="en">Hello, 
internationalization!</translation>
  -             <translation lang="ru">Привет, 
многоязычность!</translation>
  -             <translation lang="de">Hallo, die 
Internationalisierung!</translation>
  -             <translation lang="pl">Witam, oto przykład wielojęzycznej 
strony!</translation>
  -             <translation lang="es">¡¡Hola!, 
internacionalización!</translation>
  -             <translation lang="hy">´³ñ¢°, 
ÇÝï»ñݳóÛáݳÉáõÃÛáõÝ£</translation>
  -     </entry>
  -     <entry>
  -             <key>Documentation link:</key>
  -             <translation lang="en">See i18n documentation for 
details:</translation>
  -             <translation lang="ru">Для дополнительной 
информации по i18n смотри:</translation>
  -             <translation lang="de">Sieh i18n Dokumentation für 
Details:</translation>
  -             <translation lang="pl">Widzą i18n dokumentacja dla 
szczegółów:</translation>
  -             <translation lang="es">Visto la documentación i18n para 
detalles:</translation>
  -             <translation lang="hy">سÝñ³Ù³ë 
µ³ó³ïñáõÃÛ³Ý Ñ³Ù³ñ ݳÇñª</translation>
  -     </entry>
  -     <entry>
  -             <key>first</key>
  -             <translation lang="en">First</translation>
  -             <translation lang="ru">Первый</translation>
  -             <translation lang="de">Ersten</translation>
  -             <translation lang="pl">Pierwszy</translation>
  -             <translation lang="es">Primero</translation>
  -             <translation lang="hy">²é³çÇÝ</translation>
  -     </entry>
  -     <entry>
  -             <key>second</key>
  -             <translation lang="en">Second</translation>
  -             <translation lang="ru">Второй</translation>
  -             <translation lang="de">Zwiete</translation>
  -             <translation lang="pl">Drugi</translation>
  -             <translation lang="es">Segundo</translation>
  -             <translation lang="hy">ºñÏñáñ¹</translation>
  -     </entry>
  -     <entry>
  -             <key>third</key>
  -             <translation lang="en">Third</translation>
  -             <translation lang="ru">Третий</translation>
  -             <translation lang="de">Dritten</translation>
  -             <translation lang="pl">Trzeci</translation>
  -             <translation lang="es">Tercio</translation>
  -             <translation lang="hy">ºññáñ¹</translation>
  -     </entry>
  -     <entry>
  -             <key>forth</key>
  -             <translation lang="en">Forth</translation>
  -             <translation lang="ru">Четвертый</translation>
  -             <translation lang="de">Vierten</translation>
  -             <translation lang="pl">Czwarty</translation>
  -             <translation lang="es">En adelante</translation>
  -             <translation lang="hy">¼áñáñ¹</translation>
  -     </entry>
  -     <entry>
  -             <key>article</key>
  -             <translation lang="en">Article</translation>
  -             <translation lang="ru">Статья</translation>
  -             <translation lang="de">Artikel</translation>
  -             <translation lang="pl">Artykuł</translation>
  -             <translation lang="es">Artículo</translation>
  -             <translation lang="hy">Ðá¹í³Í</translation>
  -     </entry>
  -     <entry>
  -             <key>article_text1</key>
  -             <translation lang="en">This is a i18n paragraph.</translation>
  -             <translation lang="ru">Это 
интернационализированный абзац.</translation>
  -             <translation lang="de">Es i18n den Absatz.</translation>
  -             <translation lang="pl">To jest paragraf w i18n.</translation>
  -             <translation lang="es">Esto es un párrafo i18n.</translation>
  -             <translation lang="hy">ê³ ÇÝï»ñݳóÛáÝ³É 
å³ñ³·ñ³ý ¿£</translation>
  -     </entry>
  -     <entry>
  -             <key>article_text2</key>
  -             <translation lang="en">This is another i18n paragraph and is 
also a cool one.</translation>
  -             <translation lang="ru">Это тоже 
интернационализированный абзац и такой же 
классный.</translation>
  -             <translation lang="de">Es auch i18n den Absatz und solcher 
cool.</translation>
  -             <translation lang="pl">To jest następny paragraf w i18n i jest 
takze fajny.</translation>
  -             <translation lang="es">Esto es otro párrafo i18n y es también 
uno 'cool'.</translation>
  -             <translation lang="hy">ê³ ÙÇ áõñÇß 
ÇÝï»ñݳóÛáÝ³É å³ñ³·ñ³ý ¿, ¢ ÝáõÛÝ å»ë 
ó»Ýïñ£</translation>
  -     </entry>
  -     <entry>
  -             <key>copyright</key>
  -             <translation lang="en">Copyright © 2001 Konstantin Piroumian. 
No rights are reserved.</translation>
  -             <translation lang="ru">Авторские права © 2001 
Константин Пирумян. Ничто не 
защищено.</translation>
  -             <translation lang="de">Die Urheberrechte © 2001 Konstantin 
Piroumian. Nichts ist geschützt.</translation>
  -             <translation lang="pl">Copyright © 2001 Konstantin Piroumian i 
Krzysztof Zieliński. Żadne prawa nie są zastrzeżone:)</translation>
  -             <translation lang="es">Copyright © 2001 Konstantin Piroumian. 
Ningunos derechos son reservados.</translation>
  -             <translation lang="hy">Copyright © 2001 Konstantin Piroumian. 
àãÇÝã ãÇ å³Ñå³Ýí³Í£</translation>
  -     </entry>
  -     <entry>
  -             <key>Hello, {0}! Glad to see you!</key>
  -             <translation lang="en">Hello, {0}! Glad to see 
you!</translation>
  -             <translation lang="ru">Привет, {0}! Рад тебя 
видеть!</translation>
  -             <translation lang="de">Hallo, {0}! Ist dich froh, zu 
sehen!</translation>
  -             <translation lang="pl">Witam, {0}! Miło Cię 
widzieć!</translation>
  -             <translation lang="es">¡¡Hola!, {0}! ¡Alegre de 
verle!</translation>
  -             <translation lang="hy">´³ñ¢¯ {0}: àõñ³Ë »Ù ù»½ 
ï»ëݻɣ</translation>
  -     </entry>
  -     <entry>
  -             <key>Kot</key>
  -             <translation lang="en">Tomcat</translation>
  -             <translation lang="ru">Кот</translation>
  -             <translation lang="de">Der Kater</translation>
  -             <translation lang="pl">Tomcat</translation>
  -             <translation lang="es">Gato</translation>
  -             <translation lang="hy">γïáõ</translation>
  -     </entry>
  -     <entry>
  -             <key>none</key>
  -             <translation lang="en">None</translation>
  -             <translation lang="ru">Никто</translation>
  -             <translation lang="de">Niemand</translation>
  -             <translation lang="pl">Nic</translation>
  -             <translation lang="es">Ninguno</translation>
  -             <translation lang="hy">àã áù</translation>
  -     </entry>
  -     <entry>
  -             <key>one</key>
  -             <translation lang="en">one</translation>
  -             <translation lang="ru">раз</translation>
  -             <translation lang="de">einen</translation>
  -             <translation lang="pl">raz</translation>
  -             <translation lang="es">un</translation>
  -             <translation lang="hy">Ù»Ï</translation>
  -     </entry>
  -     <entry>
  -             <key>two</key>
  -             <translation lang="en">two</translation>
  -             <translation lang="ru">два</translation>
  -             <translation lang="de">zwei</translation>
  -             <translation lang="pl">dwa</translation>
  -             <translation lang="es">dos</translation>
  -             <translation lang="hy">»ñÏáõë</translation>
  -     </entry>
  -</translations>
  +<?xml version="1.0" encoding="UTF-8"?>
  +<?xml-stylesheet type="text/xsl" href="merge.xsl"?>
  +<translations>
  +     <!-- 
  +     Languages:
  +             en - English
  +             ru - Russian
  +             de - German (thanks to Jörg Prante)
  +             pl - Polish (thanks to Krzysztof Zieliński)
  +             es - Spanish
  +             hy - Armenian.
  +-->
  +     <!-- Language links -->
  +     <entry>
  +             <key>count_title</key>
  +             <translation lang="en">This page was accessed {0} times. Last 
at: {1}.</translation>
  +             <translation lang="ru">На эту страницу 
заходили {0} раз(а). В последний раз {1}.</translation>
  +             <translation lang="de">Diese Seite wurde {0}mal aufgerufen. 
Letzter Aufruf: {1}.</translation>
  +             <translation lang="pl">Ta strona była pobierana {0} razy. 
Ostatnio {1}</translation>
  +             <translation lang="es">Esta página fue tenida acceso {0} 
veces. Pasado en: {1}.</translation>
  +             <translation lang="hy">²Ûë ¿çÁ ³Ûó»É»É »Ý {0} 
³Ý·³Ù. ì»ñçÇÝÁ {1}.</translation>
  +     </entry>
  +     <entry>
  +             <key>a_key</key>
  +             <translation lang="en">This is a key value.</translation>
  +             <translation lang="ru">Это значение по 
ключу.</translation>
  +             <translation lang="de">Dies ist der Wert eines 
Schlüssels.</translation>
  +             <translation lang="pl">To jest klucz.</translation>
  +             <translation lang="es">Esto es un valor clave.</translation>
  +             <translation lang="hy">ê³ µ³Ý³ÉÇÇ ³éÅ»ùÝ 
¿£</translation>
  +     </entry>
  +     <entry>
  +             <key>lang_id1</key>
  +             <translation lang="en">ru</translation>
  +             <translation lang="ru">en</translation>
  +             <translation lang="de">en</translation>
  +             <translation lang="pl">en</translation>
  +             <translation lang="es">en</translation>
  +             <translation lang="hy">en</translation>
  +     </entry>
  +     <entry>
  +             <key>lang_id2</key>
  +             <translation lang="en">de</translation>
  +             <translation lang="ru">de</translation>
  +             <translation lang="de">ru</translation>
  +             <translation lang="pl">ru</translation>
  +             <translation lang="es">ru</translation>
  +             <translation lang="hy">ru</translation>
  +     </entry>
  +     <entry>
  +             <key>lang_id3</key>
  +             <translation lang="en">pl</translation>
  +             <translation lang="ru">pl</translation>
  +             <translation lang="de">pl</translation>
  +             <translation lang="pl">de</translation>
  +             <translation lang="es">de</translation>
  +             <translation lang="hy">de</translation>
  +     </entry>
  +     <entry>
  +             <key>lang_id4</key>
  +             <translation lang="en">es</translation>
  +             <translation lang="ru">es</translation>
  +             <translation lang="de">es</translation>
  +             <translation lang="pl">es</translation>
  +             <translation lang="es">pl</translation>
  +             <translation lang="hy">pl</translation>
  +     </entry>
  +     <entry>
  +             <key>lang_id5</key>
  +             <translation lang="en">hy</translation>
  +             <translation lang="ru">hy</translation>
  +             <translation lang="de">hy</translation>
  +             <translation lang="pl">hy</translation>
  +             <translation lang="es">hy</translation>
  +             <translation lang="hy">es</translation>
  +     </entry>
  +     <!-- current language -->
  +     <entry>
  +             <key>language</key>
  +             <translation lang="en">English</translation>
  +             <translation lang="ru">Русский</translation>
  +             <translation lang="de">Deutsch</translation>
  +             <translation lang="pl">Polski</translation>
  +             <translation lang="es">Español</translation>
  +             <translation lang="hy">гۻñ»Ý</translation>
  +     </entry>
  +     <entry>
  +             <key>language1</key>
  +             <translation lang="en">Russian</translation>
  +             <translation lang="ru">Английский</translation>
  +             <translation lang="de">Englische</translation>
  +             <translation lang="pl">Angielski</translation>
  +             <translation lang="es">Inglés</translation>
  +             <translation lang="hy">²Ý·É»ñ»Ý</translation>
  +     </entry>
  +     <entry>
  +             <key>language2</key>
  +             <translation lang="en">German</translation>
  +             <translation lang="ru">Немецкий</translation>
  +             <translation lang="de">Russe</translation>
  +             <translation lang="pl">Rosyjski</translation>
  +             <translation lang="es">Ruso</translation>
  +             <translation lang="hy">èáõë»ñ»Ý</translation>
  +     </entry>
  +     <entry>
  +             <key>language3</key>
  +             <translation lang="en">Polish</translation>
  +             <translation lang="ru">Польский</translation>
  +             <translation lang="de">Polnisch</translation>
  +             <translation lang="pl">Niemiecki</translation>
  +             <translation lang="es">Alemán</translation>
  +             <translation lang="hy">¶»ñٳݻñ»Ý</translation>
  +     </entry>
  +     <entry>
  +             <key>language4</key>
  +             <translation lang="en">Spanish</translation>
  +             <translation lang="ru">Испанский</translation>
  +             <translation lang="de">Spanisch</translation>
  +             <translation lang="pl">Hiszpañski</translation>
  +             <translation lang="es">Polaco</translation>
  +             <translation lang="hy">Ȼѻñ»Ý</translation>
  +     </entry>
  +     <entry>
  +             <key>language5</key>
  +             <translation lang="en">Armenian</translation>
  +             <translation lang="ru">Армянский</translation>
  +             <translation lang="de">Armenier</translation>
  +             <translation lang="pl">Armeñski</translation>
  +             <translation lang="es">Armenio</translation>
  +             <translation lang="hy">Æëå³Ý»ñ»Ý</translation>
  +     </entry>
  +     <entry>
  +             <key>Hello, internationalization!</key>
  +             <translation lang="en">Hello, 
internationalization!</translation>
  +             <translation lang="ru">Привет, 
многоязычность!</translation>
  +             <translation lang="de">Herzlich willkommen, 
Internationalisierung!</translation>
  +             <translation lang="pl">Witam, oto przykład wielojęzycznej 
strony!</translation>
  +             <translation lang="es">¡¡Hola!, 
internacionalización!</translation>
  +             <translation lang="hy">´³ñ¢°, 
ÇÝï»ñݳóÛáݳÉáõÃÛáõÝ£</translation>
  +     </entry>
  +     <entry>
  +             <key>Documentation link:</key>
  +             <translation lang="en">See i18n documentation for 
details:</translation>
  +             <translation lang="ru">Для дополнительной 
информации по i18n смотри:</translation>
  +             <translation lang="de">Näheres unter der i18n 
Dokumentation:</translation>
  +             <translation lang="pl">Widzą i18n dokumentacja dla 
szczegółów:</translation>
  +             <translation lang="es">Visto la documentación i18n para 
detalles:</translation>
  +             <translation lang="hy">سÝñ³Ù³ë 
µ³ó³ïñáõÃÛ³Ý Ñ³Ù³ñ ݳÇñª</translation>
  +     </entry>
  +     <entry>
  +             <key>first</key>
  +             <translation lang="en">First</translation>
  +             <translation lang="ru">Первый</translation>
  +             <translation lang="de">Erstens</translation>
  +             <translation lang="pl">Pierwszy</translation>
  +             <translation lang="es">Primero</translation>
  +             <translation lang="hy">²é³çÇÝ</translation>
  +     </entry>
  +     <entry>
  +             <key>second</key>
  +             <translation lang="en">Second</translation>
  +             <translation lang="ru">Второй</translation>
  +             <translation lang="de">Zweitens</translation>
  +             <translation lang="pl">Drugi</translation>
  +             <translation lang="es">Segundo</translation>
  +             <translation lang="hy">ºñÏñáñ¹</translation>
  +     </entry>
  +     <entry>
  +             <key>third</key>
  +             <translation lang="en">Third</translation>
  +             <translation lang="ru">Третий</translation>
  +             <translation lang="de">Drittens</translation>
  +             <translation lang="pl">Trzeci</translation>
  +             <translation lang="es">Tercio</translation>
  +             <translation lang="hy">ºññáñ¹</translation>
  +     </entry>
  +     <entry>
  +             <key>forth</key>
  +             <translation lang="en">Forth</translation>
  +             <translation lang="ru">Четвертый</translation>
  +             <translation lang="de">Viertens</translation>
  +             <translation lang="pl">Czwarty</translation>
  +             <translation lang="es">En adelante</translation>
  +             <translation lang="hy">¼áñáñ¹</translation>
  +     </entry>
  +     <entry>
  +             <key>article</key>
  +             <translation lang="en">Article</translation>
  +             <translation lang="ru">Статья</translation>
  +             <translation lang="de">Artikel</translation>
  +             <translation lang="pl">Artykuł</translation>
  +             <translation lang="es">Artículo</translation>
  +             <translation lang="hy">Ðá¹í³Í</translation>
  +     </entry>
  +     <entry>
  +             <key>article_text1</key>
  +             <translation lang="en">This is a i18n paragraph.</translation>
  +             <translation lang="ru">Это 
интернационализированный абзац.</translation>
  +             <translation lang="de">Dies ist ein Absatz nach 
i18n.</translation>
  +             <translation lang="pl">To jest paragraf w i18n.</translation>
  +             <translation lang="es">Esto es un párrafo i18n.</translation>
  +             <translation lang="hy">ê³ ÇÝï»ñݳóÛáÝ³É 
å³ñ³·ñ³ý ¿£</translation>
  +     </entry>
  +     <entry>
  +             <key>article_text2</key>
  +             <translation lang="en">This is another i18n paragraph and is 
also a cool one.</translation>
  +             <translation lang="ru">Это тоже 
интернационализированный абзац и такой же 
классный.</translation>
  +             <translation lang="de">Dies ist ein weiterer Absatz nach i18n 
und auch noch ein ziemlich cooler dazu.</translation>
  +             <translation lang="pl">To jest następny paragraf w i18n i jest 
takze fajny.</translation>
  +             <translation lang="es">Esto es otro párrafo i18n y es también 
uno 'cool'.</translation>
  +             <translation lang="hy">ê³ ÙÇ áõñÇß 
ÇÝï»ñݳóÛáÝ³É å³ñ³·ñ³ý ¿, ¢ ÝáõÛÝ å»ë 
ó»Ýïñ£</translation>
  +     </entry>
  +     <entry>
  +             <key>copyright</key>
  +             <translation lang="en">Copyright © 2001 Konstantin Piroumian. 
No rights are reserved.</translation>
  +             <translation lang="ru">Авторские права © 2001 
Константин Пирумян. Ничто не 
защищено.</translation>
  +             <translation lang="de">Copyright © 2001 Konstantin Piroumian. 
Deutsche Übersetzung von Jörg Prante.</translation>
  +             <translation lang="pl">Copyright © 2001 Konstantin Piroumian i 
Krzysztof Zieliński. Żadne prawa nie są zastrzeżone:)</translation>
  +             <translation lang="es">Copyright © 2001 Konstantin Piroumian. 
Ningunos derechos son reservados.</translation>
  +             <translation lang="hy">Copyright © 2001 Konstantin Piroumian. 
àãÇÝã ãÇ å³Ñå³Ýí³Í£</translation>
  +     </entry>
  +     <entry>
  +             <key>Hello, {0}! Glad to see you!</key>
  +             <translation lang="en">Hello, {0}! Glad to see 
you!</translation>
  +             <translation lang="ru">Привет, {0}! Рад тебя 
видеть!</translation>
  +             <translation lang="de">Hallo {0}! Schön, dich zu 
sehen!</translation>
  +             <translation lang="pl">Witam, {0}! Miło Cię 
widzieć!</translation>
  +             <translation lang="es">¡¡Hola!, {0}! ¡Alegre de 
verle!</translation>
  +             <translation lang="hy">´³ñ¢¯ {0}: àõñ³Ë »Ù ù»½ 
ï»ëݻɣ</translation>
  +     </entry>
  +     <entry>
  +             <key>Kot</key>
  +             <translation lang="en">Tomcat</translation>
  +             <translation lang="ru">Кот</translation>
  +             <translation lang="de">Tomcat</translation>
  +             <translation lang="pl">Tomcat</translation>
  +             <translation lang="es">Gato</translation>
  +             <translation lang="hy">γïáõ</translation>
  +     </entry>
  +     <entry>
  +             <key>none</key>
  +             <translation lang="en">None</translation>
  +             <translation lang="ru">Никто</translation>
  +             <translation lang="de">nichts</translation>
  +             <translation lang="pl">Nic</translation>
  +             <translation lang="es">Ninguno</translation>
  +             <translation lang="hy">àã áù</translation>
  +     </entry>
  +     <entry>
  +             <key>one</key>
  +             <translation lang="en">one</translation>
  +             <translation lang="ru">раз</translation>
  +             <translation lang="de">eins</translation>
  +             <translation lang="pl">raz</translation>
  +             <translation lang="es">un</translation>
  +             <translation lang="hy">Ù»Ï</translation>
  +     </entry>
  +     <entry>
  +             <key>two</key>
  +             <translation lang="en">two</translation>
  +             <translation lang="ru">два</translation>
  +             <translation lang="de">zwei</translation>
  +             <translation lang="pl">dwa</translation>
  +             <translation lang="es">dos</translation>
  +             <translation lang="hy">»ñÏáõë</translation>
  +     </entry>
  +</translations>
  
  
  
  1.4       +48 -32    xml-cocoon2/xdocs/i18n.xml
  
  Index: i18n.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/xdocs/i18n.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- i18n.xml  2001/06/01 16:15:03     1.3
  +++ i18n.xml  2001/06/15 15:01:20     1.4
  @@ -7,7 +7,7 @@
                        <person name="Konstantin Piroumian" email="[EMAIL 
PROTECTED]"/>
                </authors>
                <abstract>
  -             This document describes an aproach for internationalization of 
XML
  +             This document describes an approach for internationalization of 
XML
                documents within Cocoon 2. It introduces some tags to markup 
text 
                that should be translated and a format for dictionaries.
                The first proposal was made by Infozone Group 
(http://www.infozone-group.org).
  @@ -30,7 +30,7 @@
                                
<code>xmlns:i18n="http://apache.org/cocoon/i18n/2.0";</code>
                                </p>
                                <p>
  -                             First implementation was developed by <link 
href="mailto:[EMAIL PROTECTED]">Lassi Immonen</link>. In this implementation 
the syntax was changed according to the <link 
href="http://www.infozone-group.org";>Infozone Group's</link> i18n proposal 
(with a little difference) and new features were implemented.
  +                             First implementation was developed by <link 
href="mailto:[EMAIL PROTECTED]">Lassi Immonen</link>. In this implementation 
syntax was changed according to the <link 
href="http://www.infozone-group.org";>Infozone Group's</link> i18n proposal 
(with a little difference) and some new features were implemented.
                                </p>
                        </s2>
                        <s2 title="Features supported">
  @@ -42,6 +42,10 @@
                                        <li>Attribute translation</li>
                                        <li>Param substitution</li>
                                        <li>Substitution param translation</li>
  +                                     <li>Date internationalization 
(New!)</li>
  +                                     <li>Number internationalization 
(New!)</li>
  +                                     <li>Locale support (New!)</li>
  +                                     <li>A dictionary update and language 
addition automation stylesheet (New!)</li>
                                </ul>
                                <p>
                                        A simple example of i18n:
  @@ -52,12 +56,11 @@
   </para>]]></source>
                                <p>
                                        Text inside the 
<code><![CDATA[<i18n:text>]]></code> will be used as a key to find the 
  -                                     translation in the dictionary. All 
attributes that are listed in the <code><![CDATA[<i18n:attr>]]></code> 
attribute also will
  -                                     be translated and their values will be 
used as dicionary keys.
  +                                     translation in the dictionary. All 
attributes that are listed in the <code><![CDATA[<i18n:attr>]]></code> 
attribute also will be translated and their values will be used as dicionary 
keys.
                                </p>
                                <note>
  -                                     This i18n approach is not designed to 
implement i18n of dates, currencies, etc.
  -                                     Maybe this features will be supported 
in future versions.
  +                                     This i18n approach was re-designed to 
implement i18n of dates, currencies, etc.
  +                                     Although supported possibilities are 
quite enough for complicated formatting, but in some cases you will need to use 
XSP to achieve more flexibility.
                                </note>
                        </s2>
                </s1>
  @@ -81,7 +84,7 @@
                                <source><![CDATA[
   <i18n:text i18n:key="key_text">Default value</i18n:text>]]></source>
                                <note>
  -                             Maybe it would be better to have a possibility 
to use i18n:key in any element and not only in i18n:text.
  +                             Maybe it would be better to have a possibility 
to use i18n:key in any element and not only in i18n:text?
                                E.g.: 
                                <code><![CDATA[
   <ul>
  @@ -106,21 +109,21 @@
        <i18n:param>text</i18n:param>
        <i18n:param>here</i18n:param>
   </i18n:translate>]]></source>
  -                             <p>
  +                     <p>
                            Now we want to translate this into German.
                            First, the processor will look into the dictionary, 
we specified, for 
                            the string:
                        </p>
  -                             <p>
  -                                     <em>Some {0} was inserted {1}.</em>
  -                             </p>
  -                             <p>
  +                     <p>
  +                             <em>Some {0} was inserted {1}.</em>
  +                     </p>
  +                     <p>
                                It finds the string and translates it to German:
  -                     </p>
  -                             <p>
  +                     </p>
  +                     <p>
                                        <em>Etwas {0} wurde {1} eingesetzt.</em>
  -                             </p>
  -                             <p>
  +                     </p>
  +                     <p>
                            Now the processor will replace the parameters. {0} 
will be replaced 
                            with "text" and {1} with "here". This results in:
                        </p>
  @@ -159,6 +162,33 @@
                                        Parameter replacement is not available 
for attributes at this time.
                                </p>
                        </s2>
  +                     <s2 title="Date, time and number formatting">
  +                             <p>To format dates and time according to the 
current locale use <code><![CDATA[<i18n:date src-pattern="dd/MM/yyyy" 
pattern="dd:MMM:yyyy" value="01/01/2001" />]]></code>. The 
<code>'src-pattern'</code> attribute will be used to parse the 
<code>'value'</code>, then the date will be formatted according to the current 
locale using the format specified by <code>'pattern'</code> attribute.
  +                             </p>
  +                             <p>
  +                                     If no pattern was specified then the 
date will be formatted with the <code>DateFormat.DEFAULT</code> format (both 
date and time). If no value for the date is specified then the current date 
will be used. E.g.: <code><![CDATA[<i18n:date ]]></code> will result in the 
current date and time, formatted with default localized pattern.
  +                             </p>
  +                             <p>To format numbers in locale sensitive manner 
use <code><![CDATA[<i18n:number pattern="0.##" value="2.0" />]]></code>. This 
will be useful for Arabic, Indian, etc. number formatting. Additionally, 
currencies and percent formatting can be used. E.g.: 
  +                             </p>
  +                                     <ul>
  +                                             <li><code><![CDATA[<i18n:number 
sub-type="currency" value="1703.74" />]]></code> will result in localized 
presentation of the <code>value</code> - $1,703.74 for US locale.</li>
  +                                             <li><code><![CDATA[<i18n:number 
sub-type="percent" value="1.2" />]]></code> will result in localized percent 
<code>value</code> - %120 for most of the locales.</li>
  +                                     </ul>
  +                             <p>
  +                                     Also, date and number formatting can be 
used with substitution params. Additional <code>type</code> attribute must be 
used with params to indicate the param type (date or number). Default type is 
<code>string</code>.
  +                             </p>
  +                             <source><![CDATA[
  +<i18n:translate>
  +     <i18n:text>You have to pay {0} for {1} pounds or {2} of your profit. 
Valid from {3}</i18n:text>
  +     <i18n:param type="number" sub-type="currency" 
pattern="$#,##0.00">102.5</i18n:param>
  +     <i18n:param type="number" value="2.5">
  +     <i18n:param type="number" sub-type="percent" value="0.10" />    
  +     <i18n:param type="date" pattern="dd-MMM-yy" />
  +</i18n:translate>]]></source>
  +                             <p>
  +                                     Result will be like this: <code>You 
have to pay $102.5 for 2.5 pounds or 10% of your profit. Valid from 
13-Jun-01</code>
  +                             </p>            
  +                     </s2>
                        <s2 title="Dictionaries">
                                <p>
                                        Dictionaries contain the translations 
for the text to be translated.
  @@ -263,26 +293,12 @@
                        </note>
                </s1>
                <s1 title="Finally">
  -                     <s2 title="What to be done">
  -                             <p>
  -                                     Some more features must be added for 
more flexibility and convenience:
  -                             </p>
  +                     <s2 title="To be done">
                                <ul>
  +                                     <li>Multiple dictionary support</li> 
                                        <li>Dictionary import and include 
capabilities (like in XSLT)</li>
                                        <li>Command line dictionary-from-source 
generation</li>
                                        <li>Dictionary caching</li>
  -                                     <li>Date translation:
  -                                             <code><![CDATA[
  -<i18n:date src-pattern="dd/MM/yyyy" pattern="dd:MMM:yyyy" 
value="01/01/2001"/>
  -                                             ]]></code>
  -                                      - <code>'src-pattern'</code> will be 
used to parse the <code>'value'</code>, then the date will be formatted 
according to the current lang (Locale) using the <code>'pattern'</code> format.
  -                                     </li>
  -                                     <li>Number localized formatting
  -                                             <code><![CDATA[
  -<i18n:decimal pattern="0.##" value="2.0" />                                  
        
  -                                             ]]></code>
  -                                              - this will be useful for 
Arabic, Indian, etc. number formatting.
  -                                     </li>
                                </ul>
                        </s2>
                        <s2 title="Contacts">
  
  
  

----------------------------------------------------------------------
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