> > - To format dates and time according to the current locale use > src-pattern="dd/MM/yyyy" pattern="dd:MMM:yyyy" value="01/01/2001" />]]>
. The
> > 'src-pattern'
attribute will be used to parse the 'value'
, then the
> > date will be formatted according to the current locale using the format specified by
> > 'pattern'
attribute.
> > +
To format dates according to the current locale use > src-pattern="dd/MM/yyyy" pattern="dd:MMM:yyyy" value="01/01/2001" />]]>
. The
> > 'src-pattern'
attribute will be used to parse the 'value'
, then the
> > date will be formatted according to the current locale using the format specified by
> > 'pattern'
attribute.
> > +
> > + To format time for a locale (e.g. de_DE) use > src-pattern="dd/MM/yyyy" locale="de_DE" value="01/01/2001" />]]>
. The
> > 'src-pattern'
and 'pattern'
attribute may also contain
> > 'short'
, 'medium'
, 'long'
or 'full'
. The
> > date will be formatted according to this format.
> > +
> > + To format date and time use ]]>
.
> > +
> > + It is also possible to specify a src-locale: > src-pattern="short" src-locale="en_US" locale="de_DE"> 12/24/01 ]]>
will
> > result in 24.12.2001
> > +
> > +
> > + A given real pattern
and src-pattern
(not short, medium, long,
> > full) overwrites the locale
and src-locale
.
> >
> >
> > - If no pattern was specified then the date will be formatted with the
> > DateFormat.DEFAULT
format (both date and time). If no value for the date is
> > specified then the current date will be used. E.g.:
will
> > result in the current date and time, formatted with default localized pattern.
> > + If no pattern was specified then the date will be formatted with the
> > DateFormat.DEFAULT
format (both date and time). If no value for the date is
> > specified then the current date will be used. E.g.: ]]>
will
> > result in the current date, formatted with default localized pattern.
> >
> > To format numbers in locale sensitive manner use > pattern="0.##" value="2.0" />]]>
. This will be useful for Arabic, Indian, etc. number
> > formatting. Additionally, currencies and percent formatting can be used. E.g.:
> >
> > > --- I18nTransformer.java.orig Tue Aug 7 12:36:07 2001
> > +++ I18nTransformer.java Tue Aug 7 14:34:11 2001
> > @@ -176,6 +176,27 @@
> > * </map:match>
> > *
> > *
> > + *
> > + *
> > + * - gives now only the date.
> > + * - gives the date and time.
> > + * - gives the time.
> > + * - For date, date-time and time the pattern and src-pattern attribute
> > + * may have also values of: "short", "medium",
> > + * "long" or "full".
> > + *
> > + *
> > + *
> > + * - for date, date-time, time and number a different locale and
> > + * source-locale can be specified:
> > + *
> > + * 12/24/01
> > + *
> > + * will result in 24.12.2001
> > + * - A given real pattern and src-pattern (not short, medium, long, full)
> > + * overwrites the locale and src-locale
> > + *
> > + *
> > * Future work coming:
> > *
> > *
> > @@ -186,6 +207,7 @@
> > * @author Marcus Crafter
> > * @author Konstantin Piroumian
> > * @author Lassi Immonen
> > + * @author Michael Enke
> > */
> > public class I18nTransformer extends AbstractTransformer
> > implements Composable, Poolable, Configurable {
> > @@ -193,10 +215,10 @@
> > protected ComponentManager manager;
> >
> > /**
> > - * The namespace for i18n is "http://apache.org/cocoon/i18n/2.0"
> > + * The namespace for i18n is "http://apache.org/cocoon/i18n/2.1"
> > */
> > public static final String I18N_NAMESPACE_URI =
> > - "http://apache.org/cocoon/i18n/2.0";
> > + "http://apache.org/cocoon/i18n/2.1";
> >
> > //
> > // Dictionary elements and attributes
> > @@ -216,12 +238,16 @@
> > public static final String I18N_TRANSLATE_ELEMENT = "translate";
> > public static final String I18N_PARAM_ELEMENT = "param";
> > public static final String I18N_DATE_ELEMENT = "date";
> > + public static final String I18N_DATE_TIME_ELEMENT = "date-time";
> > + public static final String I18N_TIME_ELEMENT = "time";
> > public static final String I18N_NUMBER_ELEMENT = "number";
> >
> > // number and date formatting attributes
> > public static final String I18N_SRC_PATTERN_ATTRIBUTE = "src-pattern";
> > public static final String I18N_PATTERN_ATTRIBUTE = "pattern";
> > public static final String I18N_VALUE_ATTRIBUTE = "value";
> > + public static final String I18N_LOCALE_ATTRIBUTE = "locale";
> > + public static final String I18N_SRC_LOCALE_ATTRIBUTE = "src-locale";
> >
> > // configuration parameters
> > public static final String I18N_CATALOGUE_NAME = "catalogue-name";
> > @@ -253,7 +279,9 @@
> > private static final int STATE_TRANSLATE_KEY = 5;
> > private static final int STATE_TRANSLATE_TEXT_KEY = 6;
> > private static final int STATE_INSIDE_DATE = 7;
> > - private static final int STATE_INSIDE_NUMBER = 8;
> > + private static final int STATE_INSIDE_DATE_TIME = 8;
> > + private static final int STATE_INSIDE_TIME = 9;
> > + private static final int STATE_INSIDE_NUMBER = 10;
> >
> > /**
> > * Current state of the transformer.
> > @@ -316,7 +344,7 @@
> > /**
> > * Locale setting.
> > */
> > - private Locale locale;
> > + private Locale locale, loc, srcLoc;
> >
> > /**
> > * Date element attributes and their values.
> > @@ -534,6 +562,24 @@
> >
> > setFormattingParams(attr);
> > current_state = STATE_INSIDE_DATE;
> > + } else if (I18N_DATE_TIME_ELEMENT.equals(name)) {
> > + if (current_state != STATE_OUTSIDE) {
> > + throw new SAXException(this.getClass().getName()
> > + + ": i18n:date-time elements are not allowed "
> > + + "inside of other i18n elements.");
> > + }
> > +
> > + setFormattingParams(attr);
> > + current_state = STATE_INSIDE_DATE_TIME;
> > + } else if (I18N_TIME_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_TIME;
> > } else if (I18N_NUMBER_ELEMENT.equals(name)) {
> > if (current_state != STATE_OUTSIDE) {
> > throw new SAXException(this.getClass().getName()
> > @@ -573,6 +619,16 @@
> > formattingParams.put(I18N_VALUE_ATTRIBUTE, attr_value);
> > }
> >
> > + attr_value = attr.getValue(I18N_LOCALE_ATTRIBUTE);
> > + if (attr_value != null) {
> > + formattingParams.put(I18N_LOCALE_ATTRIBUTE, attr_value);
> > + }
> > +
> > + attr_value = attr.getValue(I18N_SRC_LOCALE_ATTRIBUTE);
> > + if (attr_value != null) {
> > + formattingParams.put(I18N_SRC_LOCALE_ATTRIBUTE, attr_value);
> > + }
> > +
> > attr_value = attr.getValue(I18N_TYPE_ATTRIBUTE);
> > if (attr_value != null) {
> > formattingParams.put(I18N_TYPE_ATTRIBUTE, attr_value);
> > @@ -605,8 +661,10 @@
> > break;
> > }
> > case STATE_INSIDE_DATE:
> > + case STATE_INSIDE_DATE_TIME:
> > + case STATE_INSIDE_TIME:
> > {
> > - endDateElement();
> > + endDate_TimeElement();
> > break;
> > }
> > case STATE_INSIDE_NUMBER:
> > @@ -688,6 +746,9 @@
> > break;
> > }
> > case STATE_INSIDE_DATE:
> > + case STATE_INSIDE_DATE_TIME:
> > + case STATE_INSIDE_TIME:
> > + case STATE_INSIDE_NUMBER:
> > {
> > if (formattingParams != null) {
> > if (formattingParams.get(I18N_VALUE_ATTRIBUTE) == null) {
> > @@ -699,18 +760,6 @@
> > }
> > break;
> > }
> > - case STATE_INSIDE_NUMBER:
> > - {
> > - if (formattingParams != null) {
> > - if (formattingParams.get(I18N_PATTERN_ATTRIBUTE) == null) {
> > - formattingParams.put(I18N_PATTERN_ATTRIBUTE, key);
> > - } else {
> > - // how to use the text inside of number element?
> > - }
> > -
> > - }
> > - break;
> > - }
> > default:
> > {
> > throw new SAXException(this.getClass().getName()
> > @@ -812,9 +861,11 @@
> > debug("Put param value: " + param_value);
> > formattingParams.put(I18N_VALUE_ATTRIBUTE, param_value);
> > }
> > - if ("date".equals(paramType)) {
> > - debug("Formatting date param: " + formattingParams);
> > - param_value = formatDate(formattingParams);
> > + if ("date".equals(paramType) ||
> > + "date-time".equals(paramType) ||
> > + "time".equals(paramType)) {
> > + debug("Formatting date_time param: " + formattingParams);
> > + param_value = formatDate_Time(formattingParams);
> > } else if ("number".equals(paramType)) {
> > debug("Formatting number param: " + formattingParams);
> > param_value = formatNumber(formattingParams);
> > @@ -848,17 +899,43 @@
> > current_state = STATE_OUTSIDE;
> > }
> >
> > - private void endDateElement() throws SAXException {
> > - String result = formatDate(formattingParams);
> > + private void endDate_TimeElement() throws SAXException {
> > + String result = formatDate_Time(formattingParams);
> > super.contentHandler.characters(result.toCharArray(), 0, result.length());
> > current_state = STATE_OUTSIDE;
> > }
> >
> > - private String formatDate(Map params) throws SAXException {
> > + private Locale getLocale(Map params, String attribute) {
> > + Locale locale = this.locale;
> >
> === message truncated ===> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> > For additional commands, email: cocoon-dev-help@xml.apache.org
>
>
> =====
> Davanum Srinivas, JNI-FAQ Manager
> http://www.jGuru.com/faq/JNI
>
> __________________________________________________
> Do You Yahoo!?
> Make international calls for as low as $.04/minute with Yahoo! Messenger
> http://phonecard.yahoo.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org