Hi,
I found this simple and neat way to change the language of the web
page dynamically. This will be helpfull to change the languge of the
gwt ext components also.

Copy and paste the following code into a new file named "decode-
lang.js" and place it in the "src/ext" directory.



    // decode language passed in url
   var locale = gup( 'locale' );

    // append locale script to the head

    if(locale) {
           includeJavascript( 'ext/source/locale/ext-lang-' + locale +
'.js');//Change the relative path of your lang files over here....
        }

        function gup( name )
        {

          name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
          var regexS = "[\\?&]"+name+"=([^&#]*)";
          var regex = new RegExp( regexS );
          var results = regex.exec( window.location.href );
          if( results == null )
            return "";
          else
            return results[1];
        }

        function includeJavascript(src) {
                var head_tag = document.getElementsByTagName('head')[0];
                var script_tag = document.createElement('script');
                script_tag.setAttribute('type', 'text/javascript');
                script_tag.setAttribute('src', src);
                head_tag.appendChild(script_tag);
        }




Now in your "gwt.xml" file add this js file by just adding the line.
  <script src="ext/decode-lang.js"/>

Now if u access the url with the parameter ?locale=fr or ?locale=de or
any language, all the components are automatically cahnged to the
respective languages.

I just thought this would be usefull since I searched a lot for this..

--~--~---------~--~----~------------~-------~--~----~
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