You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Kyle Robinson <KR...@pangaeainc.com> on 2001/03/19 18:36:09 UTC

Locales and images

I understand Struts has support for makeing web apps available in different
languages.  Does this include images?  If I have images with text on them in
English can I make images with text in French as well?  Do I name the image
files differently or do I have to include the paths to the images in the
property files?  Has anyone done this?  What's the best approach?

Kyle Robinson
Systems Consultant
Pangaea Systems Inc.
(250) 360-0111


RE: Locales and images

Posted by Ben Souther <bs...@redtrain.com>.
Put the path to the images in the properties files

-----Original Message-----
From: Kyle Robinson [mailto:KRobinson@pangaeainc.com]
Sent: Monday, March 19, 2001 12:36 PM
To: Struts (E-mail)
Subject: Locales and images


I understand Struts has support for makeing web apps available in different
languages.  Does this include images?  If I have images with text on them in
English can I make images with text in French as well?  Do I name the image
files differently or do I have to include the paths to the images in the
property files?  Has anyone done this?  What's the best approach?

Kyle Robinson
Systems Consultant
Pangaea Systems Inc.
(250) 360-0111



Re: 500 lines of jsp is 10k lines of java

Posted by pdw <pd...@dowman.net>.
There is a limit to the size of a compiled method in java, I think it's 64k,
it's probably not specifically related to the try/catch block.  Split it up
into multiple jsp's and use includes to make it into one page.   It seems to
me that a good jsp compiler should generate multiple methods, but I don't
know if any actually do that.

----- Original Message -----
From: "Kurt Olsen" <ko...@get2hawaii.com>
To: <st...@jakarta.apache.org>
Sent: Monday, March 19, 2001 11:03 AM
Subject: 500 lines of jsp is 10k lines of java


> Hi everybody,
>
> I'm fighting a problem whereby the java code generated by a 500 line jsp
> file is so large (10,200) lines that a try/catch block contains so much
code
> that the file won't compile, giving a msg saying something like 'jump
target
> out of range'...
>
> Surely I'm not the first to deal with this (and it's a real show-stopper).
> Anybody know a way to deal with this (other that hand editing the
> source-code)?
>
> This isn't a struts problem per-se but it's being interpreted that way by
> the powers that be where I work. Not good!
>
> Later,
> Kurt
>
>
> -----Original Message-----
> From: Kyle Robinson [mailto:KRobinson@pangaeainc.com]
> Sent: Monday, March 19, 2001 7:36 AM
> To: Struts (E-mail)
> Subject: Locales and images
>
>
> I understand Struts has support for makeing web apps available in
different
> languages.  Does this include images?  If I have images with text on them
in
> English can I make images with text in French as well?  Do I name the
image
> files differently or do I have to include the paths to the images in the
> property files?  Has anyone done this?  What's the best approach?
>
> Kyle Robinson
> Systems Consultant
> Pangaea Systems Inc.
> (250) 360-0111
>
>


500 lines of jsp is 10k lines of java

Posted by Kurt Olsen <ko...@get2hawaii.com>.
Hi everybody,

I'm fighting a problem whereby the java code generated by a 500 line jsp
file is so large (10,200) lines that a try/catch block contains so much code
that the file won't compile, giving a msg saying something like 'jump target
out of range'...

Surely I'm not the first to deal with this (and it's a real show-stopper).
Anybody know a way to deal with this (other that hand editing the
source-code)?

This isn't a struts problem per-se but it's being interpreted that way by
the powers that be where I work. Not good!

Later,
Kurt


-----Original Message-----
From: Kyle Robinson [mailto:KRobinson@pangaeainc.com]
Sent: Monday, March 19, 2001 7:36 AM
To: Struts (E-mail)
Subject: Locales and images


I understand Struts has support for makeing web apps available in different
languages.  Does this include images?  If I have images with text on them in
English can I make images with text in French as well?  Do I name the image
files differently or do I have to include the paths to the images in the
property files?  Has anyone done this?  What's the best approach?

Kyle Robinson
Systems Consultant
Pangaea Systems Inc.
(250) 360-0111


Re: Locales and images

Posted by Maya Muchnik <mm...@pumatech.com>.
I am trying to use this for different "look". But my principle is simple. In one
application a.gif - is a blank,
in other - it is some picture. And so on... Change your property file to point to a
different directory for different "look". But in this approach you have one match
between application and the property file. If you want to change a "look" on-fly,
you need to have different images, for example, a_look1.gif, a_look2.gif and make a
different link depending on a "look" parameter.

Maya

Nick Afshartous wrote:

>  > On Tue, 20 Mar 2001, Maya Muchnik wrote:
>  > >
>  > > Can I put a.gif into the property file too, and have the second statement as
>  > > this:
>  > > <html:image src="a.image"/>
>  > > Or I can have
>  > > <html:image srcKey="a.image.dir"/>
>  > >
>
> Craig R. McClanahan writes:
>  > The assumption behind this new facility is that you need to
>  > internationalize your images as well as your messages.  Perhaps, for
>  > example, you've created image buttons and the text of those buttons needs
>  > to be different depending on the user's locale.
>
> Could this new facility be based not
> only on locales ?  For example, in my company we're discussing
> how to manage different "looks" of our application by having
> different sets of images for each "look".  A facility like the
> one being dicussed could make it easy to manage this.
> --
>
>         Nick


Re: Locales and images

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Wed, 21 Mar 2001, Nick Afshartous wrote:

> 
>  > On Tue, 20 Mar 2001, Maya Muchnik wrote:
>  > > 
>  > > Can I put a.gif into the property file too, and have the second statement as
>  > > this:
>  > > <html:image src="a.image"/>
>  > > Or I can have
>  > > <html:image srcKey="a.image.dir"/>
>  > > 
> 
> Craig R. McClanahan writes:
>  > The assumption behind this new facility is that you need to
>  > internationalize your images as well as your messages.  Perhaps, for
>  > example, you've created image buttons and the text of those buttons needs
>  > to be different depending on the user's locale.
> 
> Could this new facility be based not
> only on locales ?  For example, in my company we're discussing
> how to manage different "looks" of our application by having
> different sets of images for each "look".  A facility like the
> one being dicussed could make it easy to manage this.  

Well, you could probably use it for that purpose.  However, you might also
want to investigate the "struts-template" tag library for managing
different looks for your web site.

> -- 
> 
> 	Nick
> 

Craig


Re: Locales and images

Posted by Nick Afshartous <ni...@proactcorp.com>.
 > On Tue, 20 Mar 2001, Maya Muchnik wrote:
 > > 
 > > Can I put a.gif into the property file too, and have the second statement as
 > > this:
 > > <html:image src="a.image"/>
 > > Or I can have
 > > <html:image srcKey="a.image.dir"/>
 > > 

Craig R. McClanahan writes:
 > The assumption behind this new facility is that you need to
 > internationalize your images as well as your messages.  Perhaps, for
 > example, you've created image buttons and the text of those buttons needs
 > to be different depending on the user's locale.

Could this new facility be based not
only on locales ?  For example, in my company we're discussing
how to manage different "looks" of our application by having
different sets of images for each "look".  A facility like the
one being dicussed could make it easy to manage this.  
-- 

	Nick




Re: Locales and images

Posted by Maya Muchnik <mm...@pumatech.com>.
I am not sure about several resource files. I have try to create other servlet and "match" it to
other file, initialize this file. But then what? It will stay in the memory and do nothing? Then
how about reload function? You need rewrite it too (run super.reload(), destroy your local info,
init your local info). It is not difficult if one file. For second one and new servlet????

Thanks,
Maya

Ken Beyer wrote:

> I'm also seeing that it's way too much now (a message resource per jsp).
>
> I found the following to be helpful...
> http://jakarta.apache.org/struts/api/org/apache/struts/util/package-summary.html#doc.Messages
>
> I'm thinking of at least starting off with separating the images from text,
> and maybe breaking the text down into packages later on.  Is it correct that
> I should override ActionServlet, and pass in additional init-param's similar
> to the "application" one?, i.e.
>
>     <init-param>
>         <param-name>imageresource</param-name>
>         <param-value>com.mycompany.mypkg.ImageResources</param-value>
>     </init-param>
>
> and then make sure that I load it (by overriding init()) and calling a
> private void initImageResources() + super init(), and similarly for the destroy.
>
> Also, I need to set locale to true in the web.xml (Action servlet section), and
> make sure I use "getMessage(Locale, String, ...)" pretty faithfully, right?
> Otherwise I'd always get the application's default language.
>
> Thx-
> Ken
>
> Maya Muchnik wrote:
>
> > To have a separate property file for each JSP - it is too much. All the rest - a good
> > idea.
> > I am creating my servlet that extends ActionServlet and does two things: expending
> > destroy and init functions. The reason - I have to initialize some paramaters that I
> > will use in xxxAction through application attributes.
> >
> > Other thing you need to remember that all xxx_xx.properties files do not need to have
> > all messages that in the xxx.properties file. Only what is different.
> >
> > Maya
> >


Re: Locales and images

Posted by Ken Beyer <ka...@metatec.com>.
I'm also seeing that it's way too much now (a message resource per jsp).

I found the following to be helpful...
http://jakarta.apache.org/struts/api/org/apache/struts/util/package-summary.html#doc.Messages

I'm thinking of at least starting off with separating the images from text,
and maybe breaking the text down into packages later on.  Is it correct that
I should override ActionServlet, and pass in additional init-param's similar
to the "application" one?, i.e.

    <init-param>
        <param-name>imageresource</param-name>
        <param-value>com.mycompany.mypkg.ImageResources</param-value>
    </init-param>

and then make sure that I load it (by overriding init()) and calling a
private void initImageResources() + super init(), and similarly for the destroy.

Also, I need to set locale to true in the web.xml (Action servlet section), and
make sure I use "getMessage(Locale, String, ...)" pretty faithfully, right?
Otherwise I'd always get the application's default language.

Thx-
Ken

Maya Muchnik wrote:

> To have a separate property file for each JSP - it is too much. All the rest - a good
> idea.
> I am creating my servlet that extends ActionServlet and does two things: expending
> destroy and init functions. The reason - I have to initialize some paramaters that I
> will use in xxxAction through application attributes.
>
> Other thing you need to remember that all xxx_xx.properties files do not need to have
> all messages that in the xxx.properties file. Only what is different.
>
> Maya
>


Re: Locales and images

Posted by Maya Muchnik <mm...@pumatech.com>.
To have a separate property file for each JSP - it is too much. All the rest - a good
idea.
I am creating my servlet that extends ActionServlet and does two things: expending
destroy and init functions. The reason - I have to initialize some paramaters that I
will use in xxxAction through application attributes.

Other thing you need to remember that all xxx_xx.properties files do not need to have
all messages that in the xxx.properties file. Only what is different.

Maya


Ken Beyer wrote:

> I'm struggling with something very similar and could really
> use a recommendation.
>
> In the Building View Components documentation about i18n,
> (http://jakarta.apache.org/struts/userGuide/building_view.html),
> it describes using a MyResources.properties (default) and
> other MyResources_XX.properties for other languages.
> This uses the "application" init-param of the ActionServlet in web.xml.
> That's fine and dandy for a small application, but....
>
> for a large JSP application, I don't think I want to maintain *all* my
> i18n text (including images!) in a single file per language.
> I'm thinking the best way to break this up is to put some "common"
> text in a file like CommonResources.properties.  Put my images in
> a file like ImageResources.properties.  And finally put text that
> is unique to each JSP file in their own properties files (for example
> Foo.jsp -> FooResources.properties, Bar.jsp -> BarResources.properties,
> etc.) - and I realize that for each language, I'd need a
> BarResources_DE.properties for example, but that's okay.
> I think that each of these ResourceBundle's needs to be put under their
> own application scoped bean/key, i.e. imageresource ->
> com.mycompany.mypackage.ImageResources.
>
> Question is, is this the right approach?  If so, how do I do this?
> I think I use ... bundle="fooresource" via each struts tag, (i.e.
> <html:img pageKey="welcome.gif" bundle="imageresource" border="0"/>)
> And I'd have to load that  in advance via each controller servlet (or should
> I extend org.apache.struts.action.ActionServlet and load them all there).
> Is this all correct?   A pointer to an example would help me greatly.
>
> Thanks,
> Ken
>
> Maya Muchnik wrote:
>
> > Craig,
> >
> > Can I ask you on an example to be sure, that it is correct.
> > My images are under images directory from root application dir. So, I can put the
> > following statements:
> > (in a property file :
> > message.key=images
> > a.image=a.gif
> > a.image.dir=images/a.gif
> > )
> >
> > <html:image pageKey="message.key"/>
> > ...
> > <html:image src="a.gif"/>
> > ...
> >
> > Can I put a.gif into the property file too, and have the second statement as
> > this:
> > <html:image src="a.image"/>
> > Or I can have
> > <html:image srcKey="a.image.dir"/>
> >
> > Thanks,
> >
> > Maya
> >
> > "Craig R. McClanahan" wrote:
> >
> > > There was a recent addition to the <html:image> and <html:img> tags to
> > > support internationalized images elegantly.
> > >
> > > Previously, you had to use the "src" attribute to specify the URI of your
> > > image.  If you needed different images for each language, you had to use a
> > > scriptlet expression of some sort to calculate them.
> > >
> > > Now, you can specify a message key (to be looked up in your application
> > > resources) instead:
> > >
> > >         <html:image srcKey="message.key"/>
> > >
> > > where "message.key" identifies the path to this image from your
> > > application resources.
> > >
> > > If you want to use context-relative paths everywhere, use:
> > >
> > >         <html:image pageKey="message.key"/>
> > >
> > > instead.
> > >
> > >
> > >
> > > Craig
>
> --
> Ken Beyer
> Metatec Internet Products Group
> kab@metatec.com  |  http://www.metatec.com/
> "The box said 'Requires Windows 95 or better.' - so I installed Linux."


Re: Locales and images

Posted by Maya Muchnik <mm...@pumatech.com>.
Craig,
As I understand Ken, he wants to have several files and not combine them in a
application level. He wants to add one attribute for each tag, where the file
name is pointed out. Right Ken? Is it possible? From your response, it is not.
Maya

"Craig R. McClanahan" wrote:

> On Tue, 20 Mar 2001, Ken Beyer wrote:
>
> >
> > I'm struggling with something very similar and could really
> > use a recommendation.
> >
> > In the Building View Components documentation about i18n,
> > (http://jakarta.apache.org/struts/userGuide/building_view.html),
> > it describes using a MyResources.properties (default) and
> > other MyResources_XX.properties for other languages.
> > This uses the "application" init-param of the ActionServlet in web.xml.
> > That's fine and dandy for a small application, but....
> >
> > for a large JSP application, I don't think I want to maintain *all* my
> > i18n text (including images!) in a single file per language.
> > I'm thinking the best way to break this up is to put some "common"
> > text in a file like CommonResources.properties.  Put my images in
> > a file like ImageResources.properties.  And finally put text that
> > is unique to each JSP file in their own properties files (for example
> > Foo.jsp -> FooResources.properties, Bar.jsp -> BarResources.properties,
> > etc.) - and I realize that for each language, I'd need a
> > BarResources_DE.properties for example, but that's okay.
> > I think that each of these ResourceBundle's needs to be put under their
> > own application scoped bean/key, i.e. imageresource ->
> > com.mycompany.mypackage.ImageResources.
> >
> > Question is, is this the right approach?  If so, how do I do this?
> > I think I use ... bundle="fooresource" via each struts tag, (i.e.
> > <html:img pageKey="welcome.gif" bundle="imageresource" border="0"/>)
> > And I'd have to load that  in advance via each controller servlet (or should
> > I extend org.apache.struts.action.ActionServlet and load them all there).
> > Is this all correct?   A pointer to an example would help me greatly.
> >
>
> You are correct about the implications of using multiple application
> resource bundles -- it's a lot of work, but definitely feasible.
>
> One alternative strategy to consider is to keep the application resource
> bundles separate in your *source* code, but combine them together when you
> deploy the application (for example, you can use the unix "cat" command or
> the DOS "copy" command to combine text files).  As long as the message
> keys are all unique (which you should manage by requiring specific
> prefixes for different portions of the app), this will still work fine.
>
> The same basic strategy can be used to allow different developers to work
> on their own portions of the "struts-config.xml" file in the source code,
> but combine them all together when you create the application itself.
>
> > Thanks,
> > Ken
> >
> >
> Craig


Re: Locales and images

Posted by Ken Beyer <ka...@metatec.com>.
Maya Muchnik wrote:

> 1/
> How about several files under A directory:
> B.properties
> B_en.properties
> B_de.properties
> B_fr.properties
>
> and so on...
>
> Can you see it, that you have a problem.

Yeah, it's abit of a problem.  The "overridden"  PropertyMessageResources
would need to be smart enough to group/merge all the locale's together as one.
I think it's doable, but I'm not going to do it until I need to.

For now, I'm sticking with my Ant build doing the merge of
these files.  It's easier, and just as efficient.  My fear is that when I deploy
my WAR, someone's going to mess with some strings in the properties,
and hand me back the changes.  Then I'll have to fold them changes back
into my "segmented" files.   Abit of a pain.

>
> 2/
> How about a file name as extra init parameter  that has names of all properties
> files that you want to "combine". But this becomes a little complicated when you
> think about different languages.

That could work too, but also a pain to implement too.

I just wish there were an easy way for me to load up about
10 bundle's vs. just the 1 "application" one that Struts currently
lets me load.  Then I can use them in my JSP Struts taglibs via
the "bundle" attribute - ie. <html:img srcKey="x.gif" bundle="images" .../>

I mean the 'bundle' attribute is there!!!, I'm just unclear how I set these
different resource bundles in my app scope.   I get the feeling
I'm overlooking something stupid.  Can someone tell me how I set
a "servlet context attribute key for the MessageResources instance to use" ?
This is what it says in the taglib guide, and I'm just unsure how to load
these for use.

thx-
Ken



Re: Locales and images

Posted by Maya Muchnik <mm...@pumatech.com>.
1/
How about several files under A directory:
B.properties
B_en.properties
B_de.properties
B_fr.properties

and so on...

Can you see it, that you have a problem.
2/
How about a file name as extra init parameter  that has names of all properties
files that you want to "combine". But this becomes a little complicated when you
think about different languages.

Maya

Ken Beyer wrote:

> Ken Beyer wrote:
>
> > > Anyone have a snippet of a build.xml that's does this "combining" of
> > > the properties files?
> >
>
> I appologize for beating this thread to death, but I want to mention 2
> more things.
>
> 1) I think I found another way to merge multiple
> properties files (if anyone cares :-). I could write my own
> MessageResourcesFactory class and pass that in via the "factory"
> init-param of my web.xml file.   My home-grown class could do something
> like merge all properties files found under a directory, and either throw
> an exception on duplicates, or simply ignore repeats.
>
> 2) Is it possible to change "application" (init-param) to somehow
> suck in a HashMap of MessageResources?   Maybe through
> multiple init-params or a properties file containing pointers to other
> properties files.  Then I'd call something like getMessage("imagebundle",
> "go.away.button", arg1), or perhaps use a static
> getMessageResourcesByMap("imagebundle").  Also when using struts
> taglibs, when I send - bundle="imagebundle", it would use it as
> a key into the HashMap of MessageResources.  Does this sound feasable
> or even needed?
>
> Looking at the Struts code, it looks like it might be too much to introduce, but
> just thought I'd mention it.
>
> Ken


Re: Locales and images

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Wed, 21 Mar 2001, Ken Beyer wrote:

> Ken Beyer wrote:
> 
> > > Anyone have a snippet of a build.xml that's does this "combining" of
> > > the properties files?
> >
> 
> I appologize for beating this thread to death, but I want to mention 2
> more things.
> 
> 1) I think I found another way to merge multiple
> properties files (if anyone cares :-). I could write my own
> MessageResourcesFactory class and pass that in via the "factory"
> init-param of my web.xml file.   My home-grown class could do something
> like merge all properties files found under a directory, and either throw
> an exception on duplicates, or simply ignore repeats.
> 

Yes, that is certainly an option.

> 2) Is it possible to change "application" (init-param) to somehow
> suck in a HashMap of MessageResources?   Maybe through
> multiple init-params or a properties file containing pointers to other
> properties files.  Then I'd call something like getMessage("imagebundle",
> "go.away.button", arg1), or perhaps use a static
> getMessageResourcesByMap("imagebundle").  Also when using struts
> taglibs, when I send - bundle="imagebundle", it would use it as
> a key into the HashMap of MessageResources.  Does this sound feasable
> or even needed?
> 

I'm looking at something like this to solve the "multiple controller
servlets in one web application" issue, where some large-scale apps need
to be a single web-app (to share sessions), but are constructed in
discrete units by separate development organizations.

The biggest challenge is that the calling sequence is not backwards
compatible.  Your earlier approach deals with that one more elegantly.

> Looking at the Struts code, it looks like it might be too much to introduce, but
> just thought I'd mention it.
> 
> Ken
> 
> 

Craig



Re: Locales and images

Posted by Ken Beyer <ka...@metatec.com>.
Ken Beyer wrote:

> > Anyone have a snippet of a build.xml that's does this "combining" of
> > the properties files?
>

I appologize for beating this thread to death, but I want to mention 2
more things.

1) I think I found another way to merge multiple
properties files (if anyone cares :-). I could write my own
MessageResourcesFactory class and pass that in via the "factory"
init-param of my web.xml file.   My home-grown class could do something
like merge all properties files found under a directory, and either throw
an exception on duplicates, or simply ignore repeats.

2) Is it possible to change "application" (init-param) to somehow
suck in a HashMap of MessageResources?   Maybe through
multiple init-params or a properties file containing pointers to other
properties files.  Then I'd call something like getMessage("imagebundle",
"go.away.button", arg1), or perhaps use a static
getMessageResourcesByMap("imagebundle").  Also when using struts
taglibs, when I send - bundle="imagebundle", it would use it as
a key into the HashMap of MessageResources.  Does this sound feasable
or even needed?

Looking at the Struts code, it looks like it might be too much to introduce, but
just thought I'd mention it.

Ken


Re: Locales and images

Posted by Peter Alfors <pe...@irista.com>.
Check out Ant 1.3.  The user list said that a <concat> task has been added.

HTH,
    Pete

"Craig R. McClanahan" wrote:

> On Tue, 20 Mar 2001, Ken Beyer wrote:
>
> > > Anyone have a snippet of a build.xml that's does this "combining" of
> > > the properties files?
> >
>
> Looks pretty reasonable to me.  It looks like a platform-inpendent <cat>
> task might be a nice contribution to Ant, because this won't work under
> Windows unless you've got CYGWIN installed.
>
> Craig

Re: Locales and images

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Tue, 20 Mar 2001, Ken Beyer wrote:

> > Anyone have a snippet of a build.xml that's does this "combining" of
> > the properties files?
> 

Looks pretty reasonable to me.  It looks like a platform-inpendent <cat>
task might be a nice contribution to Ant, because this won't work under
Windows unless you've got CYGWIN installed.

Craig


Re: Locales and images

Posted by Ken Beyer <ka...@metatec.com>.
> Anyone have a snippet of a build.xml that's does this "combining" of
> the properties files?

Craig/etc,

I'm not an Ant expert, but managed to do the "cat" (of my properties files)
you suggested by putting the following in my build.xml.   I know it's more
Ant specific than Struts, but do you know if there's a better/easier
way than this? ...

    <execon executable="cat"
output="${build.home}/express-ui/WEB-INF/classes/com/metatec/express/ui/common/ApplicationResources.properties">

        <fileset dir="src/ui">
            <patternset id="app.properties">
                <include name="**/*.properties" />
                <exclude name="**/*_??.properties" />
            </patternset>
        </fileset>
    </execon>
    <execon executable="cat"
output="${build.home}/express-ui/WEB-INF/classes/com/metatec/express/ui/common/ApplicationResources_de.properties">

        <fileset dir="src/ui">
            <patternset id="de.properties">
                <include name="**/*_de.properties" />
             </patternset>
        </fileset>
    </execon>
    <execon executable="cat"
output="${build.home}/express-ui/WEB-INF/classes/com/metatec/express/ui/common/ApplicationResources_fr.properties">

        <fileset dir="src/ui">
            <patternset id="fr.properties">
                <include name="**/*_fr.properties" />
             </patternset>
        </fileset>
    </execon>

Thx,
Ken


Re: Locales and images

Posted by Ken Beyer <ka...@metatec.com>.
"Craig R. McClanahan" wrote:

> On Tue, 20 Mar 2001, Ken Beyer wrote:
>
> >
> > I'm struggling with something very similar and could really
> > use a recommendation.
> >
> > In the Building View Components documentation about i18n,
> > (http://jakarta.apache.org/struts/userGuide/building_view.html),
> > it describes using a MyResources.properties (default) and
> > other MyResources_XX.properties for other languages.
> > This uses the "application" init-param of the ActionServlet in web.xml.
> > That's fine and dandy for a small application, but....
> >
> > for a large JSP application, I don't think I want to maintain *all* my
> > i18n text (including images!) in a single file per language.
> > I'm thinking the best way to break this up is to put some "common"
> > text in a file like CommonResources.properties.  Put my images in
> > a file like ImageResources.properties.  And finally put text that
> > is unique to each JSP file in their own properties files (for example
> > Foo.jsp -> FooResources.properties, Bar.jsp -> BarResources.properties,
> > etc.) - and I realize that for each language, I'd need a
> > BarResources_DE.properties for example, but that's okay.
> > I think that each of these ResourceBundle's needs to be put under their
> > own application scoped bean/key, i.e. imageresource ->
> > com.mycompany.mypackage.ImageResources.
> >
> > Question is, is this the right approach?  If so, how do I do this?
> > I think I use ... bundle="fooresource" via each struts tag, (i.e.
> > <html:img pageKey="welcome.gif" bundle="imageresource" border="0"/>)
> > And I'd have to load that  in advance via each controller servlet (or should
> > I extend org.apache.struts.action.ActionServlet and load them all there).
> > Is this all correct?   A pointer to an example would help me greatly.
> >
>
> You are correct about the implications of using multiple application
> resource bundles -- it's a lot of work, but definitely feasible.
>
> One alternative strategy to consider is to keep the application resource
> bundles separate in your *source* code, but combine them together when you
> deploy the application (for example, you can use the unix "cat" command or
> the DOS "copy" command to combine text files).  As long as the message
> keys are all unique (which you should manage by requiring specific
> prefixes for different portions of the app), this will still work fine.
>
> The same basic strategy can be used to allow different developers to work
> on their own portions of the "struts-config.xml" file in the source code,
> but combine them all together when you create the application itself.
>
> > Thanks,
> > Ken
> >
> >
> Craig

Duh, cat.  why didn't I think of that.  use it every day, but didn't even
cross my mind here.   I'll just make sure my message keys are unique.
Anyone have a snippet of a build.xml that's does this "combining" of
the properties files?

Ken

PS -Struts rules!, I was looking for a nice way to separate JSP Java
and HTML and I feel Struts is really excellent for this.  You've all
done a great job developing it and supporting us newcomers.   Keep up
the great work everyone!



Re: Locales and images

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Tue, 20 Mar 2001, Ken Beyer wrote:

> 
> I'm struggling with something very similar and could really
> use a recommendation.
> 
> In the Building View Components documentation about i18n,
> (http://jakarta.apache.org/struts/userGuide/building_view.html),
> it describes using a MyResources.properties (default) and
> other MyResources_XX.properties for other languages.
> This uses the "application" init-param of the ActionServlet in web.xml.
> That's fine and dandy for a small application, but....
> 
> for a large JSP application, I don't think I want to maintain *all* my
> i18n text (including images!) in a single file per language.
> I'm thinking the best way to break this up is to put some "common"
> text in a file like CommonResources.properties.  Put my images in
> a file like ImageResources.properties.  And finally put text that
> is unique to each JSP file in their own properties files (for example
> Foo.jsp -> FooResources.properties, Bar.jsp -> BarResources.properties,
> etc.) - and I realize that for each language, I'd need a
> BarResources_DE.properties for example, but that's okay.
> I think that each of these ResourceBundle's needs to be put under their
> own application scoped bean/key, i.e. imageresource ->
> com.mycompany.mypackage.ImageResources.
> 
> Question is, is this the right approach?  If so, how do I do this?
> I think I use ... bundle="fooresource" via each struts tag, (i.e.
> <html:img pageKey="welcome.gif" bundle="imageresource" border="0"/>)
> And I'd have to load that  in advance via each controller servlet (or should
> I extend org.apache.struts.action.ActionServlet and load them all there).
> Is this all correct?   A pointer to an example would help me greatly.
> 

You are correct about the implications of using multiple application
resource bundles -- it's a lot of work, but definitely feasible.

One alternative strategy to consider is to keep the application resource
bundles separate in your *source* code, but combine them together when you
deploy the application (for example, you can use the unix "cat" command or
the DOS "copy" command to combine text files).  As long as the message
keys are all unique (which you should manage by requiring specific
prefixes for different portions of the app), this will still work fine.

The same basic strategy can be used to allow different developers to work
on their own portions of the "struts-config.xml" file in the source code,
but combine them all together when you create the application itself.

> Thanks,
> Ken
> 
> 
Craig


Re: Locales and images

Posted by Ken Beyer <ka...@metatec.com>.
I'm struggling with something very similar and could really
use a recommendation.

In the Building View Components documentation about i18n,
(http://jakarta.apache.org/struts/userGuide/building_view.html),
it describes using a MyResources.properties (default) and
other MyResources_XX.properties for other languages.
This uses the "application" init-param of the ActionServlet in web.xml.
That's fine and dandy for a small application, but....

for a large JSP application, I don't think I want to maintain *all* my
i18n text (including images!) in a single file per language.
I'm thinking the best way to break this up is to put some "common"
text in a file like CommonResources.properties.  Put my images in
a file like ImageResources.properties.  And finally put text that
is unique to each JSP file in their own properties files (for example
Foo.jsp -> FooResources.properties, Bar.jsp -> BarResources.properties,
etc.) - and I realize that for each language, I'd need a
BarResources_DE.properties for example, but that's okay.
I think that each of these ResourceBundle's needs to be put under their
own application scoped bean/key, i.e. imageresource ->
com.mycompany.mypackage.ImageResources.

Question is, is this the right approach?  If so, how do I do this?
I think I use ... bundle="fooresource" via each struts tag, (i.e.
<html:img pageKey="welcome.gif" bundle="imageresource" border="0"/>)
And I'd have to load that  in advance via each controller servlet (or should
I extend org.apache.struts.action.ActionServlet and load them all there).
Is this all correct?   A pointer to an example would help me greatly.

Thanks,
Ken


Maya Muchnik wrote:

> Craig,
>
> Can I ask you on an example to be sure, that it is correct.
> My images are under images directory from root application dir. So, I can put the
> following statements:
> (in a property file :
> message.key=images
> a.image=a.gif
> a.image.dir=images/a.gif
> )
>
> <html:image pageKey="message.key"/>
> ...
> <html:image src="a.gif"/>
> ...
>
> Can I put a.gif into the property file too, and have the second statement as
> this:
> <html:image src="a.image"/>
> Or I can have
> <html:image srcKey="a.image.dir"/>
>
> Thanks,
>
> Maya
>
> "Craig R. McClanahan" wrote:
>
> > There was a recent addition to the <html:image> and <html:img> tags to
> > support internationalized images elegantly.
> >
> > Previously, you had to use the "src" attribute to specify the URI of your
> > image.  If you needed different images for each language, you had to use a
> > scriptlet expression of some sort to calculate them.
> >
> > Now, you can specify a message key (to be looked up in your application
> > resources) instead:
> >
> >         <html:image srcKey="message.key"/>
> >
> > where "message.key" identifies the path to this image from your
> > application resources.
> >
> > If you want to use context-relative paths everywhere, use:
> >
> >         <html:image pageKey="message.key"/>
> >
> > instead.
> >
> >
> >
> > Craig

--
Ken Beyer
Metatec Internet Products Group
kab@metatec.com  |  http://www.metatec.com/
"The box said 'Requires Windows 95 or better.' - so I installed Linux."




Re: Locales and images

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Tue, 20 Mar 2001, Maya Muchnik wrote:

> Craig,
> 
> If  b.gif is a shared resource for two resource files, is it true, that only a default
> resource file (without language extension) needs to have it?
> 

That is technically correct.  I have found, though, that this sometimes
confuses the people responsible for maintaining the resource bundles --
it's been easier for me to include all message keys in all bundles.

Your mileage may vary.

> Maya
> 

Craig


Re: Locales and images

Posted by Maya Muchnik <mm...@pumatech.com>.
Craig,

If  b.gif is a shared resource for two resource files, is it true, that only a default
resource file (without language extension) needs to have it?

Maya

"Craig R. McClanahan" wrote:

> On Tue, 20 Mar 2001, Maya Muchnik wrote:
>
> > Craig,
> >
> > Can I ask you on an example to be sure, that it is correct.
> > My images are under images directory from root application dir. So, I can put the
> > following statements:
> > (in a property file :
> > message.key=images
> > a.image=a.gif
> > a.image.dir=images/a.gif
> > )
> >
> > <html:image pageKey="message.key"/>
> > ...
> > <html:image src="a.gif"/>
> > ...
> >
> > Can I put a.gif into the property file too, and have the second statement as
> > this:
> > <html:image src="a.image"/>
> > Or I can have
> > <html:image srcKey="a.image.dir"/>
> >
>
> The assumption behind this new facility is that you need to
> internationalize your images as well as your messages.  Perhaps, for
> example, you've created image buttons and the text of those buttons needs
> to be different depending on the user's locale.
>
> Now, let's take Maya's example, and say that our images are stored in an
> "images" directory (relative to the context path of this
> application).  Now, in my application resources for English, I might have:
>
>         image.a=/images/a_en.gif
>         image.b=/images/b.gif
>
> while in my application resources for French, I might have:
>
>         image.a=/images.a_fr.gif
>         image.b=/images.b.gif
>
> Note that -- with these settings -- I'm using a different GIF file for the
> "a" image, but (currently) sharing the "b" image.  Now, I can create a
> single JSP page that grabs the correct version of each image:
>
>         <html:image pageKey="image.a"/>
>         <html:image pageKey="image.b"/>
>
> (When you use the "pageKey" attribute, your paths have to be context
> relative and start with a slash, just like all the paths in
> struts-config.xml.)
>
> Note one added advantage of this approach.  Currently, we're sharing the
> "b" image because it didn't need to be internationalized.  Now, you decide
> that you really do want to make it different.  All you have to do is:
> * Create the new "/images/b_en.gif" and "/images/b_fr.gif" image files
> * Change the two lines in your application resources
> * Restart your app, with no change to any JSP page that uses
>   those images.
>
> Pretty slick, huh?  :-)
>
> > Thanks,
> >
> > Maya
> >
>
> Craig
>
> > "Craig R. McClanahan" wrote:
> >
> > > There was a recent addition to the <html:image> and <html:img> tags to
> > > support internationalized images elegantly.
> > >
> > > Previously, you had to use the "src" attribute to specify the URI of your
> > > image.  If you needed different images for each language, you had to use a
> > > scriptlet expression of some sort to calculate them.
> > >
> > > Now, you can specify a message key (to be looked up in your application
> > > resources) instead:
> > >
> > >         <html:image srcKey="message.key"/>
> > >
> > > where "message.key" identifies the path to this image from your
> > > application resources.
> > >
> > > If you want to use context-relative paths everywhere, use:
> > >
> > >         <html:image pageKey="message.key"/>
> > >
> > > instead.
> > >
> > >
> > >
> > > Craig
> >
> >


Re: Locales and images

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Tue, 20 Mar 2001, Maya Muchnik wrote:

> Craig,
> 
> Can I ask you on an example to be sure, that it is correct.
> My images are under images directory from root application dir. So, I can put the
> following statements:
> (in a property file :
> message.key=images
> a.image=a.gif
> a.image.dir=images/a.gif
> )
> 
> <html:image pageKey="message.key"/>
> ...
> <html:image src="a.gif"/>
> ...
> 
> Can I put a.gif into the property file too, and have the second statement as
> this:
> <html:image src="a.image"/>
> Or I can have
> <html:image srcKey="a.image.dir"/>
> 

The assumption behind this new facility is that you need to
internationalize your images as well as your messages.  Perhaps, for
example, you've created image buttons and the text of those buttons needs
to be different depending on the user's locale.

Now, let's take Maya's example, and say that our images are stored in an
"images" directory (relative to the context path of this
application).  Now, in my application resources for English, I might have:

	image.a=/images/a_en.gif
	image.b=/images/b.gif

while in my application resources for French, I might have:

	image.a=/images.a_fr.gif
	image.b=/images.b.gif

Note that -- with these settings -- I'm using a different GIF file for the
"a" image, but (currently) sharing the "b" image.  Now, I can create a
single JSP page that grabs the correct version of each image:

	<html:image pageKey="image.a"/>
	<html:image pageKey="image.b"/>

(When you use the "pageKey" attribute, your paths have to be context
relative and start with a slash, just like all the paths in
struts-config.xml.)

Note one added advantage of this approach.  Currently, we're sharing the
"b" image because it didn't need to be internationalized.  Now, you decide
that you really do want to make it different.  All you have to do is:
* Create the new "/images/b_en.gif" and "/images/b_fr.gif" image files
* Change the two lines in your application resources
* Restart your app, with no change to any JSP page that uses
  those images.

Pretty slick, huh?  :-)

> Thanks,
> 
> Maya
> 

Craig


> "Craig R. McClanahan" wrote:
> 
> > There was a recent addition to the <html:image> and <html:img> tags to
> > support internationalized images elegantly.
> >
> > Previously, you had to use the "src" attribute to specify the URI of your
> > image.  If you needed different images for each language, you had to use a
> > scriptlet expression of some sort to calculate them.
> >
> > Now, you can specify a message key (to be looked up in your application
> > resources) instead:
> >
> >         <html:image srcKey="message.key"/>
> >
> > where "message.key" identifies the path to this image from your
> > application resources.
> >
> > If you want to use context-relative paths everywhere, use:
> >
> >         <html:image pageKey="message.key"/>
> >
> > instead.
> >
> >
> >
> > Craig
> 
> 


Re: Locales and images

Posted by Maya Muchnik <mm...@pumatech.com>.
Craig,

Can I ask you on an example to be sure, that it is correct.
My images are under images directory from root application dir. So, I can put the
following statements:
(in a property file :
message.key=images
a.image=a.gif
a.image.dir=images/a.gif
)

<html:image pageKey="message.key"/>
...
<html:image src="a.gif"/>
...

Can I put a.gif into the property file too, and have the second statement as
this:
<html:image src="a.image"/>
Or I can have
<html:image srcKey="a.image.dir"/>

Thanks,

Maya

"Craig R. McClanahan" wrote:

> There was a recent addition to the <html:image> and <html:img> tags to
> support internationalized images elegantly.
>
> Previously, you had to use the "src" attribute to specify the URI of your
> image.  If you needed different images for each language, you had to use a
> scriptlet expression of some sort to calculate them.
>
> Now, you can specify a message key (to be looked up in your application
> resources) instead:
>
>         <html:image srcKey="message.key"/>
>
> where "message.key" identifies the path to this image from your
> application resources.
>
> If you want to use context-relative paths everywhere, use:
>
>         <html:image pageKey="message.key"/>
>
> instead.
>
>
>
> Craig


Re: Locales and images

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Mon, 19 Mar 2001, Kyle Robinson wrote:

> I understand Struts has support for makeing web apps available in different
> languages.  Does this include images?  If I have images with text on them in
> English can I make images with text in French as well?  Do I name the image
> files differently or do I have to include the paths to the images in the
> property files?  Has anyone done this?  What's the best approach?
> 

There was a recent addition to the <html:image> and <html:img> tags to
support internationalized images elegantly.

Previously, you had to use the "src" attribute to specify the URI of your
image.  If you needed different images for each language, you had to use a
scriptlet expression of some sort to calculate them.

Now, you can specify a message key (to be looked up in your application
resources) instead:

	<html:image srcKey="message.key"/>

where "message.key" identifies the path to this image from your
application resources.

If you want to use context-relative paths everywhere, use:

	<html:image pageKey="message.key"/>

instead.

> Kyle Robinson
> Systems Consultant
> Pangaea Systems Inc.
> (250) 360-0111
> 
> 

Craig