You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by br...@apache.org on 2003/08/06 16:42:46 UTC
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/transformation I18nTransformer.java
bruno 2003/08/06 07:42:46
Modified: src/documentation/xdocs/userdocs/transformers
i18n-transformer.xml
src/java/org/apache/cocoon/transformation
I18nTransformer.java
Log:
Fixed bug 19841: untranslated-text doesn't work for i18n:text
Revision Changes Path
1.7 +7 -1 cocoon-2.1/src/documentation/xdocs/userdocs/transformers/i18n-transformer.xml
Index: i18n-transformer.xml
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/documentation/xdocs/userdocs/transformers/i18n-transformer.xml,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- i18n-transformer.xml 4 Aug 2003 09:08:33 -0000 1.6
+++ i18n-transformer.xml 6 Aug 2003 14:42:46 -0000 1.7
@@ -350,7 +350,13 @@
refer to e.g. request parameters. (<em>at least 1 catalogue
element required</em>).</li>
<li><strong>untranslated-text</strong>: text used for
- untranslated keys (default is to output the key name).</li>
+ untranslated keys (default is to output the key name).
+ For the i18n:text element, this will only be used if
+ the content of the i18n:text element was empty (thus
+ when the key was specified using the i18n:key
+ attribute). Otherwise the content of the i18n:text
+ element will be outputted when no translation is
+ found.</li>
<li><strong>cache-at-startup</strong>: flag whether to cache
messages at startup (false by default).</li>
</ul>
1.10 +18 -6 cocoon-2.1/src/java/org/apache/cocoon/transformation/I18nTransformer.java
Index: I18nTransformer.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/transformation/I18nTransformer.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- I18nTransformer.java 22 May 2003 16:01:57 -0000 1.9
+++ I18nTransformer.java 6 Aug 2003 14:42:46 -0000 1.10
@@ -840,6 +840,9 @@
// Untranslated message value
private String untranslated;
+ /* A MirrorRecorder containing the contents of {@link #untranslated}. */
+ private MirrorRecorder untranslatedRecorder;
+
// Cache at startup setting value
private boolean cacheAtStartup;
@@ -995,6 +998,11 @@
untranslated = localUntranslated;
}
+ if (untranslated != null) {
+ untranslatedRecorder = new MirrorRecorder();
+ untranslatedRecorder.characters(untranslated.toCharArray(), 0, untranslated.length());
+ }
+
// Get current locale
Locale locale = I18nUtils.parseLocale(lc);
if (getLogger().isDebugEnabled())
@@ -1595,7 +1603,13 @@
// We have the key, but couldn't find a transltation
if (getLogger().isDebugEnabled())
debug("translation not found for key " + current_key);
- tr_text_recorder = text_recorder;
+ // use the untranslated-text only when the content of the i18n:text
+ // element was empty
+ if (text_recorder.empty() && untranslatedRecorder != null) {
+ tr_text_recorder = untranslatedRecorder;
+ } else {
+ tr_text_recorder = text_recorder;
+ }
}
}
@@ -2107,11 +2121,9 @@
public void recycle() {
// restore untranslated-text if necessary
- if (globalUntranslated != null &&
- !untranslated.equals(globalUntranslated)) {
-
+ if (globalUntranslated != null)
untranslated = globalUntranslated;
- }
+ untranslatedRecorder = null;
// clean up default catalogue
factory.release(defaultCatalogue);