Tuesday, July 31, 2012

Re: Setting Locale language dynamically initially

But, I don't have a server-side technology, and I don't want to have one. The whole idea is to have only client-side HTML, JavaScript, CSS.... technology and that is it. That is why I need something using JavaScript or GWT to solve the problem.

Ok take a look at com.google.gwt.i18n.I18N.gwt.xml

Seems like there are 5 ways to provide the locale:

1.) using a query param named "locale". To use this method you can let your web server send a redirect from app.example.com to app.example.com/?locale=<locale> after determining the locale on your web server if possible or you do the redirect from within your app, e.g. in your onModuleLoad() you use Window.Location.assign(<current url> + <locale query param>). You can change the name of the query param by setting a different value to "locale.queryparam".

2.) using a cookie. To use this you have to define the cookie name by setting "locale.cookie" to any value as in I18N.gwt.xml no default cookie name is defined.

3.) using meta tags. As already described you can include a gwt:property meta tag in a dynamic host page.

4.) using the user agent information. To use this you have to activate it by setting "locale.useragent" to "Y" as its disabled by default in I18N.gwt.xml.

5.) create your own property provider and use JavaScript to fill the "locale" property value yourself. Here you are completely free how to obtain the value.

GWT's default search order is "query param, cookie, meta, useragent" but cookie and useragent will be skipped if you don't configure/activate them. You could also modify the search order by setting "locale.searchorder" in your gwt.xml.

Now choose one solution ... 

-- J.

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/B-9Jd1XS9J4J.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment