cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject cvs commit: cocoon-2.1 status.xml
Date Thu, 22 May 2003 16:01:59 GMT
bruno       2003/05/22 09:01:59

  Modified:    src/java/org/apache/cocoon/transformation
                        I18nTransformer.java
               src/documentation/xdocs/userdocs/transformers
                        i18n-transformer.xml
               .        status.xml
  Log:
  I18nTransformer: reworked the "dec-and-grp-locale" attribute into a
  "currency" attribute as discussed on cocoon-dev
  
  Revision  Changes    Path
  1.9       +26 -14    cocoon-2.1/src/java/org/apache/cocoon/transformation/I18nTransformer.java
  
  Index: I18nTransformer.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/transformation/I18nTransformer.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- I18nTransformer.java	20 May 2003 15:49:56 -0000	1.8
  +++ I18nTransformer.java	22 May 2003 16:01:57 -0000	1.9
  @@ -625,11 +625,14 @@
   
       /**
        * This attribute is used to specify a different locale for the
  -     * GroupingSeparator and MonetaryDecimalSeparator.
  +     * currency. When specified, this locale will be combined with
  +     * the "normal" locale: e.g. the seperator symbols are taken from
  +     * the normal locale but the currency symbol and possition will
  +     * be taken from the currency locale.
        * This enables to see a currency formatted for Euro but with US
        * grouping and decimal char.
        */
  -    public static final String I18N_DEC_AND_GRP_LOCALE_ATTRIBUTE = "dec-and-grp-locale";
  +    public static final String CURRENCY_LOCALE_ATTRIBUTE = "currency";
   
       /**
        * This attribute can be used on <code>i18n:text</code> to indicate the
catalogue
  @@ -1404,9 +1407,9 @@
               formattingParams.put(I18N_LOCALE_ATTRIBUTE, attr_value);
           }
   
  -        attr_value = attr.getValue(I18N_DEC_AND_GRP_LOCALE_ATTRIBUTE);
  +        attr_value = attr.getValue(CURRENCY_LOCALE_ATTRIBUTE);
           if (attr_value != null) {
  -            formattingParams.put(I18N_DEC_AND_GRP_LOCALE_ATTRIBUTE, attr_value);
  +            formattingParams.put(CURRENCY_LOCALE_ATTRIBUTE, attr_value);
           }
   
           attr_value = attr.getValue(I18N_SRC_LOCALE_ATTRIBUTE);
  @@ -1886,8 +1889,17 @@
           // locale, may be switched locale
           Locale loc = getLocale(params, I18N_LOCALE_ATTRIBUTE);
           Locale srcLoc = getLocale(params, I18N_SRC_LOCALE_ATTRIBUTE);
  -        // Decimal and Grouping locale
  -        Locale dgLoc = getLocale(params, I18N_DEC_AND_GRP_LOCALE_ATTRIBUTE);
  +        // currency locale
  +        Locale currencyLoc = getLocale(params, CURRENCY_LOCALE_ATTRIBUTE);
  +        // decimal and grouping locale
  +        Locale dgLoc = null;
  +        if (currencyLoc != null) {
  +            // the reasoning here is: if there is a currency locale, then start from that
  +            // one but take certain properties (like decimal and grouping seperation symbols)
  +            // from the default locale (this happens further on).
  +            dgLoc = loc;
  +            loc = currencyLoc;
  +        }
   
           // src format
           DecimalFormat from_fmt = (DecimalFormat)NumberFormat.getInstance(srcLoc);
  @@ -1957,13 +1969,13 @@
           }
   
           if(dgLoc != null) {
  -            DecimalFormat _df = (DecimalFormat)NumberFormat.getCurrencyInstance(dgLoc);
  -            DecimalFormatSymbols _dfsNew = _df.getDecimalFormatSymbols();
  -            DecimalFormatSymbols _dfsOrig = to_fmt.getDecimalFormatSymbols();
  -            _dfsOrig.setDecimalSeparator(_dfsNew.getDecimalSeparator());
  -            _dfsOrig.setMonetaryDecimalSeparator(_dfsNew.getMonetaryDecimalSeparator());
  -            _dfsOrig.setGroupingSeparator(_dfsNew.getGroupingSeparator());
  -            to_fmt.setDecimalFormatSymbols(_dfsOrig);
  +            DecimalFormat df = (DecimalFormat)NumberFormat.getCurrencyInstance(dgLoc);
  +            DecimalFormatSymbols dfsNew = df.getDecimalFormatSymbols();
  +            DecimalFormatSymbols dfsOrig = to_fmt.getDecimalFormatSymbols();
  +            dfsOrig.setDecimalSeparator(dfsNew.getDecimalSeparator());
  +            dfsOrig.setMonetaryDecimalSeparator(dfsNew.getMonetaryDecimalSeparator());
  +            dfsOrig.setGroupingSeparator(dfsNew.getGroupingSeparator());
  +            to_fmt.setDecimalFormatSymbols(dfsOrig);
           }
   
           // pattern overwrites locale format
  
  
  
  1.4       +7 -6      cocoon-2.1/src/documentation/xdocs/userdocs/transformers/i18n-transformer.xml
  
  Index: i18n-transformer.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/documentation/xdocs/userdocs/transformers/i18n-transformer.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- i18n-transformer.xml	20 May 2003 15:49:57 -0000	1.3
  +++ i18n-transformer.xml	22 May 2003 16:01:58 -0000	1.4
  @@ -254,14 +254,15 @@
                           <li><code><![CDATA[<i18n:number type="percent"
value="1.2" />]]></code> will result in localized percent value: %120 for most
of the locales.</li>
                       </ul>
                   <p>
  -                 If someone from US want to see sales figures from a store in Germany,
  -                 the value is formatted with locale="de_DE", e.g.
  -                 100,00 &#x20AC;. The decimal and grouping separator than is also in
de_DE locale.
  -                 This may be leading to some confusion/misunderstanding because
  +                 If someone from US want to see sales figures from a store in
  +                 Germany, formatted using the german currency, you would need
  +                 to use locale="de_DE" to get the currency right, e.g. 100,00
  +                 &#x20AC;. The decimal and grouping separator is then also from
  +                 the de_DE locale.  This may lead to some confusion because
                    people from US know the "," as thousand separator.
   
  -                 There is a attribute called "dec-and-grp-locale", so that the output from
  -                 <code><![CDATA[<i18n:number type="currency" locale="de_DE"
dec-and-grp-locale="en_US">100</i18n:number>]]></code>
  +                 Therefore a "currency" attribute is available, so that the output from
  +                 <code><![CDATA[<i18n:number type="currency" locale="en_US"
currency="de_DE">100</i18n:number>]]></code>
                    results in 100.00 &#x20AC;
                   </p>
                   <anchor id="i18n_param"/><p>
  
  
  
  1.41      +3 -1      cocoon-2.1/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/status.xml,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- status.xml	20 May 2003 16:00:36 -0000	1.40
  +++ status.xml	22 May 2003 16:01:58 -0000	1.41
  @@ -181,7 +181,9 @@
   
    <release version="@version@" date="@date@">
     <action dev="BRD" type="add" fixes-bug="19894" due-to="Michael Enke" due-to-email="michael.enke@wincor-nixdorf.com">
  -    I18nTransformer: support a dec-and-grp-locale attribute on i18n:number.
  +    I18nTransformer: support a currency attribute on i18n:number. This allows
  +    to take the currency symbol and formatting from one locale and the decimal
  +    and grouping separation symbols from another locale.
     </action>
     <action dev="BRD" type="fix" fixes-bug="19881" due-to="Michael Enke" due-to-email="michael.enke@wincor-nixdorf.com">
       Fixed synchronisation problem in I18nTransformer when retrieving catalogues.
  
  
  

Mime
View raw message