Reviewers: jlabanca,
Description:
As mentioned at the end of issue 4228, the portion of the locale
property provider which gets the value from the user agent is broken. I
fixed the bug and tested it on several platforms, which also revealed
another problem where the browsers supply the region code in lowercase.
This is really hard to test much at all, since you would need to be
running a real browser with different locales, so I thought it would be
better to make Showcase use the feature so future problems would be
caught during smoke tests.
Please review this at http://gwt-code-reviews.appspot.com/1382803/
Affected files:
samples/showcase/src/com/google/gwt/sample/showcase/Showcase.gwt.xml
user/src/com/google/gwt/i18n/linker/LocalePropertyProviderGenerator.java
Index:
user/src/com/google/gwt/i18n/linker/LocalePropertyProviderGenerator.java
===================================================================
---
user/src/com/google/gwt/i18n/linker/LocalePropertyProviderGenerator.java
(revision 9848)
+++
user/src/com/google/gwt/i18n/linker/LocalePropertyProviderGenerator.java
(working copy)
@@ -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("}");
}
/**
Index: samples/showcase/src/com/google/gwt/sample/showcase/Showcase.gwt.xml
===================================================================
--- samples/showcase/src/com/google/gwt/sample/showcase/Showcase.gwt.xml
(revision 9848)
+++ samples/showcase/src/com/google/gwt/sample/showcase/Showcase.gwt.xml
(working copy)
@@ -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>
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors