Revision: 9850
Author: gwt.mirror...@gmail.com
Date: Tue Mar 15 07:52:10 2011
Log: Fix generated JS for getting the locale property value from the
user agent.
Public review at: http://gwt-code-reviews.appspot.com/1382803/
Patch by: jat
Review by: jlabanca
http://code.google.com/p/google-web-toolkit/source/detail?r=9850
Modified:
/trunk/samples/showcase/src/com/google/gwt/sample/showcase/Showcase.gwt.xml
/trunk/user/src/com/google/gwt/i18n/linker/LocalePropertyProviderGenerator.java
=======================================
---
/trunk/samples/showcase/src/com/google/gwt/sample/showcase/Showcase.gwt.xml
Mon Feb 28 08:19:11 2011
+++
/trunk/samples/showcase/src/com/google/gwt/sample/showcase/Showcase.gwt.xml
Tue Mar 15 07:52:10 2011
@@ -25,4 +25,5 @@
<extend-property name="locale" values="zh"/>
<set-property-fallback name="locale" value="en"/>
<set-configuration-property name="locale.cookie"
value="SHOWCASE_LOCALE"/>
+ <set-configuration-property name="locale.useragent" value="Y"/>
</module>
=======================================
---
/trunk/user/src/com/google/gwt/i18n/linker/LocalePropertyProviderGenerator.java
Tue Dec 21 05:40:19 2010
+++
/trunk/user/src/com/google/gwt/i18n/linker/LocalePropertyProviderGenerator.java
Tue Mar 15 07:52:10 2011
@@ -280,9 +280,15 @@
+ "navigator.browserLanguage : navigator.language;");
body.println("if (language) {");
body.indent();
- body.println("locale = language.replace(/-/g, \"_\");");
+ body.println("var parts = language.split(/[-_]/);");
+ body.println("if (parts.length > 1) {");
+ body.indent();
+ body.println("parts[1] = parts[1].toUpperCase();");
body.outdent();
- body.println();
+ body.println("}");
+ body.println("locale = parts.join(\"_\");");
+ body.outdent();
+ body.println("}");
}
/**
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors