You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by fe...@apache.org on 2010/01/21 01:08:05 UTC
svn commit: r901450 - in /directory/sandbox/felixk/apacheds-i18n: ./ i18n/
i18n/src/ i18n/src/main/ i18n/src/main/java/ i18n/src/main/java/org/
i18n/src/main/java/org/apache/ i18n/src/main/java/org/apache/directory/
i18n/src/main/java/org/apache/direct...
Author: felixk
Date: Thu Jan 21 00:08:04 2010
New Revision: 901450
URL: http://svn.apache.org/viewvc?rev=901450&view=rev
Log:
Initial I18n module (DIRSERVER-506, DIRSERVER-886)
Each message will get a number (defined in Err.java as constant).
This constant will reflect an error description in a properties file, which can be translated.
A call for an error message will look like
Err.i18n(Err.ERR_X, [optional parameters comma separated])
Putting all the error codes and translations into one place (module) will give a bit more of work in the beginning, but will be better manageable later on IMO.
Added:
directory/sandbox/felixk/apacheds-i18n/i18n/ (with props)
directory/sandbox/felixk/apacheds-i18n/i18n/pom.xml (with props)
directory/sandbox/felixk/apacheds-i18n/i18n/src/
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/java/
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/java/org/
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/java/org/apache/
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/java/org/apache/directory/
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/java/org/apache/directory/server/
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/java/org/apache/directory/server/i18n/
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/java/org/apache/directory/server/i18n/Err.java (with props)
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties (with props)
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors_de.properties (with props)
directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors_fr.properties (with props)
directory/sandbox/felixk/apacheds-i18n/i18n/src/site/
directory/sandbox/felixk/apacheds-i18n/i18n/src/site/site.xml (with props)
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/GermanLanguageTest.java (with props)
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/MissingErrorCodeTest.java (with props)
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/UnknownLanguageTest.java (with props)
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/server/
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/server/i18n/
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/server/i18n/errors.properties (with props)
directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/server/i18n/errors_de.properties (with props)
Modified:
directory/sandbox/felixk/apacheds-i18n/pom.xml
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Jan 21 00:08:04 2010
@@ -0,0 +1,4 @@
+.settings
+target
+.classpath
+.project
Added: directory/sandbox/felixk/apacheds-i18n/i18n/pom.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/apacheds-i18n/i18n/pom.xml?rev=901450&view=auto
==============================================================================
--- directory/sandbox/felixk/apacheds-i18n/i18n/pom.xml (added)
+++ directory/sandbox/felixk/apacheds-i18n/i18n/pom.xml Thu Jan 21 00:08:04 2010
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>apacheds-parent</artifactId>
+ <groupId>org.apache.directory.server</groupId>
+ <version>1.5.6-SNAPSHOT</version>
+ </parent>
+ <groupId>org.apache.directory.server</groupId>
+ <artifactId>apacheds-i18n</artifactId>
+ <version>1.5.6-SNAPSHOT</version>
+ <name>ApacheDS I18n</name>
+
+ <description>Internationalization of errors and other messages</description>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <forkMode>always</forkMode>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/pom.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: directory/sandbox/felixk/apacheds-i18n/i18n/src/main/java/org/apache/directory/server/i18n/Err.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/apacheds-i18n/i18n/src/main/java/org/apache/directory/server/i18n/Err.java?rev=901450&view=auto
==============================================================================
--- directory/sandbox/felixk/apacheds-i18n/i18n/src/main/java/org/apache/directory/server/i18n/Err.java (added)
+++ directory/sandbox/felixk/apacheds-i18n/i18n/src/main/java/org/apache/directory/server/i18n/Err.java Thu Jan 21 00:08:04 2010
@@ -0,0 +1,93 @@
+/*
+ * 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.
+ *
+ */
+
+package org.apache.directory.server.i18n;
+
+
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+
+
+/**
+ * Provides i18n handling of error codes.
+ * About formatting see also {@link MessageFormat}
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class Err
+{
+ private final static ResourceBundle res = ResourceBundle.getBundle( "org/apache/directory/server/i18n/errors" );
+
+ public static String ERR_1 = "ERR 1";
+ public static String ERR_2 = "ERR 2";
+ public static String ERR_3 = "ERR 3";
+ public static String ERR_4 = "ERR 4";
+ public static String ERR_5 = "ERR 5";
+ public static String ERR_6 = "ERR 6";
+ public static String ERR_7 = "ERR 7";
+ public static String ERR_8 = "ERR 8";
+ public static String ERR_9 = "ERR 9";
+ public static String ERR_10 = "ERR 10";
+ public static String ERR_11 = "ERR 11";
+ public static String ERR_12 = "ERR 12";
+ public static String ERR_13 = "ERR 13";
+ public static String ERR_14 = "ERR 14";
+ public static String ERR_15 = "ERR 15";
+ public static String ERR_16 = "ERR 16";
+ public static String ERR_17 = "ERR 17";
+ public static String ERR_18 = "ERR 18";
+ public static String ERR_19 = "ERR 19";
+ public static String ERR_20 = "ERR 20";
+
+
+ /**
+ *
+ * Translate an error code with parameter
+ *
+ * @param err The error code
+ * @param argArray The parameters
+ * @return
+ */
+ public static String i18n( String err, Object... args )
+ {
+ try
+ {
+ return MessageFormat.format( res.getString( err ), args );
+ }
+ catch ( Exception e )
+ {
+ StringBuffer sb = new StringBuffer();
+ boolean comma = false;
+ for ( Object obj : args )
+ {
+ if ( comma )
+ {
+ sb.append( "," );
+ }
+ else
+ {
+ comma = true;
+ }
+ sb.append( obj );
+ }
+ return err + " (" + sb.toString() + ")";
+ }
+ }
+}
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/main/java/org/apache/directory/server/i18n/Err.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/main/java/org/apache/directory/server/i18n/Err.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties?rev=901450&view=auto
==============================================================================
--- directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties (added)
+++ directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties Thu Jan 21 00:08:04 2010
@@ -0,0 +1,21 @@
+#
+# 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.
+#
+#
+
+ERR\ 1=Err 1
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors_de.properties
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors_de.properties?rev=901450&view=auto
==============================================================================
--- directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors_de.properties (added)
+++ directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors_de.properties Thu Jan 21 00:08:04 2010
@@ -0,0 +1,21 @@
+#
+# 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.
+#
+#
+
+ERR\ 1=Err 1
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors_de.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors_de.properties
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors_fr.properties
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors_fr.properties?rev=901450&view=auto
==============================================================================
--- directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors_fr.properties (added)
+++ directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors_fr.properties Thu Jan 21 00:08:04 2010
@@ -0,0 +1,21 @@
+#
+# 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.
+#
+#
+
+ERR\ 1=Err 1
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors_fr.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/main/resources/org/apache/directory/server/i18n/errors_fr.properties
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: directory/sandbox/felixk/apacheds-i18n/i18n/src/site/site.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/apacheds-i18n/i18n/src/site/site.xml?rev=901450&view=auto
==============================================================================
--- directory/sandbox/felixk/apacheds-i18n/i18n/src/site/site.xml (added)
+++ directory/sandbox/felixk/apacheds-i18n/i18n/src/site/site.xml Thu Jan 21 00:08:04 2010
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<!--
+ @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+-->
+<project name="${project.name}">
+ <body>
+ <menu ref="parent" />
+ <menu ref="reports" />
+ </body>
+</project>
\ No newline at end of file
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/site/site.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/site/site.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/GermanLanguageTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/GermanLanguageTest.java?rev=901450&view=auto
==============================================================================
--- directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/GermanLanguageTest.java (added)
+++ directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/GermanLanguageTest.java Thu Jan 21 00:08:04 2010
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ *
+ */
+
+package org.apache.directory.server.i18n;
+
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Locale;
+
+import org.junit.Test;
+
+
+/**
+ * Test when translation available for current locale -> use locale translation.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class GermanLanguageTest
+{
+
+ @Test
+ public void testTranslateDeLocale()
+ {
+ Locale.setDefault( Locale.GERMAN );
+ assertEquals( "Das ist Fehler 1", Err.i18n( Err.ERR_1 ) );
+ assertEquals( "Das ist Fehler 2 mit 1 Parameter", Err.i18n( Err.ERR_2, 1 ) );
+ assertEquals( "Das ist Fehler 3 mit 2 Parameter", Err.i18n( Err.ERR_3, 3, 2 ) );
+ assertEquals( "Das ist Fehler 4 mit mehr als 2 Parameter", Err.i18n( Err.ERR_4, 4, "mehr", "als", 2 ) );
+ }
+}
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/GermanLanguageTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/GermanLanguageTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/MissingErrorCodeTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/MissingErrorCodeTest.java?rev=901450&view=auto
==============================================================================
--- directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/MissingErrorCodeTest.java (added)
+++ directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/MissingErrorCodeTest.java Thu Jan 21 00:08:04 2010
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ *
+ */
+
+package org.apache.directory.server.i18n;
+
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+
+/**
+ * Test when missing error code.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class MissingErrorCodeTest
+{
+
+ @Test
+ public void testMissingErrorCode()
+ {
+ assertEquals( "MissingErrorCode ()", Err.i18n( "MissingErrorCode" ) );
+ assertEquals( "MissingErrorCode (1)", Err.i18n( "MissingErrorCode", 1 ) );
+ assertEquals( "MissingErrorCode (3,2)", Err.i18n( "MissingErrorCode", 3, 2 ) );
+ assertEquals( "MissingErrorCode (4,more,than,2)", Err.i18n( "MissingErrorCode", 4, "more", "than", 2 ) );
+ }
+}
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/MissingErrorCodeTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/MissingErrorCodeTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/UnknownLanguageTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/UnknownLanguageTest.java?rev=901450&view=auto
==============================================================================
--- directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/UnknownLanguageTest.java (added)
+++ directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/UnknownLanguageTest.java Thu Jan 21 00:08:04 2010
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ *
+ */
+
+package org.apache.directory.server.i18n;
+
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Locale;
+
+import org.junit.Test;
+
+
+/**
+ * Test when no translation available for current locale -> use default translation.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class UnknownLanguageTest
+{
+
+ @Test
+ public void testTranslateUnknownLocale()
+ {
+ Locale.setDefault( Locale.TRADITIONAL_CHINESE );
+ assertEquals( "This is error 1", Err.i18n( Err.ERR_1 ) );
+ assertEquals( "This is error 2 with 1 parameter", Err.i18n( Err.ERR_2, 1 ) );
+ assertEquals( "This is error 3 with 2 parameters", Err.i18n( Err.ERR_3, 3, 2 ) );
+ assertEquals( "This is error 4 with more than 2 parameters", Err.i18n( Err.ERR_4, 4, "more", "than", 2 ) );
+ }
+}
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/UnknownLanguageTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/test/java/org/apache/directory/server/i18n/UnknownLanguageTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/server/i18n/errors.properties
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/server/i18n/errors.properties?rev=901450&view=auto
==============================================================================
--- directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/server/i18n/errors.properties (added)
+++ directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/server/i18n/errors.properties Thu Jan 21 00:08:04 2010
@@ -0,0 +1,24 @@
+#
+# 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.
+#
+#
+
+ERR\ 1=This is error 1
+ERR\ 2=This is error 2 with {0} parameter
+ERR\ 3=This is error {0} with {1} parameters
+ERR\ 4=This is error {0} with {1} {2} {3} parameters
\ No newline at end of file
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/server/i18n/errors.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/server/i18n/errors.properties
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/server/i18n/errors_de.properties
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/server/i18n/errors_de.properties?rev=901450&view=auto
==============================================================================
--- directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/server/i18n/errors_de.properties (added)
+++ directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/server/i18n/errors_de.properties Thu Jan 21 00:08:04 2010
@@ -0,0 +1,24 @@
+#
+# 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.
+#
+#
+
+ERR\ 1=Das ist Fehler 1
+ERR\ 2=Das ist Fehler 2 mit {0} Parameter
+ERR\ 3=Das ist Fehler {0} mit {1} Parameter
+ERR\ 4=Das ist Fehler {0} mit {1} {2} {3} Parameter
\ No newline at end of file
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/server/i18n/errors_de.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: directory/sandbox/felixk/apacheds-i18n/i18n/src/test/resources/org/apache/directory/server/i18n/errors_de.properties
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: directory/sandbox/felixk/apacheds-i18n/pom.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/apacheds-i18n/pom.xml?rev=901450&r1=901449&r2=901450&view=diff
==============================================================================
--- directory/sandbox/felixk/apacheds-i18n/pom.xml (original)
+++ directory/sandbox/felixk/apacheds-i18n/pom.xml Thu Jan 21 00:08:04 2010
@@ -326,6 +326,7 @@
</dependencies>
<modules>
+ <module>i18n</module>
<module>all</module>
<module>utils</module>
<module>jdbm</module>