Re: i18n

Charles Goodwin <[email protected]> Tue, 8 Apr 2003 17:21:43 +0100
Newsgroups gmane.comp.java.xwt.general
Message-ID <308906BE5D07D5119285009027D61C5722F6D1@NTFPS1>
> Would these go in <template/>, or <static/>? Why? And doesn't the 'var'
> in front of it make it local to the template?

I used <template /> because I didn't have great success with xwt.static and
theming.  I'm hoping xwt.overlay() will fix this.

As for 'var' making things local... yes, it should, but what is local wrt
xwt and whether or not it works are both questions I don't really know the
answer to because I've no recollection of coming across any problems using
it.

> >     <template>
> >         <teststrings id="strings" />
> >         <testtemplate1 id="template1" />
> >         <testtemplate2 id="template2" />
> >         <testtemplate3 id="template3" />
> > 
> >         $template1.font = $template2.font = $template3.font =
> > $teststrings.font;
> 
> I still don't understand how $teststrings ends up pointing to
> com.emile.lang here.

Oops, typo... s/\$teststrings/\$strings/

If that correction doesn't help, here's the explanation:

The import: <import name="com.emile.lang" />

This says to look for templates in com.emile.lang.

The theme: xwt.theme( "com.emile.lang", "com.emile.english" );

This says that, if com.emile.lang is imported, to look for the templates in
com.emile.english first.  You only have to theme once, and then all
templates that import com.emile.lang will automatically be searching
com.emile.english.

Since <teststrings> is in com.emile.english, it gets instantiated (if it
wasn't in com.emile.english, xwt would then look in com.emile.lang <- you
could use this as the default) and then the rest of the example is self
explanatory.

> <testtemplate1 id="template1" label="&xwt.property.foo.bar.stringz;"/>

This could only work when referencing static stuff.  You can't reference
non-static stuff as only static stuff is the same across different
instantiations.  If you have two buttons $button1 and $button2, does
xwt.property.button.activated come from $button1 or $button2?

> The upside of this is that fixed parts of the ui would translate
> itself automatically without much code being necesary to do so

It's practically the same amount:

<testtemplate1 id="template1" label="&xwt.property.foo.bar.stringz;"/>

vs

<testtemplate1 id="template1" />
$template1.label = xwt.property.foo.bar.stringz

> But for now I'll be happy to just do it by hand. All I want, initially,
> is a way to keep the language strings and images (these might need
> localization at some point) separate from the actual code.

I think a refined version of what Adam suggested (which I based my example
on) is along the right lines.  Of course, we should try to make it as easy
as possible, but I'm not sure of the feasibility of anything ohter than a
combination of 1) allowing <b p="x"> in tag references to xwt.static and 2)
xwt.theme and/or xwt.overlay actually working on xwt.static blocks.
_______________________________________________
http://lists.xwt.org/listinfo/dev