On 29 oct, 17:15, Thomas Broyer <[EMAIL PROTECTED]> wrote:
> On 29 oct, 12:51, jagadesh <[EMAIL PROTECTED]> wrote:
>
> > Hi Guys ,
>
> > Iam Working On Gwt 1.5.3 . My Requirement is
> > Iam Using 2 languages  one is English and other is Chines
> > [ Traditional]
>
> > i have written 2 constants file for both. now how can i set the
> > language depending on the browser locale.
> > i.e if the site opens in china , the language should be chinese and
> > chinese constant file should be selected.
>
> > how can i do this sort of thing .
>
> > Can Anyone Sort Me out. a sample code would be more helpfull.
>
> You should use content-negotiation on the server-side [...]
> If you use Apache, [...]

And now you can somehow "delegate" the server-side negotiation to a
third party:
http://ajaxian.com/archives/language-jsonp-service

Untested, but you should now be able to do in your *.gwt.xml:

  <script src="http://langdetect.appspot.com/?
callback=(function(languages){window.languages=languages;})" />
  <property-provider name="locale">
    <![CDATA[
    try {
      for (int i = 0; i < languages.length; i++) {
        // normalize to java.util.Locale format
        var localeInfo = languages[i].split("-");
        localeInfo[0] = localeInfo[0].toLowerCase();
        localeInfo[1] = localeInfo[1].toUpperCase();
        var locale = "_".join(localeInfo);
        if (__gwt_isKnownPropertyValue("locale", locale) {
          return locale;
        }
      }
      return "default";
    } catch(e){
      alert("Unexpected exception in locale detection, using default:
" + e);
      return "default";
    }
  ]]>
  </property-provider>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to