CSS Localization

9 views
Skip to first unread message

Dan

unread,
Jun 27, 2010, 9:53:48 PM6/27/10
to Google Web Toolkit
Is it possible to localize the css in a CssResource so that during the
translation phase of product development, css tweaks can be made to
adjust for language specific spacing and formatting issues?

if not, what's the current best practice to work around these issues?

Thomas Broyer

unread,
Jun 28, 2010, 4:44:19 AM6/28/10
to Google Web Toolkit


On 28 juin, 03:53, Dan <ddum...@gmail.com> wrote:
> Is it possible to localize the css in a CssResource so that during the
> translation phase of product development, css tweaks can be made to
> adjust for language specific spacing and formatting issues?

Yes, you can have distinct MyStyle_en.css MyStyle_fr.css, etc. and
have them picked from a single @Source("MyStyle.css").

> if not, what's the current best practice to work around these issues?


If the changes are "localised" though, I'd rather use @if blocks:
@if locale en {
...
}
@elif locale fr {
...
}

Dan Dumont

unread,
Jun 28, 2010, 5:32:41 PM6/28/10
to google-we...@googlegroups.com
AMAZING!

is that documented anywhere?   I saw no mention on the css section of the building user interfaces part of the docs.

}

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


Qian Qiao

unread,
Jun 29, 2010, 1:13:11 AM6/29/10
to google-we...@googlegroups.com

It is in the documentation:
http://code.google.com/webtoolkit/doc/latest/DevGuideClientBundle.html#CssResource

--
Proper software development is like female orgasm. Some claim it's a
myth, others try very hard to make it happen but don't know how, and
most magazines, books and videos showing it are showing faked ones.

Thomas Broyer

unread,
Jun 29, 2010, 6:21:52 AM6/29/10
to Google Web Toolkit


On 28 juin, 23:32, Dan Dumont <ddum...@gmail.com> wrote:
> AMAZING!
>
> is that documented anywhere?   I saw no mention on the css section of the
> building user interfaces part of the docs.

http://code.google.com/webtoolkit/doc/latest/DevGuideClientBundle.html#I18N

"""This will work equally well with all resource types"""

Dan Dumont

unread,
Jun 29, 2010, 7:44:06 AM6/29/10
to google-we...@googlegroups.com
Thank you both! I'll go get my eyes checked now...


--

djd

unread,
Jun 29, 2010, 9:04:26 AM6/29/10
to Google Web Toolkit
If you can do all formatting from Css, one idea to go is like this:

- in your war directory, or one subdirectory of this (can be
anywhere), have the locale-specific css files, given a specific naming
convention (let's say "main-en.css", "main-fr.css" - for french
locale). The idea is to name the files as a fixed prefix with a
variable (locale based - en, fr, de, etc) suffix.
- in your code (let's say at init time, before any widgets are
constructed), simply read the locale from browser and inject the right
css into dom (http://code.google.com/p/google-web-toolkit/wiki/
StyleInjector). If this doesn't work, you can try to manually write a
Js function that appends the Css to dom (achievable, I've done it).
Your only attention here is to supply the mapping (locale => url).


If you can't do everything from Css, along with the things above, you
will need to supply localized widgets...I can think of a couple of
ways, but i'm not sure you can do deferred binding for that. If not,
you could have some sort of factory pattern that would provide you
with the widgets.

Hope that helps,
Alex
Reply all
Reply to author
Forward
0 new messages