Wednesday, November 8, 2017

Re: GWT multilanguage and fix direction



On Wednesday, November 8, 2017 at 12:04:53 PM UTC+1, Amir Norozi wrote:

Hi guys!
I've a GWT project that is many language like french,english and specially farsi and arabic.
I want that when my users click on farsi or arabic then all of elements on my web pages will to be RTL and...
when click on french or english all of them come back to LTR.
please guide me... :)

Assuming you're using GWT I18N here (note that this means reloading the application whenever you want/need to change the locale), you can know if the current locale is RTL (to adapt the UI) by calling LocaleInfo.getCurrentLocale().isRTL(). Some widgets already take that information into account and adapt their layout automatically.
The Showcase sample is a good example; for example: https://github.com/gwtproject/gwt/blob/2.8.2/samples/showcase/src/com/google/gwt/sample/showcase/client/ShowcaseShell.java#L197-L201 and https://github.com/gwtproject/gwt/blob/2.8.2/samples/showcase/src/com/google/gwt/sample/showcase/client/content/popups/CwDialogBox.java#L179-L186 (notice how almost everything switches to RTL without the need for the anything else in the code besides those two places). The showcase also uses this information to conditionally load different CSS stylesheets on load: https://github.com/gwtproject/gwt/blob/2.8.2/samples/showcase/src/com/google/gwt/sample/showcase/client/Showcase.java#L244 (note that it could have used StyleInjector to simplify the code)

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment