You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by df...@apache.org on 2005/02/18 16:23:27 UTC
svn commit: r154316 - in jakarta/commons/sandbox/i18n/trunk/src: resources/
test/ test/org/ test/org/apache/ test/org/apache/commons/
test/org/apache/commons/i18n/
Author: dflorey
Date: Fri Feb 18 07:23:26 2005
New Revision: 154316
URL: http://svn.apache.org/viewcvs?view=rev&rev=154316
Log:
Added localized resources
Added:
jakarta/commons/sandbox/i18n/trunk/src/resources/
jakarta/commons/sandbox/i18n/trunk/src/resources/messages.properties
jakarta/commons/sandbox/i18n/trunk/src/resources/messages_de.properties
jakarta/commons/sandbox/i18n/trunk/src/test/
jakarta/commons/sandbox/i18n/trunk/src/test/messageBundle.properties
jakarta/commons/sandbox/i18n/trunk/src/test/messageBundle_de.properties
jakarta/commons/sandbox/i18n/trunk/src/test/org/
jakarta/commons/sandbox/i18n/trunk/src/test/org/apache/
jakarta/commons/sandbox/i18n/trunk/src/test/org/apache/commons/
jakarta/commons/sandbox/i18n/trunk/src/test/org/apache/commons/i18n/
jakarta/commons/sandbox/i18n/trunk/src/test/org/apache/commons/i18n/I18nTestSuite.java
jakarta/commons/sandbox/i18n/trunk/src/test/org/apache/commons/i18n/ResourceBundleMessageProviderTest.java
jakarta/commons/sandbox/i18n/trunk/src/test/org/apache/commons/i18n/XMLMessageProviderTest.java
jakarta/commons/sandbox/i18n/trunk/src/test/testMessages.xml
Added: jakarta/commons/sandbox/i18n/trunk/src/resources/messages.properties
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/i18n/trunk/src/resources/messages.properties?view=auto&rev=154316
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/src/resources/messages.properties (added)
+++ jakarta/commons/sandbox/i18n/trunk/src/resources/messages.properties Fri Feb 18 07:23:26 2005
@@ -0,0 +1,5 @@
+messageNotFound=Message with key {0} not found
+noMessageEntriesFound=No message entries found for bundle with key {0}
+messageEntryNotFound=Message bundle with key {0} does not contain an entry with key {1}
+resourceBundleNotFound=Could not find resource bundle with base name {0}, uninstalling it
+messageParsingError=Error while parsing message file with id {0}
\ No newline at end of file
Added: jakarta/commons/sandbox/i18n/trunk/src/resources/messages_de.properties
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/i18n/trunk/src/resources/messages_de.properties?view=auto&rev=154316
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/src/resources/messages_de.properties (added)
+++ jakarta/commons/sandbox/i18n/trunk/src/resources/messages_de.properties Fri Feb 18 07:23:26 2005
@@ -0,0 +1,5 @@
+messageNotFound=Keine Nachricht mit Schlüssel {0} gefunden
+noMessageEntriesFound=Keine Einträge für die Nachricht mit Schlüssel {0} gefunden
+messageEntryNotFound=Die Nachricht mit Schlüssel {0} enthält keinen Eintrag mit Schlüssel {1}
+resourceBundleNotFound=Übersetzungsdatei mit dem Namen {0} wurde nicht gefunden und wird daher deinstalliert
+messageParsingError=Fehler beim Einlesen der Übersetzungsdatei mit der ID {0}
\ No newline at end of file
Added: jakarta/commons/sandbox/i18n/trunk/src/test/messageBundle.properties
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/i18n/trunk/src/test/messageBundle.properties?view=auto&rev=154316
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/src/test/messageBundle.properties (added)
+++ jakarta/commons/sandbox/i18n/trunk/src/test/messageBundle.properties Fri Feb 18 07:23:26 2005
@@ -0,0 +1,3 @@
+# Example for using message bundles using a flat properties-file
+helloWorld.title=Hello World
+helloWorld.text=I wish you a merry christmas!
\ No newline at end of file
Added: jakarta/commons/sandbox/i18n/trunk/src/test/messageBundle_de.properties
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/i18n/trunk/src/test/messageBundle_de.properties?view=auto&rev=154316
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/src/test/messageBundle_de.properties (added)
+++ jakarta/commons/sandbox/i18n/trunk/src/test/messageBundle_de.properties Fri Feb 18 07:23:26 2005
@@ -0,0 +1,3 @@
+# Example for using message bundles using a flat properties-file
+helloWorld.title=Hallo Welt
+helloWorld.text=Ich wünsche Dir alles Gute und ein frohes Fest!
\ No newline at end of file
Added: jakarta/commons/sandbox/i18n/trunk/src/test/org/apache/commons/i18n/I18nTestSuite.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/i18n/trunk/src/test/org/apache/commons/i18n/I18nTestSuite.java?view=auto&rev=154316
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/src/test/org/apache/commons/i18n/I18nTestSuite.java (added)
+++ jakarta/commons/sandbox/i18n/trunk/src/test/org/apache/commons/i18n/I18nTestSuite.java Fri Feb 18 07:23:26 2005
@@ -0,0 +1,38 @@
+/*
+*
+* ====================================================================
+*
+* Copyright 2004 The Apache Software Foundation
+*
+* Licensed 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.commons.i18n;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * @author Daniel Florey
+ *
+ */
+public class I18nTestSuite extends TestSuite {
+ public static void main(java.lang.String[] args) {
+ junit.textui.TestRunner.run(suite());
+ }
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(ResourceBundleMessageProviderTest.class);
+ return suite;
+ }
+}
Added: jakarta/commons/sandbox/i18n/trunk/src/test/org/apache/commons/i18n/ResourceBundleMessageProviderTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/i18n/trunk/src/test/org/apache/commons/i18n/ResourceBundleMessageProviderTest.java?view=auto&rev=154316
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/src/test/org/apache/commons/i18n/ResourceBundleMessageProviderTest.java (added)
+++ jakarta/commons/sandbox/i18n/trunk/src/test/org/apache/commons/i18n/ResourceBundleMessageProviderTest.java Fri Feb 18 07:23:26 2005
@@ -0,0 +1,57 @@
+/*
+*
+* ====================================================================
+*
+* Copyright 2004 The Apache Software Foundation
+*
+* Licensed 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.commons.i18n;
+
+import java.util.Locale;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.i18n.bundles.MessageBundle;
+
+/**
+ * @author Daniel Florey
+ *
+ */
+public class ResourceBundleMessageProviderTest extends TestCase {
+ public ResourceBundleMessageProviderTest(String testName) {
+ super(testName);
+ }
+
+ public void testInstallResourceBundle() {
+ System.out.println("INSTALL RESOURCE BUNDLE");
+ ResourceBundleMessageProvider.install("messageBundle");
+ MessageBundle testMessage = new MessageBundle("helloWorld");
+ Locale locale = Locale.GERMAN;
+ assertEquals(testMessage.getTitle(locale), "Hallo Welt");
+ }
+
+ public void testGetEntries() {
+ ResourceBundleMessageProvider.install("messageBundle");
+ Map entries = new ResourceBundleMessageProvider().getEntries("helloWorld", Locale.GERMAN);
+ assertTrue(entries.size() == 2 );
+ }
+
+ public void testFallbackToDefaultLocale() {
+ ResourceBundleMessageProvider.install("messageBundle");
+ Map entries = new ResourceBundleMessageProvider().getEntries("helloWorld", Locale.GERMAN);
+ assertTrue(entries.size() == 2 );
+ }
+}
\ No newline at end of file
Added: jakarta/commons/sandbox/i18n/trunk/src/test/org/apache/commons/i18n/XMLMessageProviderTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/i18n/trunk/src/test/org/apache/commons/i18n/XMLMessageProviderTest.java?view=auto&rev=154316
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/src/test/org/apache/commons/i18n/XMLMessageProviderTest.java (added)
+++ jakarta/commons/sandbox/i18n/trunk/src/test/org/apache/commons/i18n/XMLMessageProviderTest.java Fri Feb 18 07:23:26 2005
@@ -0,0 +1,49 @@
+/*
+*
+* ====================================================================
+*
+* Copyright 2004 The Apache Software Foundation
+*
+* Licensed 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.commons.i18n;
+
+import java.util.Locale;
+
+import org.apache.commons.i18n.bundles.MessageBundle;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Daniel Florey
+ *
+ */
+public class XMLMessageProviderTest extends TestCase {
+ public void testInstallResourceBundle() {
+ System.out.println("INSTALL RESOURCE BUNDLE");
+ XMLMessageProvider.install("org.apache.commons-i18n.test",
+ Thread.currentThread().getContextClassLoader().getResourceAsStream("testMessages.xml"));
+ MessageBundle testMessage = new MessageBundle("helloWorld");
+ Locale locale = Locale.GERMAN;
+ assertEquals(testMessage.getTitle(locale), "Hallo Welt");
+ }
+
+ /**
+ * Constructor for MessageManagerTest.
+ * @param arg0
+ */
+ public XMLMessageProviderTest(String testName) {
+ super(testName);
+ }
+}
Added: jakarta/commons/sandbox/i18n/trunk/src/test/testMessages.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/i18n/trunk/src/test/testMessages.xml?view=auto&rev=154316
==============================================================================
--- jakarta/commons/sandbox/i18n/trunk/src/test/testMessages.xml (added)
+++ jakarta/commons/sandbox/i18n/trunk/src/test/testMessages.xml Fri Feb 18 07:23:26 2005
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="iso-8859-1" ?>
+<messages>
+ <!-- Fell free to insert your locale or correct mispellings here -->
+ <message id="helloWorld">
+ <locale language="en">
+ <entry key="title">hello world</entry>
+ <entry key="text">hello world, we are in {0}.</entry>
+ <entry key="summary">sample summary to test english messages. Country = {0}, language = {1} and variant = {2}.</entry>
+ <entry key="details">sample deatils to test english messages. Country = {0}, language = {1} and variant = {2}.</entry>
+ </locale>
+ <locale language="pt" country="br">
+ <entry key="title">olo mundo</entry>
+ <entry key="text">hello mundo, nós estamos no {0}.</entry>
+ <entry key="summary">sample summary to test portuguese messages. Country = {0}, language = {1} and variant = {2}.</entry>
+ <entry key="details">sample deatils to test portuguese messages. Country = {0}, language = {1} and variant = {2}.</entry>
+ </locale>
+ <locale language="es">
+ <entry key="title">hola mundo</entry>
+ <entry key="text">hola mundo, estamos em los {0}.</entry>
+ <entry key="summary">sample summary to test spanish messages. Country = {0}, language = {1} and variant = {2}.</entry>
+ <entry key="details">sample deatils to test spanish messages. Country = {0}, language = {1} and variant = {2}.</entry>
+ </locale>
+ <locale language="it">
+ <entry key="title">ciao mondo</entry>
+ <entry key="text">ciao mondo, siamo negli {0}.</entry>
+ <entry key="summary">sample summary to test italian messages. Country = {0}, language = {1} and variant = {2}.</entry>
+ <entry key="details">sample deatils to test italian messages. Country = {0}, language = {1} and variant = {2}.</entry>
+ </locale>
+ <locale language="fr">
+ <entry key="title">bonjour monde</entry>
+ <entry key="text">bonjour monde, nous sommes aux {0}.</entry>
+ <entry key="summary">sample summary to test francais messages. Country = {0}, language = {1} and variant = {2}.</entry>
+ <entry key="details">sample deatils to test francais messages. Country = {0}, language = {1} and variant = {2}.</entry>
+ </locale>
+ <locale language="du">
+ <entry key="title">hello wereld</entry>
+ <entry key="text">hello wereld, zijn wij in de {0}.</entry>
+ <entry key="summary">sample summary to test dutch messages. Country = {0}, language = {1} and variant = {2}.</entry>
+ <entry key="details">sample deatils to test dutch messages. Country = {0}, language = {1} and variant = {2}.</entry>
+ </locale>
+ <locale language="de">
+ <entry key="title">Hallo Welt</entry>
+ <entry key="text">Wir sind in {0}.</entry>
+ <entry key="summary">sample summary to test german messages. Country = {0}, language = {1} and variant = {2}.</entry>
+ <entry key="details">sample deatils to test german messages. Country = {0}, language = {1} and variant = {2}.</entry>
+ </locale>
+ </message>
+</messages>
+
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org