You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by jo...@apache.org on 2005/11/29 22:19:31 UTC
svn commit: r349815 - in /cocoon/trunk:
src/java/org/apache/cocoon/i18n/I18nUtils.java
src/java/org/apache/cocoon/i18n/XMLResourceBundle.java
src/java/org/apache/cocoon/transformation/I18nTransformer.java status.xml
Author: joerg
Date: Tue Nov 29 13:19:22 2005
New Revision: 349815
URL: http://svn.apache.org/viewcvs?rev=349815&view=rev
Log:
fixing bug COCOON-1700:
XMLResourceBundle now checks for both the old and the new namespace.
Modified:
cocoon/trunk/src/java/org/apache/cocoon/i18n/I18nUtils.java
cocoon/trunk/src/java/org/apache/cocoon/i18n/XMLResourceBundle.java
cocoon/trunk/src/java/org/apache/cocoon/transformation/I18nTransformer.java
cocoon/trunk/status.xml
Modified: cocoon/trunk/src/java/org/apache/cocoon/i18n/I18nUtils.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/i18n/I18nUtils.java?rev=349815&r1=349814&r2=349815&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/i18n/I18nUtils.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/i18n/I18nUtils.java Tue Nov 29 13:19:22 2005
@@ -22,6 +22,7 @@
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.Session;
import org.apache.cocoon.environment.Response;
+import org.apache.cocoon.util.Deprecation;
import java.util.Enumeration;
import java.util.Locale;
@@ -39,6 +40,21 @@
// Locale string delimiter
private static final String LOCALE_DELIMITER = "_-@.";
+ /**
+ * 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.1";
+ /**
+ * The old namespace for i18n is "http://apache.org/cocoon/i18n/2.0".
+ */
+ public static final String I18N_OLD_NAMESPACE_URI =
+ "http://apache.org/cocoon/i18n/2.0";
+ /**
+ * Did we already encountered an old namespace? This is static to ensure
+ * that the associated message will be logged only once.
+ */
+ private static boolean deprecationFound = false;
private I18nUtils() {
// Disable instantiation
@@ -242,4 +258,19 @@
response.addCookie(response.createCookie(attribute, locale));
}
}
+
+ public static boolean matchesI18nNamespace(String uri) {
+ if (I18N_NAMESPACE_URI.equals(uri)) {
+ return true;
+ } else if (I18N_OLD_NAMESPACE_URI.equals(uri)) {
+ if (!deprecationFound) {
+ deprecationFound = true;
+ Deprecation.logger.warn("The namespace <" + I18N_OLD_NAMESPACE_URI +
+ "> is deprecated, use: <" + I18N_NAMESPACE_URI + ">");
+ }
+ return true;
+ }
+ return false;
+ }
+
}
Modified: cocoon/trunk/src/java/org/apache/cocoon/i18n/XMLResourceBundle.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/i18n/XMLResourceBundle.java?rev=349815&r1=349814&r2=349815&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/i18n/XMLResourceBundle.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/i18n/XMLResourceBundle.java Tue Nov 29 13:19:22 2005
@@ -67,11 +67,6 @@
implements Bundle {
/**
- * Namespace for the Bundle markup
- */
- public static final String NS = "http://apache.org/cocoon/i18n/2.0";
-
- /**
* XML bundle root element name
*/
public static final String EL_CATALOGUE = "catalogue";
@@ -149,7 +144,7 @@
switch (this.state) {
case 0:
// <i18n:catalogue>
- if (!"".equals(ns) && !NS.equals(ns)) {
+ if (!"".equals(ns) && !I18nUtils.matchesI18nNamespace(ns)) {
throw new SAXException("Root element <" + EL_CATALOGUE +
"> must be non-namespaced or in i18n namespace.");
}
Modified: cocoon/trunk/src/java/org/apache/cocoon/transformation/I18nTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/transformation/I18nTransformer.java?rev=349815&r1=349814&r2=349815&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/transformation/I18nTransformer.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/transformation/I18nTransformer.java Tue Nov 29 13:19:22 2005
@@ -272,28 +272,6 @@
Serviceable, Configurable, Disposable {
/**
- * 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.1";
-
- /**
- * The old namespace for i18n is "http://apache.org/cocoon/i18n/2.0".
- */
- public static final String I18N_OLD_NAMESPACE_URI =
- "http://apache.org/cocoon/i18n/2.0";
-
- /**
- * Did we already encountered an old namespace? This is static to ensure
- * that the associated message will be logged only once.
- */
- private static boolean deprecationFound = false;
-
- //
- // i18n elements
- //
-
- /**
* <code>i18n:text</code> element is used to translate any text, with
* or without markup. Example:
* <pre>
@@ -1119,23 +1097,11 @@
}
// Process start element event
- if (I18N_NAMESPACE_URI.equals(uri)) {
+ if (I18nUtils.matchesI18nNamespace(uri)) {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Starting i18n element: " + name);
}
startI18NElement(name, attr);
-
- } else if (I18N_OLD_NAMESPACE_URI.equals(uri)) {
- if (!deprecationFound) {
- deprecationFound = true;
- getLogger().warn("The namespace <" + I18N_OLD_NAMESPACE_URI +
- "> is deprecated, use: <" + I18N_NAMESPACE_URI + ">");
- }
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("Starting deprecated i18n element: " + name);
- }
- startI18NElement(name, attr);
-
} else {
// We have a non i18n element event
if (current_state == STATE_OUTSIDE) {
@@ -1163,7 +1129,7 @@
strBuffer = null;
}
- if (I18N_NAMESPACE_URI.equals(uri) || I18N_OLD_NAMESPACE_URI.equals(uri)) {
+ if (I18nUtils.matchesI18nNamespace(uri)) {
endI18NElement(name);
} else if (current_state == STATE_INSIDE_PARAM) {
param_recorder.endElement(uri, name, raw);
@@ -1225,17 +1191,17 @@
currentKey = attr.getValue("", I18N_KEY_ATTRIBUTE);
if (currentKey == null) {
// Try the namespaced attribute
- currentKey = attr.getValue(I18N_NAMESPACE_URI, I18N_KEY_ATTRIBUTE);
+ currentKey = attr.getValue(I18nUtils.I18N_NAMESPACE_URI, I18N_KEY_ATTRIBUTE);
if (currentKey == null) {
// Try the old namespace
- currentKey = attr.getValue(I18N_OLD_NAMESPACE_URI, I18N_KEY_ATTRIBUTE);
+ currentKey = attr.getValue(I18nUtils.I18N_OLD_NAMESPACE_URI, I18N_KEY_ATTRIBUTE);
}
}
currentCatalogueId = attr.getValue("", I18N_CATALOGUE_ATTRIBUTE);
if (currentCatalogueId == null) {
// Try the namespaced attribute
- currentCatalogueId = attr.getValue(I18N_NAMESPACE_URI, I18N_CATALOGUE_ATTRIBUTE);
+ currentCatalogueId = attr.getValue(I18nUtils.I18N_NAMESPACE_URI, I18N_CATALOGUE_ATTRIBUTE);
}
if (prev_state != STATE_INSIDE_PARAM) {
@@ -1549,10 +1515,10 @@
// Translate all attributes from i18n:attr="name1 name2 ..."
// using their values as keys.
- int attrIndex = attr.getIndex(I18N_NAMESPACE_URI, I18N_ATTR_ATTRIBUTE);
+ int attrIndex = attr.getIndex(I18nUtils.I18N_NAMESPACE_URI, I18N_ATTR_ATTRIBUTE);
if (attrIndex == -1) {
// Try the old namespace
- attrIndex = attr.getIndex(I18N_OLD_NAMESPACE_URI, I18N_ATTR_ATTRIBUTE);
+ attrIndex = attr.getIndex(I18nUtils.I18N_OLD_NAMESPACE_URI, I18N_ATTR_ATTRIBUTE);
}
if (attrIndex != -1) {
@@ -1586,7 +1552,7 @@
// Translate all attributes from i18n:expr="name1 name2 ..."
// using their values as keys.
- attrIndex = attr.getIndex(I18N_NAMESPACE_URI, I18N_EXPR_ATTRIBUTE);
+ attrIndex = attr.getIndex(I18nUtils.I18N_NAMESPACE_URI, I18N_EXPR_ATTRIBUTE);
if (attrIndex != -1) {
StringTokenizer st = new StringTokenizer(attr.getValue(attrIndex));
@@ -2279,4 +2245,5 @@
resolvedLocations = null;
}
}
+
}
Modified: cocoon/trunk/status.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/status.xml?rev=349815&r1=349814&r2=349815&view=diff
==============================================================================
--- cocoon/trunk/status.xml (original)
+++ cocoon/trunk/status.xml Tue Nov 29 13:19:22 2005
@@ -175,6 +175,9 @@
<!-- These are the changes from the last 2.1.x version. -->
<changes>
<release version="@version@" date="@date@">
+ <action dev="JH" type="fix" fixes-bug="COCOON-1700">
+ I18n: XMLResourceBundle checks now for both the new and the old namespace.
+ </action>
<action dev="AN" type="add">
XSP block: Instrument {#expr} interpolation to produce Cocoon stacktrace for parse errors.
</action>