From: Matthew B. <mat...@co...> - 2005-07-13 14:29:54
Attachments:
xmltemplate_localise.txt
|
At the moment I don't seem to be able to complie template that have localised facility calls. Attached is a patch that seems to fix this. What do people think of it? -- +--Matthew Buckett-----------------------------------------+ | VLE Developer, Learning Technologies Group | | Tel: +44 (0) 1865 283660 http://www.oucs.ox.ac.uk/ | +------------Computing Services, University of Oxford------+ |
From: Alistair Y. <ali...@sm...> - 2005-07-13 14:38:57
|
can you describe what you've done Mathew? There may not be a problem at all. I may have localised some #defines - it's difficult to tell them apart from Facility calls that should be localised, such as "Enter web site" Before you start hacking the code, can you make sure it's not a #define that's been localised? Alistair On 13 Jul 2005, at 15:29, Matthew Buckett wrote: > At the moment I don't seem to be able to complie template that have > localised facility calls. Attached is a patch that seems to fix this. > What do people think of it? > > -- > +--Matthew Buckett-----------------------------------------+ > | VLE Developer, Learning Technologies Group | > | Tel: +44 (0) 1865 283660 http://www.oucs.ox.ac.uk/ | > +------------Computing Services, University of Oxford------+ > Index: src/org/bodington/servlet/template/XmlTemplate.java > =================================================================== > RCS file: /cvsroot/bodington/bodington/src/org/bodington/servlet/ > template/XmlTemplate.java,v > retrieving revision 1.39 > diff -u -r1.39 XmlTemplate.java > --- src/org/bodington/servlet/template/XmlTemplate.java 6 Jul > 2005 17:11:03 -0000 1.39 > +++ src/org/bodington/servlet/template/XmlTemplate.java 13 Jul > 2005 14:22:47 -0000 > @@ -102,7 +102,8 @@ > "literal", > "variable", > "assign", > - "call" > + "call", > + "localise" > }; > > private static final String[] htmlfragment_tag_names= > @@ -963,6 +964,12 @@ > private void compileLocaliserCall(Element e) { > writer.println("writer.println(res.getString(\"" + > e.getAttribute("id") + "\"));" ); > } > + > + private Class compileLocaliser( Element e) > + { > + writer.print( "res.getString(\"" + e.getAttribute("id") + > "\")"); > + return String.class; > + } > > private void compileInputCall(Element e) { > NamedNodeMap attrs = e.getAttributes(); > @@ -1108,6 +1115,8 @@ > return compileAssign( element ); > else if ( "call".equals( element.getTagName() ) ) > return compileCall( element ); > + else if ( "localise".equals( element.getTagName() ) ) > + return compileLocaliser(element); > > throw new ServletException( "Template bytecode compilation > error: unknown expression." ); > } > Index: tomcatadd/webapps/bodington/templates/style_default/default/ > applettop.html > =================================================================== > RCS file: /cvsroot/bodington/bodington/tomcatadd/webapps/bodington/ > templates/style_default/default/applettop.html,v > retrieving revision 1.9 > diff -u -r1.9 applettop.html > --- tomcatadd/webapps/bodington/templates/style_default/default/ > applettop.html 12 Jul 2005 20:30:30 -0000 1.9 > +++ tomcatadd/webapps/bodington/templates/style_default/default/ > applettop.html 13 Jul 2005 14:22:47 -0000 > @@ -42,7 +42,7 @@ > <parameters> > <variable name="request"/> > <variable name="writer"/> > - <literal type="String"><localise id="page.title.text" /></ > literal> > + <localise id="page.title.text"/> > </parameters> > > </call></h3></td> > Index: tomcatadd/webapps/bodington/templates/style_default/default/ > error403.html > =================================================================== > RCS file: /cvsroot/bodington/bodington/tomcatadd/webapps/bodington/ > templates/style_default/default/error403.html,v > retrieving revision 1.4 > diff -u -r1.4 error403.html > --- tomcatadd/webapps/bodington/templates/style_default/default/ > error403.html 12 Jul 2005 20:31:01 -0000 1.4 > +++ tomcatadd/webapps/bodington/templates/style_default/default/ > error403.html 13 Jul 2005 14:22:47 -0000 > @@ -26,7 +26,7 @@ > <parameters> > <variable name="request"/> > <variable name="response"/> > - <literal type="String"><localise id="navigation.text" /></ > literal> > + <localise id="navigation.text" /> > </parameters> > > </call></p><p>&nbsp;</p><p>&nbsp;</p> > Index: tomcatadd/webapps/bodington/templates/style_default/default/ > login_anon.html > =================================================================== > RCS file: /cvsroot/bodington/bodington/tomcatadd/webapps/bodington/ > templates/style_default/default/login_anon.html,v > retrieving revision 1.3 > diff -u -r1.3 login_anon.html > --- tomcatadd/webapps/bodington/templates/style_default/default/ > login_anon.html 12 Jul 2005 20:32:20 -0000 1.3 > +++ tomcatadd/webapps/bodington/templates/style_default/default/ > login_anon.html 13 Jul 2005 14:22:47 -0000 > @@ -118,7 +118,7 @@ > <parameters> > <variable name="request"/> > <variable name="writer"/> > - <literal type="String"><localise > id="enter.website" /></literal> > + <localise id="enter.website" /> > </parameters> > </call> > </p> > Index: tomcatadd/webapps/bodington/templates/style_default/default/ > login_step4.html > =================================================================== > RCS file: /cvsroot/bodington/bodington/tomcatadd/webapps/bodington/ > templates/style_default/default/login_step4.html,v > retrieving revision 1.9 > diff -u -r1.9 login_step4.html > --- tomcatadd/webapps/bodington/templates/style_default/default/ > login_step4.html 12 Jul 2005 20:19:06 -0000 1.9 > +++ tomcatadd/webapps/bodington/templates/style_default/default/ > login_step4.html 13 Jul 2005 14:22:47 -0000 > @@ -74,7 +74,7 @@ > <parameters> > <variable name="request"/> > <variable name="writer"/> > - <literal type="String"><localise > id="enter" /></literal> > + <localise id="enter" /> > </parameters> > </call> > <br /><br /> > |
From: Matthew B. <mat...@co...> - 2005-07-13 15:04:46
|
Alistair Young wrote: > can you describe what you've done Mathew? There may not be a problem at > all. I may have localised some #defines - it's difficult to tell them > apart from Facility calls that should be localised, such as "Enter web > site" Localised some #defines? > Before you start hacking the code, can you make sure it's not a #define > that's been localised? I havn't commited it back to CVS because you know more about this but I couldn't get the templates to compile. This patch to XmlTemplate adds <localise> as a valid part of an expression (expressions are used in a <call>). >> Index: src/org/bodington/servlet/template/XmlTemplate.java >> =================================================================== >> RCS file: /cvsroot/bodington/bodington/src/org/bodington/servlet/ >> template/XmlTemplate.java,v >> retrieving revision 1.39 >> diff -u -r1.39 XmlTemplate.java >> --- src/org/bodington/servlet/template/XmlTemplate.java 6 Jul 2005 >> 17:11:03 -0000 1.39 >> +++ src/org/bodington/servlet/template/XmlTemplate.java 13 Jul >> 2005 14:22:47 -0000 >> @@ -102,7 +102,8 @@ >> "literal", >> "variable", >> "assign", >> - "call" >> + "call", >> + "localise" >> }; >> >> private static final String[] htmlfragment_tag_names= >> @@ -963,6 +964,12 @@ >> private void compileLocaliserCall(Element e) { >> writer.println("writer.println(res.getString(\"" + >> e.getAttribute("id") + "\"));" ); >> } >> + >> + private Class compileLocaliser( Element e) >> + { >> + writer.print( "res.getString(\"" + e.getAttribute("id") + >> "\")"); >> + return String.class; >> + } >> >> private void compileInputCall(Element e) { >> NamedNodeMap attrs = e.getAttributes(); >> @@ -1108,6 +1115,8 @@ >> return compileAssign( element ); >> else if ( "call".equals( element.getTagName() ) ) >> return compileCall( element ); >> + else if ( "localise".equals( element.getTagName() ) ) >> + return compileLocaliser(element); >> >> throw new ServletException( "Template bytecode compilation >> error: unknown expression." ); >> } This shows how the templates will have to change with my patch. >> Index: tomcatadd/webapps/bodington/templates/style_default/default/ >> applettop.html >> <parameters> >> <variable name="request"/> >> <variable name="writer"/> >> - <literal type="String"><localise id="page.title.text" /></ literal> >> + <localise id="page.title.text"/> >> </parameters> -- +--Matthew Buckett-----------------------------------------+ | VLE Developer, Learning Technologies Group | | Tel: +44 (0) 1865 283660 http://www.oucs.ox.ac.uk/ | +------------Computing Services, University of Oxford------+ |