|
Hi I had had a similar problem so I've changed the I18nCatalogueGenerator.java My problem was that the generator was not able to serve the i18n transformer with the right messages. E.g. if the user-language was Arabic, then the generator delivered not the default messages. I made a workaround which works for me: /* * Copyright 1999-2005 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.cocoon.portal.tools.generation; import java.io.IOException; import java.net.MalformedURLException; import java.util.Iterator; import java.util.List; import java.util.Map; import org.apache.avalon.framework.parameters.Parameters; import org.apache.avalon.framework.service.ServiceException; import org.apache.avalon.framework.service.ServiceManager; import org.apache.cocoon.ProcessingException; import org.apache.cocoon.environment.SourceResolver; import org.apache.cocoon.generation.ServiceableGenerator; import org.apache.cocoon.portal.tools.PortalToolCatalogue; import org.apache.cocoon.portal.tools.PortalToolManager; import org.apache.cocoon.xml.IncludeXMLConsumer; import org.apache.excalibur.source.Source; import org.apache.excalibur.xml.sax.SAXParser; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.helpers.AttributesImpl; /** * * @version CVS $Id: I18nCatalogueGenerator.java 157071 2005-03-11 11:16:05Z cziegeler $ */ public class I18nCatalogueGenerator extends ServiceableGenerator { private SAXParser parser; private PortalToolManager ptm; private final String CATALOGUE_TAG = "catalogue"; private String lang = ".xml"; private StringBuffer i18n = new StringBuffer(); /* (non-Javadoc) * @see org.apache.cocoon.generation.Generator#generate() */ public void generate() throws IOException, SAXException, ProcessingException { this.xmlConsumer.startDocument(); this.xmlConsumer.startElement("", CATALOGUE_TAG, CATALOGUE_TAG, new AttributesImpl()); List cats = ptm.getI18n(); // parse default catalogue for(Iterator it = cats.iterator(); it.hasNext();) { PortalToolCatalogue ptc = (PortalToolCatalogue) it.next(); try { Source cat; cat = resolver.resolveURI(ptc.getLocation() + ptc.getName() + ".xml"); //System.err.println( "i18nCatalogue 1: " +cat.getURI() ); IncludeXMLConsumer ixc = new IncludeXMLConsumer(this.xmlConsumer); ixc.setIgnoreRootElement(true); this.parser.parse(new InputSource(cat.getInputStream()), ixc); } catch (MalformedURLException e) { System.err.println( "i18nCatalogue 1ea: "+e); // ignore } catch (IOException e) { System.err.println( "i18nCatalogue 1eb: "+e); // ignore } } for(Iterator it = cats.iterator(); it.hasNext();) { PortalToolCatalogue ptc = (PortalToolCatalogue) it.next(); try { Source cat; cat = resolver.resolveURI(ptc.getLocation() + ptc.getName() + lang); //System.err.println( "i18nCatalogue 2: " +cat.getURI() + " lang: " + lang + " i18n: " + i18n ); IncludeXMLConsumer ixc = new IncludeXMLConsumer(this.xmlConsumer); ixc.setIgnoreRootElement(true); this.parser.parse(new InputSource(cat.getInputStream()), ixc); } catch (MalformedURLException e) { System.err.println( "i18nCatalogue 2ea: "+e); // ignore } catch (IOException e) { System.err.println( "i18nCatalogue 2eb: "+e); // ignore } } this.xmlConsumer.endElement("", CATALOGUE_TAG, CATALOGUE_TAG); this.xmlConsumer.endDocument(); } /* (non-Javadoc) * @see org.apache.cocoon.sitemap.SitemapModelComponent#setup(org.apache.cocoon.environment.SourceResolver, java.util.Map, java.lang.String, org.apache.avalon.framework.parameters.Parameters) */ public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) throws ProcessingException, SAXException, IOException { super.setup(resolver, objectModel, src, par); //System.err.println( "i18nCatalogue src: " + src + " lang: "+lang); if(src.indexOf("_") != -1) { //use only language, but not country because in this Portal the catalogue-files are only in de, fr, it, and default if ( src.lastIndexOf("_") == src.indexOf("_") ) { this.lang = src.substring(src.indexOf("_"), src.length()); } else { this.lang = src.substring(src.indexOf("_"), src.lastIndexOf("_")); } this.lang = this.lang.toLowerCase(); if (this.lang.endsWith(":")) { this.lang=this.lang.substring(0,this.lang.length()-1); } if (!this.lang.endsWith(".xml")) { this.lang = this.lang + ".xml"; } //System.err.println( "i18nCatalogue src changed lang to: "+lang); } } /* (non-Javadoc) * @see org.apache.cocoon.generation.ServiceableGenerator#service(org.apache.avalon.framework.service.ServiceManager) */ public void service(ServiceManager manager) throws ServiceException { super.service(manager); this.parser = (SAXParser)this.manager.lookup(SAXParser.ROLE); ptm = (PortalToolManager) this.manager.lookup(PortalToolManager.ROLE); } /* (non-Javadoc) * @see org.apache.cocoon.generation.ServiceableGenerator#dispose() */ public void dispose() { super.dispose(); this.manager.release(this.parser); this.manager.release(this.ptm); } } Jens Maukisch wrote: Hi, |
