cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Quinn <jer...@media.demon.co.uk>
Subject Re: i18n and CForms
Date Thu, 25 Nov 2004 19:38:42 GMT

Thanks for your response Sylvain.

On 25 Nov 2004, at 18:36, Sylvain Wallez wrote:

> Jeremy Quinn wrote:
>
>> Hi All
>>
>> I am finding that the default FormsMessages that come with CForms do  
>> not appear to be working in 2.1.7-dev.
>>
>> My default browser locale (I tried both Safari and Firefox) is  
>> 'en_US', so should be using  
>> context://samples/blocks/forms/messages/FormsMessages.xml.
>>
>> This is not happening, either in my own usage or in the samples for  
>> CForms.
>>
>> So for instance, instead of getting the message "This field is  
>> required." I get "general.field-required" indicating that the lookup  
>> failed.
>>
>> Interestingly, even after I copied "FormsMessages.xml" to  
>> "FormsMessages_en_US.xml" and restarted Cocoon, it still did not  
>> work.
>>
>> I also tried setting Firefox to say my locale was 'fr', it still did  
>> not work.
>>
>> The i18n Samples work fine.
>>
>> Any ideas anyone?
>
>
> Are you using the i18n transformer in a subsitemap of the sitemap  
> where it is declared?

I was originally.

> There's currently a problem with components that have relative URLs in  
> their configuration (the message catalogue location is such an URL)  
> and that are used in subsitemap.

I remembered something about that.

> The problem comes from the fact that the relative context is that of  
> the sitemap where a component is firstly used, which in the case of  
> subsitemaps is different from the context where the component was  
> declared.

My top-level sitemap and all of my subsitemaps are in the same folder.

> That can be solved by implementing the "multi-relative source  
> resolving" I've been talking about recently, but for now you have to  
> make sure that the i18n transformer is only used in the sitemap where  
> it is declared.

I am not 100% sure what "multi-relative source resolving" means, I will  
read back through the lists.

Meanwhile .....

In order to simplify the issue, I have move all i18nTransformer and  
catalogue declarations to my project's top-level sitemap (there are no  
higher i18nTransformer declarations).

It looks like this:

<map:transformer name="i18n"  
src="org.apache.cocoon.transformation.I18nTransformer">
   <catalogues default="forms">
     <catalogue id="main" name="main" location="content/i18n"/>
     <catalogue id="editor" name="editor" location="content/i18n"/>
     <catalogue id="config" name="configuration"  
location="content/i18n"/>
     <catalogue id="event" name="event" location="content/i18n"/>
     <catalogue id="sched" name="scheduler" location="content/i18n"/>
     <catalogue id="samp" name="samples" location="content/i18n"/>
     <catalogue id="webdav" name="webdav" location="content/i18n"/>
     <catalogue id="forms" name="FormsMessages"  
location="context://samples/blocks/forms/messages"/>
   </catalogues>
   <cache-at-startup>false</cache-at-startup>
</map:transformer>

This project is mounted externally to Cocoon, hence the "context://"  
URI for FormsMessages.

Each of my pages that use the custom i18n work fine, they all refer to  
their catalogue like this:
<i18n:text  
i18n:catalogue="editor">new-component.filename.label</i18n:text>

or from FlowScript like this:
form.lookupWidget("messages").addMessage(new I18nMessage(error,  
"editor"));


Here is an example of the errors I am seeing.

Scenario:
	default locale of the site is 'it'.
	my browser's default locale is 'en_US'
	my custom i18n message files are supplied both as '[filename]_en.xml'  
and '[filename]_it.xml'

1. I load a page that has a form in it, that uses messages from  
'editor_*.xml':

INFO    (2004-11-25) 18:52.12:049   [core.i18n-bundles]  
(/gov-cms/editor/new-component.html)  
PoolThread-4/XMLResourceBundleFactory: Resource not found: editor,  
locale: , bundleName:  
file:/Users/jerm/Development/Checkouts/Pronetics/scratchpad/gov-cms/ 
application/webapp/content/i18n/editor.xml. Exception:  
org.apache.cocoon.ResourceNotFoundException: Resource not found.:  
org.apache.excalibur.source.SourceNotFoundException:  
file:/Users/jerm/Development/Checkouts/Pronetics/scratchpad/gov-cms/ 
application/webapp/content/i18n/editor.xml doesn't exist.

Fine so far ..... editor_en.xml was found, and works fine.

2. I submit the form in such a way that will invoke validation errors,  
the first error message about the missing '}' is highly suspicious to  
me. I have no such characters in my messages (not using that  
functionality, and the curly-brace pairs in FormsMessages.xml all seem  
to be well formed). The errors below are what happens when the CForms  
i18n does not work.

ERROR   (2004-11-25) 18:54.24:624   [core.i18n-bundles]  
(/gov-cms/editor/new-component.html)  
PoolThread-4/XMLResourceBundleFactory: Resource loading failed
org.xml.sax.SAXException: Unclosed '}'
	at  
org.apache.cocoon.xml.ParamSaxBuffer.characters(ParamSaxBuffer.java:76)
	at  
org.apache.cocoon.i18n.XMLResourceBundle$SAXContentHandler.characters(XM 
LResourceBundle.java:232)
	at org.apache.xerces.parsers.AbstractSAXParser.characters(Unknown  
Source)
	at  
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanContent(Unknow 
n Source)
	at  
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDis 
patcher.dispatch(Unknown Source)
	at  
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unkno 
wn Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
	at org.apache.excalibur.xml.impl.JaxpParser.parse(JaxpParser.java:296)
	at  
org.apache.excalibur.xmlizer.DefaultXMLizer.toSAX(DefaultXMLizer.java: 
123)
	at  
org.apache.cocoon.components.source.SourceUtil.toSAX(SourceUtil.java: 
166)
	at  
org.apache.cocoon.components.source.SourceUtil.toSAX(SourceUtil.java: 
98)
	at  
org.apache.cocoon.i18n.XMLResourceBundle.load(XMLResourceBundle.java: 
299)
	at  
org.apache.cocoon.i18n.XMLResourceBundle.init(XMLResourceBundle.java: 
276)
	at  
org.apache.cocoon.i18n.XMLResourceBundleFactory._loadBundle(XMLResourceB 
undleFactory.java:308)
	at  
org.apache.cocoon.i18n.XMLResourceBundleFactory._select(XMLResourceBundl 
eFactory.java:273)
	at  
org.apache.cocoon.i18n.XMLResourceBundleFactory._select(XMLResourceBundl 
eFactory.java:262)
	at  
org.apache.cocoon.i18n.XMLResourceBundleFactory.select(XMLResourceBundle 
Factory.java:231)
	at  
org.apache.cocoon.transformation.I18nTransformer$CatalogueInfo.getCatalo 
gue(I18nTransformer.java:2272)
	at  
org.apache.cocoon.transformation.I18nTransformer.getMessage(I18nTransfor 
mer.java:2158)
	at  
org.apache.cocoon.transformation.I18nTransformer.getMessage(I18nTransfor 
mer.java:2181)
	at  
org.apache.cocoon.transformation.I18nTransformer.endTextElement(I18nTran 
sformer.java:1691)
	at  
org.apache.cocoon.transformation.I18nTransformer.endI18NElement(I18nTran 
sformer.java:1463)
	at  
org.apache.cocoon.transformation.I18nTransformer.endElement(I18nTransfor 
mer.java:1177)
	at  
org.apache.cocoon.xml.AbstractXMLPipe.endElement(AbstractXMLPipe.java: 
111)
	at  
org.apache.cocoon.forms.transformation.EffectWidgetReplacingPipe$Styling 
ContentHandler.endElement(EffectWidgetReplacingPipe.java:764)
	at org.apache.cocoon.forms.util.I18nMessage.toSAX(I18nMessage.java:117)
	at  
org.apache.cocoon.forms.validation.ValidationError.generateSaxFragment(V 
alidationError.java:84)
	at  
org.apache.cocoon.forms.formmodel.Field.generateItemSaxFragment(Field.ja 
va:390)
	at  
org.apache.cocoon.forms.formmodel.AbstractWidget.generateSaxFragment(Abs 
tractWidget.java:425)
	at  
org.apache.cocoon.forms.transformation.EffectWidgetReplacingPipe$WidgetH 
andler.process(EffectWidgetReplacingPipe.java:423)
	at  
org.apache.cocoon.forms.transformation.EffectPipe.endElement(EffectPipe. 
java:417)
	at  
org.apache.cocoon.generation.JXTemplateGenerator.execute(JXTemplateGener 
ator.java:2627)
	at  
org.apache.cocoon.generation.JXTemplateGenerator.performGeneration(JXTem 
plateGenerator.java:2488)
	at  
org.apache.cocoon.generation.JXTemplateGenerator.generate(JXTemplateGene 
rator.java:2482)
	at  
org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.process 
XMLPipeline(AbstractProcessingPipeline.java:530)
	at  
org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.process 
(AbstractProcessingPipeline.java:468)
	at  
org.apache.cocoon.components.treeprocessor.sitemap.SerializeNode.invoke( 
SerializeNode.java:120)
	at  
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode. 
invokeNodes(AbstractParentProcessingNode.java:46)
	at  
org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.i 
nvoke(PreparableMatchNode.java:130)
	at  
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode. 
invokeNodes(AbstractParentProcessingNode.java:68)
	at  
org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(P 
ipelineNode.java:138)
	at  
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode. 
invokeNodes(AbstractParentProcessingNode.java:68)
	at  
org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke( 
PipelinesNode.java:89)
	at  
org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process 
(ConcreteTreeProcessor.java:241)
	at  
org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.handleC 
ocoonRedirect(ConcreteTreeProcessor.java:305)
	at  
org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.access$ 
000(ConcreteTreeProcessor.java:49)
	at  
org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor$TreePro 
cessorRedirector.cocoonRedirect(ConcreteTreeProcessor.java:342)
	at  
org.apache.cocoon.environment.ForwardRedirector.redirect(ForwardRedirect 
or.java:59)
	at  
org.apache.cocoon.components.flow.AbstractInterpreter.forwardTo(Abstract 
Interpreter.java:209)
	at  
org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptInterpret 
er.forwardTo(FOM_JavaScriptInterpreter.java:863)
	at  
org.apache.cocoon.components.flow.javascript.fom.FOM_Cocoon.forwardTo(FO 
M_Cocoon.java:1483)
	at  
org.apache.cocoon.components.flow.javascript.fom.FOM_Cocoon.jsFunction_s 
endPage(FOM_Cocoon.java:265)
	at inv6.invoke()
	at  
org.mozilla.javascript.FunctionObject.doInvoke(FunctionObject.java:523)
	at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:438)
	at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1244)
	at  
org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(C 
ontinuationInterpreter.java:1134)
	at  
org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(C 
ontinuationInterpreter.java:190)
	at  
org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(C 
ontinuationInterpreter.java:138)
	at  
org.mozilla.javascript.continuations.InterpretedFunctionImpl.call(Interp 
retedFunctionImpl.java:121)
	at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1244)
	at  
org.mozilla.javascript.ScriptableObject.callMethod(ScriptableObject.java 
:1591)
	at  
org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptInterpret 
er.handleContinuation(FOM_JavaScriptInterpreter.java:812)
	at  
org.apache.cocoon.components.treeprocessor.sitemap.CallFunctionNode.invo 
ke(CallFunctionNode.java:123)
	at  
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode. 
invokeNodes(AbstractParentProcessingNode.java:46)
	at  
org.apache.cocoon.components.treeprocessor.sitemap.MatchNode.invoke(Matc 
hNode.java:107)
	at  
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode. 
invokeNodes(AbstractParentProcessingNode.java:68)
	at  
org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(P 
ipelineNode.java:138)
	at  
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode. 
invokeNodes(AbstractParentProcessingNode.java:68)
	at  
org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke( 
PipelinesNode.java:89)
	at  
org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process 
(ConcreteTreeProcessor.java:241)
	at  
org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process 
(ConcreteTreeProcessor.java:181)
	at  
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreePro 
cessor.java:243)
	at  
org.apache.cocoon.components.treeprocessor.sitemap.MountNode.invoke(Moun 
tNode.java:117)
	at  
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode. 
invokeNodes(AbstractParentProcessingNode.java:46)
	at  
org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.i 
nvoke(PreparableMatchNode.java:130)
	at  
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode. 
invokeNodes(AbstractParentProcessingNode.java:68)
	at  
org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(P 
ipelineNode.java:138)
	at  
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode. 
invokeNodes(AbstractParentProcessingNode.java:68)
	at  
org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke( 
PipelinesNode.java:89)
	at  
org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process 
(ConcreteTreeProcessor.java:241)
	at  
org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process 
(ConcreteTreeProcessor.java:181)
	at  
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreePro 
cessor.java:243)
	at  
org.apache.cocoon.components.treeprocessor.sitemap.MountNode.invoke(Moun 
tNode.java:117)
	at  
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode. 
invokeNodes(AbstractParentProcessingNode.java:46)
	at  
org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.i 
nvoke(PreparableMatchNode.java:130)
	at  
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode. 
invokeNodes(AbstractParentProcessingNode.java:68)
	at  
org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(P 
ipelineNode.java:138)
	at  
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode. 
invokeNodes(AbstractParentProcessingNode.java:68)
	at  
org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke( 
PipelinesNode.java:89)
	at  
org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process 
(ConcreteTreeProcessor.java:241)
	at  
org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process 
(ConcreteTreeProcessor.java:181)
	at  
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreePro 
cessor.java:243)
	at org.apache.cocoon.Cocoon.process(Cocoon.java:606)
	at  
org.apache.cocoon.servlet.CocoonServlet.service(CocoonServlet.java: 
1119)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at  
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:354)
	at  
org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationH 
andler.java:294)
	at  
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java: 
567)
	at org.mortbay.http.HttpContext.handle(HttpContext.java:1808)
	at  
org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationCon 
text.java:525)
	at org.mortbay.http.HttpContext.handle(HttpContext.java:1758)
	at org.mortbay.http.HttpServer.service(HttpServer.java:879)
	at org.mortbay.http.HttpConnection.service(HttpConnection.java:790)
	at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:952)
	at org.mortbay.http.HttpConnection.handle(HttpConnection.java:807)
	at  
org.mortbay.http.SocketListener.handleConnection(SocketListener.java: 
197)
	at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:289)
	at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:501)
INFO    (2004-11-25) 18:54.24:633   [core.i18n-bundles]  
(/gov-cms/editor/new-component.html)  
PoolThread-4/XMLResourceBundleFactory: Resource not found:  
FormsMessages, locale: en, bundleName:  
file:/Users/jerm/Development/Checkouts/Apache/Cocoon/BRANCH_2_1_X/ 
build/webapp/samples/blocks/forms/messages/FormsMessages_en.xml.  
Exception: org.apache.cocoon.ResourceNotFoundException: Resource not  
found.: org.apache.excalibur.source.SourceNotFoundException:  
file:/Users/jerm/Development/Checkouts/Apache/Cocoon/BRANCH_2_1_X/ 
build/webapp/samples/blocks/forms/messages/FormsMessages_en.xml doesn't  
exist.

The path to the CForms messages folder is fine.

I can foresee a problem whereby the site default locale is "it" but the  
Italian CForms messages are supplied as "it_IT" (not sure why this was  
done), but I have not got to this yet, while it still does not work in  
English.

I am not sure what else to try ....

Thanks for any suggestions.

regards Jeremy

--------------------------------------------------------

                   If email from this address is not signed
                                 IT IS NOT FROM ME

                         Always check the label, folks !!!!!
--------------------------------------------------------


Mime
View raw message