Here is what I came up with:
In my <project>.gwt.xml file I added the following line:
<set-configuration-property name="locale.cookie" value="gwtLocale"/>
On the page I created a simple dropdown box with all the languages supported by my site. I am filling this box with the following code (shamlessly coppied from the GWT Showcase app by Google).
String[] localeNames = LocaleInfo.getAvailableLocaleNames();
for (String localeName : localeNames) {
if (!localeName.equals("default")) {
String nativeName = LocaleInfo.getLocaleNativeDisplayName(localeName);
languageBox.addItem(nativeName, localeName);
if (localeName.equals(currentLocale)) {
languageBox.setSelectedIndex(languageBox.getItemCount() - 1);
}
}
}
In the change handler for this dropdown box I set up the following bit of code:
String localeName = languageBox.getValue( languageBox.getSelectedIndex() );
Date now = new Date();
long nowLong = now.getTime();
nowLong = nowLong + (1000 * 60 * 60 * 24 * 21);
now.setTime(nowLong);
Cookies.setCookie("gwtLocale", localeName, now);
Then once the page is reloaded I do the following:
String currentLocale = Cookies.getCookie( LocaleInfo.getLocaleCookieName() );
if (currentLocale.equals("default") || currentLocale == null ) {
currentLocale = "en_US";
}
And that's it a very simple clean and easy pure GWT way of allowing your user to set their locale for your website using a cookie. Not bad for my first day of playing wit GWT, now on to the next task of the project having a user login on the site. (Authentication only for now Authorization will follow after that...)
If players may withdraw and deposit via cryptocurrencies, it is going to shorten the time taken to a couple of seconds or hours in line with the particular coin used. For more ideal details about online sports, check out.
ReplyDelete