Author: svenmeier
Date: Mon Jul  4 18:14:08 2011
New Revision: 1142755

URL: http://svn.apache.org/viewvc?rev=1142755&view=rev
Log:
WICKET-3310: i18n for duration

Added:
    
wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/time/Duration.properties
   (with props)
    
wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/time/Duration_de.properties
   (with props)
    
wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/time/Duration_fr.properties
   (with props)
Modified:
    
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/util/time/DurationTest.java
    
wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/time/Duration.java

Modified: 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/util/time/DurationTest.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/test/java/org/apache/wicket/util/time/DurationTest.java?rev=1142755&r1=1142754&r2=1142755&view=diff
==============================================================================
--- 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/util/time/DurationTest.java
 (original)
+++ 
wicket/trunk/wicket-core/src/test/java/org/apache/wicket/util/time/DurationTest.java
 Mon Jul  4 18:14:08 2011
@@ -104,7 +104,9 @@ public final class DurationTest
                assertEquals(Duration.minutes(90), Duration.valueOf("90 
minutes"));
                assertEquals(Duration.hours(1.5), Duration.valueOf("1.5 hour", 
Locale.US));
                assertEquals(Duration.hours(1.5), Duration.valueOf("1,5 hour", 
Locale.GERMAN));
+               assertEquals("1 hour", Duration.hours(1).toString(Locale.US));
                assertEquals("1.5 hours", 
Duration.hours(1.5).toString(Locale.US));
-               assertEquals("1,5 hours", 
Duration.hours(1.5).toString(Locale.GERMAN));
+               assertEquals("1 Stunde", 
Duration.hours(1).toString(Locale.GERMAN));
+               assertEquals("1,5 Stunden", 
Duration.hours(1.5).toString(Locale.GERMAN));
        }
 }

Modified: 
wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/time/Duration.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/time/Duration.java?rev=1142755&r1=1142754&r2=1142755&view=diff
==============================================================================
--- 
wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/time/Duration.java
 (original)
+++ 
wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/time/Duration.java
 Mon Jul  4 18:14:08 2011
@@ -17,6 +17,7 @@
 package org.apache.wicket.util.time;
 
 import java.util.Locale;
+import java.util.ResourceBundle;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -526,7 +527,7 @@ public class Duration extends AbstractTi
                                return unitString(seconds(), "second", locale);
                        }
 
-                       return getMilliseconds() + " milliseconds";
+                       return unitString(seconds(), "millisecond", locale);
                }
                else
                {
@@ -535,18 +536,29 @@ public class Duration extends AbstractTi
        }
 
        /**
-        * Converts a value to a unit-suffixed value, taking care of English 
singular/plural suffix.
+        * Converts a value to a unit-suffixed value.
         * 
         * @param value
         *            a <code>double</code> value to format
         * @param units
-        *            the units to apply singular or plural suffix to
+        *            the units
         * @param locale
         *            the <code>Locale</code>
         * @return a <code>String</code> representation
         */
        private String unitString(final double value, final String units, final 
Locale locale)
        {
-               return StringValue.valueOf(value, locale) + " " + units + 
((value > 1.0) ? "s" : "");
+               final String key;
+               if (value > 1.0)
+               {
+                       key = units + "s";
+               }
+               else
+               {
+                       key = units;
+               }
+
+               return StringValue.valueOf(value, locale) + " " +
+                       ResourceBundle.getBundle(Duration.class.getName(), 
locale).getString(key);
        }
 }

Added: 
wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/time/Duration.properties
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/time/Duration.properties?rev=1142755&view=auto
==============================================================================
--- 
wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/time/Duration.properties
 (added)
+++ 
wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/time/Duration.properties
 Mon Jul  4 18:14:08 2011
@@ -0,0 +1,25 @@
+#  Licensed to the Apache Software Foundation (ASF) under one or more
+#  contributor license agreements.  See the NOTICE file distributed with
+#  this work for additional information regarding copyright ownership.
+#  The ASF licenses this file to You under the Apache License, Version 2.0
+#  (the "License"); you may not use this file except in compliance with
+#  the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+day=day
+hour=hour
+minute=minute
+second=second
+millisecond=millisecond
+
+days=days
+hours=hours
+minutes=minutes
+seconds=seconds
+milliseconds=milliseconds

Propchange: 
wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/time/Duration.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/time/Duration_de.properties
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/time/Duration_de.properties?rev=1142755&view=auto
==============================================================================
--- 
wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/time/Duration_de.properties
 (added)
+++ 
wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/time/Duration_de.properties
 Mon Jul  4 18:14:08 2011
@@ -0,0 +1,25 @@
+#  Licensed to the Apache Software Foundation (ASF) under one or more
+#  contributor license agreements.  See the NOTICE file distributed with
+#  this work for additional information regarding copyright ownership.
+#  The ASF licenses this file to You under the Apache License, Version 2.0
+#  (the "License"); you may not use this file except in compliance with
+#  the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+day=Tag
+hour=Stunde
+minute=Minute
+second=Sekunde
+millisecond=Millisekunde
+
+days=Tage
+hours=Stunden
+minutes=Minuten
+seconds=Sekunden
+milliseconds=Millisekunden

Propchange: 
wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/time/Duration_de.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/time/Duration_fr.properties
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/time/Duration_fr.properties?rev=1142755&view=auto
==============================================================================
--- 
wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/time/Duration_fr.properties
 (added)
+++ 
wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/time/Duration_fr.properties
 Mon Jul  4 18:14:08 2011
@@ -0,0 +1,25 @@
+#  Licensed to the Apache Software Foundation (ASF) under one or more
+#  contributor license agreements.  See the NOTICE file distributed with
+#  this work for additional information regarding copyright ownership.
+#  The ASF licenses this file to You under the Apache License, Version 2.0
+#  (the "License"); you may not use this file except in compliance with
+#  the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+day=jour
+hour=heure
+minute=minute
+second=seconde
+millisecond=milliseconde
+
+days=jours
+hours=heures
+minutes=minutes
+seconds=secondes
+milliseconds=millisecondes

Propchange: 
wicket/trunk/wicket-util/src/main/java/org/apache/wicket/util/time/Duration_fr.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain


Reply via email to