On Saturday 28 January 2006 02:11, Patrick Casey wrote:
>       You sometimes do have to change layout on a page by page layout when
> you do i18n stuff, especially if some of the languages you're translating
> into are significantly more verbose than English (<cough> german <cough>).
> So a nice little set of widgets that do, say:
>
>       Label1  text1
>       Label2  text2
>
>       Might not fit if the german translation of label is
>
>       InevitableReallyLongGermanAlliterativeLabel     text1
>       FiendishlyShortForGerman        test2

Surely if thats the problem that what you really need is to control layout via 
css and have a different style sheet for each language.

What I have done is create a border component (which incidentally is hidden 
inside a library jar file which is then available for all applications at my 
site) which takes two separate style sheet parameters.  One, the page style 
comes from an injected asset, but the site style is read from a standard key 
("cssURL") from the application.properties file.

By using the locale different version of this you can change the CSS dependent 
on the language.

The border component need to break into the shell so it can write into the 
header.  

I do this with a delegate

<html jwcid="@Shell" stylesheet="ognl:pageStyle" title="ognl:siteTitle" 
delegate="ognl:siteCSS">


and then in the java

        /* Renders the following (for the shell to add it to the header)
         *      <link rel="stylesheet" type="text/css" href="/style/site.css"/>
         */
        private class siteCSS implements IRender {
                public void render(IMarkupWriter writer, IRequestCycle cycle) {
                        writer.beginEmpty("link");
                        writer.attribute("rel","stylesheet");
                        writer.attribute("type","text/css");
                        writer.attribute("href",appMessage("cssURL"));
                        writer.println();
                }
        }
        
        public IRender getSiteCSS(){
                return new siteCSS();
        }
        
        /*
         * Gets messages from the applications property file
         * via key
         */
        private String appMessage(String key) {
                return getPage().getMessages().getMessage(key);
        }



-- 
Alan Chandler
http://www.chandlerfamily.org.uk
Open Source. It's the difference between trust and antitrust.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to