On Wednesday, November 8, 2017 at 12:04:53 PM UTC+1, Amir Norozi wrote:
>
>
> <https://lh3.googleusercontent.com/-eFkwqlJaQOg/WgLfwq22fPI/AAAAAAAAACg/f-M7tUuwOkUmI6CumdDYcP-cU333HCsxQCLcBGAs/s1600/Capture.PNG>
> 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() 
<http://www.gwtproject.org/javadoc/latest/com/google/gwt/i18n/client/LocaleInfo.html#isRTL-->.
 
Some widgets already take that information into account and adapt their 
layout automatically.
The Showcase sample 
<https://github.com/gwtproject/gwt/tree/2.8.2/samples/showcase> 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 
<http://www.gwtproject.org/javadoc/latest/com/google/gwt/dom/client/StyleInjector.html>
 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

Reply via email to