You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2014/05/23 08:08:34 UTC

[1/5] git commit: Android should return BCP47 tag, not localized string

Repository: cordova-plugin-globalization
Updated Branches:
  refs/heads/master b02fe3f1b -> be9b83b19


Android should return BCP47 tag, not localized string


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/commit/69562f4d
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/tree/69562f4d
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/diff/69562f4d

Branch: refs/heads/master
Commit: 69562f4d726f2ddcca4d82c6cb6a4b02402e2edd
Parents: e15742a
Author: mbillau <mi...@gmail.com>
Authored: Mon Apr 28 15:02:39 2014 -0400
Committer: mbillau <mi...@gmail.com>
Committed: Tue Apr 29 12:59:31 2014 -0400

----------------------------------------------------------------------
 doc/index.md                   | 10 ++++---
 src/android/Globalization.java | 52 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 58 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/69562f4d/doc/index.md
----------------------------------------------------------------------
diff --git a/doc/index.md b/doc/index.md
index 74bf9ee..18afafd 100644
--- a/doc/index.md
+++ b/doc/index.md
@@ -435,8 +435,8 @@ Get the string identifier for the client's current language.
 
 ### Description
 
-Returns the language identifier string to the `successCallback` with a
-`properties` object as a parameter. That object should have a `value`
+Returns the BCP-47 compliant language identifier tag to the `successCallback` 
+with a `properties` object as a parameter. That object should have a `value`
 property with a `String` value.
 
 If there is an error getting the language, then the `errorCallback`
@@ -453,13 +453,17 @@ error's expected code is `GlobalizationError.UNKNOWN\_ERROR`.
 ### Example
 
 When the browser is set to the `en\_US` locale, this should display a
-popup dialog with the text `language: English`:
+popup dialog with the text `language: en_US`:
 
     navigator.globalization.getPreferredLanguage(
         function (language) {alert('language: ' + language.value + '\n');},
         function () {alert('Error getting language\n');}
     );
 
+### Android Quirks
+
+- Returns the ISO 639-1 two-letter language code, upper case ISO 3166-1 
+country code and variant separated by underscores. Examples: "en", "en_US", "_US"
 
 ### Windows Phone 8 Quirks
 

http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/69562f4d/src/android/Globalization.java
----------------------------------------------------------------------
diff --git a/src/android/Globalization.java b/src/android/Globalization.java
index 588fe4a..612d731 100644
--- a/src/android/Globalization.java
+++ b/src/android/Globalization.java
@@ -148,6 +148,56 @@ public class Globalization extends CordovaPlugin  {
             throw new GlobalizationError(GlobalizationError.UNKNOWN_ERROR);
         }
     }
+        /*
+     * @Description: Returns a well-formed ITEF BCP 47 language tag representing this localestring identifier for the client's current locale 
+     *
+     * @Return: String: The BCP 47 language tag for the current locale
+     */
+    private String toBcp47Language(Locale loc){
+        final char SEP = '-';       // we will use a dash as per BCP 47
+        String language = loc.getLanguage();
+        String region = loc.getCountry();
+        String variant = loc.getVariant();
+
+        // special case for Norwegian Nynorsk since "NY" cannot be a variant as per BCP 47
+        // this goes before the string matching since "NY" wont pass the variant checks
+        if( language.equals("no") && region.equals("NO") && variant.equals("NY")){
+            language = "nn";
+            region = "NO";
+            variant = "";
+        }
+
+        if( language.isEmpty() || !language.matches("\\p{Alpha}{2,8}")){
+            language = "und";       // Follow the Locale#toLanguageTag() implementation 
+                                    // which says to return "und" for Undetermined
+        }else if(language.equals("iw")){
+            language = "he";        // correct deprecated "Hebrew"
+        }else if(language.equals("in")){
+            language = "id";        // correct deprecated "Indonesian"
+        }else if(language.equals("ji")){
+            language = "yi";        // correct deprecated "Yiddish"
+        }
+
+        // ensure valid country code, if not well formed, it's omitted
+        if (!region.matches("\\p{Alpha}{2}|\\p{Digit}{3}")) {
+            region = "";
+        }
+
+         // variant subtags that begin with a letter must be at least 5 characters long
+        if (!variant.matches("\\p{Alnum}{5,8}|\\p{Digit}\\p{Alnum}{3}")) {
+            variant = "";
+        }
+
+        StringBuilder bcp47Tag = new StringBuilder(language);
+        if (!region.isEmpty()) {
+            bcp47Tag.append(SEP).append(region);
+        }
+        if (!variant.isEmpty()) {
+             bcp47Tag.append(SEP).append(variant);
+        }
+
+        return bcp47Tag.toString();
+    }
     /*
      * @Description: Returns the string identifier for the client's current language
      *
@@ -159,7 +209,7 @@ public class Globalization extends CordovaPlugin  {
     private JSONObject getPreferredLanguage() throws GlobalizationError {
         JSONObject obj = new JSONObject();
         try {
-            obj.put("value", Locale.getDefault().getDisplayLanguage().toString());
+            obj.put("value", toBcp47Language(Locale.getDefault()));
             return obj;
         } catch (Exception e) {
             throw new GlobalizationError(GlobalizationError.UNKNOWN_ERROR);


[3/5] git commit: CB-4602 CB-6490 CB-4822 WP Globalization

Posted by pu...@apache.org.
CB-4602 CB-6490 CB-4822 WP Globalization

BCP-47 compliance for getLocaleName, getPreferredLanguage.


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/commit/86bd57c3
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/tree/86bd57c3
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/diff/86bd57c3

Branch: refs/heads/master
Commit: 86bd57c39bee21116ce6ced42254f34be602c9cd
Parents: 693a6f2
Author: Staci Cooper <sm...@us.ibm.com>
Authored: Thu May 15 12:34:28 2014 -0700
Committer: Staci Cooper <sm...@us.ibm.com>
Committed: Thu May 15 12:34:28 2014 -0700

----------------------------------------------------------------------
 src/wp/Globalization.cs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/86bd57c3/src/wp/Globalization.cs
----------------------------------------------------------------------
diff --git a/src/wp/Globalization.cs b/src/wp/Globalization.cs
index ffe27ec..cac1e03 100644
--- a/src/wp/Globalization.cs
+++ b/src/wp/Globalization.cs
@@ -435,7 +435,7 @@ namespace WPCordovaClassLib.Cordova.Commands
         {
             try
             {
-                var locale = RegionInfo.CurrentRegion.TwoLetterISORegionName;
+                var locale = CultureInfo.CurrentCulture.Name;
                 PluginResult result = new PluginResult(PluginResult.Status.OK, this.WrapIntoJSON(locale));
                 this.DispatchCommandResult(result);
             }
@@ -453,7 +453,7 @@ namespace WPCordovaClassLib.Cordova.Commands
         {
             try
             {
-                var language = CultureInfo.CurrentCulture.TwoLetterISOLanguageName;
+                var language = CultureInfo.CurrentUICulture.Name;
                 PluginResult result = new PluginResult(PluginResult.Status.OK, this.WrapIntoJSON(language));
                 this.DispatchCommandResult(result);
             }


[5/5] git commit: Merge branch 'CB-4602wp' of https://github.com/stacic/cordova-plugin-globalization

Posted by pu...@apache.org.
Merge branch 'CB-4602wp' of https://github.com/stacic/cordova-plugin-globalization


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/commit/be9b83b1
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/tree/be9b83b1
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/diff/be9b83b1

Branch: refs/heads/master
Commit: be9b83b1900dea88258d9aa23bd398f41b0ba198
Parents: b02fe3f 2ad8451
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Thu May 22 23:02:08 2014 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Thu May 22 23:02:08 2014 -0700

----------------------------------------------------------------------
 doc/index.md                   | 224 ++++++++++++++++++++----------------
 src/android/Globalization.java |  63 +++++++++-
 src/wp/Globalization.cs        |   4 +-
 3 files changed, 186 insertions(+), 105 deletions(-)
----------------------------------------------------------------------



[4/5] git commit: CB-4602 Added clarification to docs

Posted by pu...@apache.org.
CB-4602 Added clarification to docs


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/commit/2ad8451e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/tree/2ad8451e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/diff/2ad8451e

Branch: refs/heads/master
Commit: 2ad8451e763896360fc4212fb0051039390e3baf
Parents: 86bd57c
Author: Staci Cooper <sm...@us.ibm.com>
Authored: Wed May 21 08:32:41 2014 -0700
Committer: Staci Cooper <sm...@us.ibm.com>
Committed: Wed May 21 08:32:41 2014 -0700

----------------------------------------------------------------------
 doc/index.md | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/2ad8451e/doc/index.md
----------------------------------------------------------------------
diff --git a/doc/index.md b/doc/index.md
index 9187e57..4e949f2 100644
--- a/doc/index.md
+++ b/doc/index.md
@@ -92,8 +92,11 @@ country code and variant separated by hyphens. Examples: "en", "en-US", "US"
 
 ### Windows Phone 8 Quirks
 
-- Returns the ISO 639-1 two-letter code for the current language.
-
+- Returns the ISO 639-1 two-letter language code and ISO 3166-1 country code
+of the regional variant corresponding to the "Language" setting, separated by
+a hyphen.
+- Note that the regional variant is a property of the "Language" setting and
+not determined by the unrelated "Country/Region" setting on Windows Phone.
 
 ## navigator.globalization.getLocaleName
 
@@ -137,7 +140,9 @@ method is essentially the same as `navigator.globalizatin.getPreferredLanguage()
 
 ### Windows Phone 8 Quirks
 
-- Returns the two-letter code defined in ISO 3166 for the current country/region.
+- Returns the ISO 639-1 two-letter language code and ISO 3166-1 country code
+of the regional variant corresponding to the "Regional Format" setting, separated
+by a hyphen.
 
 
 ## navigator.globalization.dateToString


[2/5] git commit: getLocale,getLanguage, and docs

Posted by pu...@apache.org.
getLocale,getLanguage, and docs


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/commit/693a6f23
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/tree/693a6f23
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/diff/693a6f23

Branch: refs/heads/master
Commit: 693a6f2365533db4843125a62163f65f11b0150d
Parents: 69562f4
Author: mbillau <mi...@gmail.com>
Authored: Thu May 1 12:32:08 2014 -0400
Committer: mbillau <mi...@gmail.com>
Committed: Thu May 1 12:32:08 2014 -0400

----------------------------------------------------------------------
 doc/index.md                   | 223 +++++++++++++++++++-----------------
 src/android/Globalization.java |  43 ++++---
 2 files changed, 144 insertions(+), 122 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/693a6f23/doc/index.md
----------------------------------------------------------------------
diff --git a/doc/index.md b/doc/index.md
index 18afafd..9187e57 100644
--- a/doc/index.md
+++ b/doc/index.md
@@ -20,7 +20,14 @@
 # org.apache.cordova.globalization
 
 This plugin obtains information and performs operations specific to the user's
-locale and timezone.
+locale, language, and timezone. Note the difference between locale and language:
+locale controls how numbers, dates, and times are displayed for a region, while
+language determines what language text appears as, independently of locale settings.
+Often developers use locale to set both settings, but there is no reason a user
+couldn't set her language to "English" but locale to "French", so that text is
+displayed in English but dates, times, etc., are displayed as they are in France.
+Unfortunately, most mobile platforms currently do not make a distinction between
+these settings. 
 
 ## Installation
 
@@ -45,6 +52,93 @@ locale and timezone.
 - navigator.globalization.getNumberPattern
 - navigator.globalization.getCurrencyPattern
 
+## navigator.globalization.getPreferredLanguage
+
+Get the BCP 47 language tag for the client's current language.
+
+    navigator.globalization.getPreferredLanguage(successCallback, errorCallback);
+
+### Description
+
+Returns the BCP-47 compliant language identifier tag to the `successCallback` 
+with a `properties` object as a parameter. That object should have a `value`
+property with a `String` value.
+
+If there is an error getting the language, then the `errorCallback`
+executes with a `GlobalizationError` object as a parameter. The
+error's expected code is `GlobalizationError.UNKNOWN_ERROR`.
+
+### Supported Platforms
+
+- Amazon Fire OS
+- Android
+- iOS
+- Windows Phone 8
+
+### Example
+
+When the browser is set to the `en-US` language, this should display a
+popup dialog with the text `language: en-US`:
+
+    navigator.globalization.getPreferredLanguage(
+        function (language) {alert('language: ' + language.value + '\n');},
+        function () {alert('Error getting language\n');}
+    );
+
+### Android Quirks
+
+- Returns the ISO 639-1 two-letter language code, upper case ISO 3166-1 
+country code and variant separated by hyphens. Examples: "en", "en-US", "US"
+
+### Windows Phone 8 Quirks
+
+- Returns the ISO 639-1 two-letter code for the current language.
+
+
+## navigator.globalization.getLocaleName
+
+Returns the BCP 47 compliant tag for the client's current locale setting.
+
+    navigator.globalization.getLocaleName(successCallback, errorCallback);
+
+### Description
+
+Returns the BCP 47 compliant locale identifier string to the `successCallback`
+with a `properties` object as a parameter. That object should have a `value`
+property with a `String` value. The locale tag will consist of a two-letter lower
+case language code, two-letter upper case country code, and (unspecified) variant
+code, separated by a hyphen.
+
+If there is an error getting the locale, then the `errorCallback`
+executes with a `GlobalizationError` object as a parameter. The
+error's expected code is `GlobalizationError.UNKNOWN_ERROR`.
+
+### Supported Platforms
+
+- Amazon Fire OS
+- Android
+- iOS
+- Windows Phone 8
+
+### Example
+
+When the browser is set to the `en-US` locale, this displays a popup
+dialog with the text `locale: en-US`.
+
+    navigator.globalization.getLocaleName(
+        function (locale) {alert('locale: ' + locale.value + '\n');},
+        function () {alert('Error getting locale\n');}
+    );
+
+### Android Quirks
+
+- Java does not distinguish between a set "langauge" and set "locale," so this
+method is essentially the same as `navigator.globalizatin.getPreferredLanguage()`.
+
+### Windows Phone 8 Quirks
+
+- Returns the two-letter code defined in ISO 3166 for the current country/region.
+
 
 ## navigator.globalization.dateToString
 
@@ -61,7 +155,7 @@ The inbound `date` parameter should be of type `Date`.
 
 If there is an error formatting the date, then the `errorCallback`
 executes with a `GlobalizationError` object as a parameter. The
-error's expected code is `GlobalizationError.FORMATTING\_ERROR`.
+error's expected code is `GlobalizationError.FORMATTING_ERROR`.
 
 The `options` parameter is optional, and its default values are:
 
@@ -80,7 +174,7 @@ The `options.selector` can be `date`, `time` or `date and time`.
 
 ### Example
 
-If the browser is set to the `en\_US` locale, this displays a popup
+If the browser is set to the `en_US` locale, this displays a popup
 dialog with text similar to `date: 9/25/2012 4:21PM` using the default
 options:
 
@@ -124,7 +218,7 @@ the ISO 4217 currency codes, for example 'USD'.
 
 If there is an error obtaining the pattern, then the `errorCallback`
 executes with a `GlobalizationError` object as a parameter. The
-error's expected code is `GlobalizationError.FORMATTING\_ERROR`.
+error's expected code is `GlobalizationError.FORMATTING_ERROR`.
 
 ### Supported Platforms
 
@@ -134,7 +228,7 @@ error's expected code is `GlobalizationError.FORMATTING\_ERROR`.
 
 ### Example
 
-When the browser is set to the `en\_US` locale and the selected
+When the browser is set to the `en_US` locale and the selected
 currency is United States Dollars, this example displays a popup
 dialog with text similar to the results that follow:
 
@@ -178,7 +272,7 @@ the week, depending on the option selected.
 
 If there is an error obtaining the names, then the `errorCallback`
 executes with a `GlobalizationError` object as a parameter. The
-error's expected code is `GlobalizationError.UNKNOWN\_ERROR`.
+error's expected code is `GlobalizationError.UNKNOWN_ERROR`.
 
 The `options` parameter is optional, and its default values are:
 
@@ -197,7 +291,7 @@ The value of `options.item` can be `months` or `days`.
 
 ### Example
 
-When the browser is set to the `en\_US` locale, this example displays
+When the browser is set to the `en_US` locale, this example displays
 a series of twelve popup dialogs, one per month, with text similar to
 `month: January`:
 
@@ -228,13 +322,13 @@ a parameter contains the following properties:
 
 - __timezone__: The abbreviated name of the time zone on the client. _(String)_
 
-- __utc\_offset__: The current difference in seconds between the client's time zone and coordinated universal time. _(Number)_
+- __utc_offset__: The current difference in seconds between the client's time zone and coordinated universal time. _(Number)_
 
-- __dst\_offset__: The current daylight saving time offset in seconds between the client's non-daylight saving's time zone and the client's daylight saving's time zone. _(Number)_
+- __dst_offset__: The current daylight saving time offset in seconds between the client's non-daylight saving's time zone and the client's daylight saving's time zone. _(Number)_
 
 If there is an error obtaining the pattern, the `errorCallback`
 executes with a `GlobalizationError` object as a parameter. The
-error's expected code is `GlobalizationError.PATTERN\_ERROR`.
+error's expected code is `GlobalizationError.PATTERN_ERROR`.
 
 The `options` parameter is optional, and defaults to the following values:
 
@@ -253,7 +347,7 @@ time`.
 
 ### Example
 
-When the browser is set to the `en\_US` locale, this example displays
+When the browser is set to the `en_US` locale, this example displays
 a popup dialog with text such as `pattern: M/d/yyyy h:mm a`:
 
     function checkDatePattern() {
@@ -291,7 +385,7 @@ property with a `Number` value.
 
 If there is an error obtaining the pattern, then the `errorCallback`
 executes with a `GlobalizationError` object as a parameter. The
-error's expected code is `GlobalizationError.UNKNOWN\_ERROR`.
+error's expected code is `GlobalizationError.UNKNOWN_ERROR`.
 
 ### Supported Platforms
 
@@ -302,7 +396,7 @@ error's expected code is `GlobalizationError.UNKNOWN\_ERROR`.
 
 ### Example
 
-When the browser is set to the `en\_US` locale, this displays a
+When the browser is set to the `en_US` locale, this displays a
 popup dialog with text similar to `day: 1`.
 
     navigator.globalization.getFirstDayOfWeek(
@@ -311,42 +405,6 @@ popup dialog with text similar to `day: 1`.
     );
 
 
-Get the string identifier for the client's current locale setting.
-
-    navigator.globalization.getLocaleName(successCallback, errorCallback);
-
-### Description
-
-Returns the locale identifier string to the `successCallback` with a
-`properties` object as a parameter. That object should have a `value`
-property with a `String` value.
-
-If there is an error getting the locale, then the `errorCallback`
-executes with a `GlobalizationError` object as a parameter. The
-error's expected code is `GlobalizationError.UNKNOWN\_ERROR`.
-
-### Supported Platforms
-
-- Amazon Fire OS
-- Android
-- iOS
-- Windows Phone 8
-
-### Example
-
-When the browser is set to the `en\_US` locale, this displays a popup
-dialog with the text `locale: en\_US`.
-
-    navigator.globalization.getLocaleName(
-        function (locale) {alert('locale: ' + locale.value + '\n');},
-        function () {alert('Error getting locale\n');}
-    );
-
-
-### Windows Phone 8 Quirks
-
-- Returns the two-letter code defined in ISO 3166 for the current country/region.
-
 ## navigator.globalization.getNumberPattern
 
 Returns a pattern string to format and parse numbers according to the client's user preferences.
@@ -376,7 +434,7 @@ as a parameter. That object contains the following properties:
 
 If there is an error obtaining the pattern, then the `errorCallback`
 executes with a `GlobalizationError` object as a parameter. The
-error's expected code is `GlobalizationError.PATTERN\_ERROR`.
+error's expected code is `GlobalizationError.PATTERN_ERROR`.
 
 The `options` parameter is optional, and default values are:
 
@@ -393,7 +451,7 @@ The `options.type` can be `decimal`, `percent`, or `currency`.
 
 ### Example
 
-When the browser is set to the `en\_US` locale, this should display a
+When the browser is set to the `en_US` locale, this should display a
 popup dialog with text similar to the results that follow:
 
     navigator.globalization.getNumberPattern(
@@ -427,47 +485,6 @@ Results:
 
 - The `fraction` property is not supported, and returns zero.
 
-## navigator.globalization.getPreferredLanguage
-
-Get the string identifier for the client's current language.
-
-    navigator.globalization.getPreferredLanguage(successCallback, errorCallback);
-
-### Description
-
-Returns the BCP-47 compliant language identifier tag to the `successCallback` 
-with a `properties` object as a parameter. That object should have a `value`
-property with a `String` value.
-
-If there is an error getting the language, then the `errorCallback`
-executes with a `GlobalizationError` object as a parameter. The
-error's expected code is `GlobalizationError.UNKNOWN\_ERROR`.
-
-### Supported Platforms
-
-- Amazon Fire OS
-- Android
-- iOS
-- Windows Phone 8
-
-### Example
-
-When the browser is set to the `en\_US` locale, this should display a
-popup dialog with the text `language: en_US`:
-
-    navigator.globalization.getPreferredLanguage(
-        function (language) {alert('language: ' + language.value + '\n');},
-        function () {alert('Error getting language\n');}
-    );
-
-### Android Quirks
-
-- Returns the ISO 639-1 two-letter language code, upper case ISO 3166-1 
-country code and variant separated by underscores. Examples: "en", "en_US", "_US"
-
-### Windows Phone 8 Quirks
-
-- Returns the ISO 639-1 two-letter code for the current language.
 
 ## navigator.globalization.isDayLightSavingsTime
 
@@ -487,7 +504,7 @@ and `false` indicates that it is not.
 The inbound parameter `date` should be of type `Date`.
 
 If there is an error reading the date, then the `errorCallback`
-executes. The error's expected code is `GlobalizationError.UNKNOWN\_ERROR`.
+executes. The error's expected code is `GlobalizationError.UNKNOWN_ERROR`.
 
 ### Supported Platforms
 
@@ -524,7 +541,7 @@ property with a `String` value.
 
 If there is an error formatting the number, then the `errorCallback`
 executes with a `GlobalizationError` object as a parameter. The
-error's expected code is `GlobalizationError.FORMATTING\_ERROR`.
+error's expected code is `GlobalizationError.FORMATTING_ERROR`.
 
 The `options` parameter is optional, and its default values are:
 
@@ -541,7 +558,7 @@ The `options.type` can be 'decimal', 'percent', or 'currency'.
 
 ### Example
 
-When the browser is set to the `en\_US` locale, this displays a popup
+When the browser is set to the `en_US` locale, this displays a popup
 dialog with text similar to `number: 3.142`:
 
     navigator.globalization.numberToString(
@@ -592,7 +609,7 @@ time`.
 
 If there is an error parsing the date string, then the `errorCallback`
 executes with a `GlobalizationError` object as a parameter. The
-error's expected code is `GlobalizationError.PARSING\_ERROR`.
+error's expected code is `GlobalizationError.PARSING_ERROR`.
 
 ### Supported Platforms
 
@@ -603,7 +620,7 @@ error's expected code is `GlobalizationError.PARSING\_ERROR`.
 
 ### Example
 
-When the browser is set to the `en\_US` locale, this displays a
+When the browser is set to the `en_US` locale, this displays a
 popup dialog with text similar to `month:8 day:25 year:2012`. Note
 that the month integer is one less than the string, as the month
 integer represents an array index.
@@ -638,7 +655,7 @@ as a parameter. That object should have a `value` property with a
 If there is an error parsing the number string, then the
 `errorCallback` executes with a `GlobalizationError` object as a
 parameter. The error's expected code is
-`GlobalizationError.PARSING\_ERROR`.
+`GlobalizationError.PARSING_ERROR`.
 
 The `options` parameter is optional, and defaults to the following
 values:
@@ -656,7 +673,7 @@ The `options.type` can be `decimal`, `percent`, or `currency`.
 
 ### Example
 
-When the browser is set to the `en\_US` locale, this should display a
+When the browser is set to the `en_US` locale, this should display a
 popup dialog with text similar to `number: 1234.56`:
 
     navigator.globalization.stringToNumber(
@@ -674,10 +691,10 @@ An object representing a error from the Globalization API.
 ### Properties
 
 - __code__:  One of the following codes representing the error type _(Number)_
-  - GlobalizationError.UNKNOWN\_ERROR: 0
-  - GlobalizationError.FORMATTING\_ERROR: 1
-  - GlobalizationError.PARSING\_ERROR: 2
-  - GlobalizationError.PATTERN\_ERROR: 3
+  - GlobalizationError.UNKNOWN_ERROR: 0
+  - GlobalizationError.FORMATTING_ERROR: 1
+  - GlobalizationError.PARSING_ERROR: 2
+  - GlobalizationError.PATTERN_ERROR: 3
 - __message__:  A text message that includes the error's explanation and/or details _(String)_
 
 ### Description

http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/693a6f23/src/android/Globalization.java
----------------------------------------------------------------------
diff --git a/src/android/Globalization.java b/src/android/Globalization.java
index 612d731..ca9691e 100644
--- a/src/android/Globalization.java
+++ b/src/android/Globalization.java
@@ -132,24 +132,8 @@ public class Globalization extends CordovaPlugin  {
         return true;
     }
     /*
-     * @Description: Returns the string identifier for the client's current locale setting
-     *
-     * @Return: JSONObject
-     *          Object.value {String}: The locale identifier
-     *
-     * @throws: GlobalizationError.UNKNOWN_ERROR
-     */
-    private JSONObject getLocaleName() throws GlobalizationError{
-        JSONObject obj = new JSONObject();
-        try{
-            obj.put("value",Locale.getDefault().toString());//get the locale from the Android Device
-            return obj;
-        }catch(Exception e){
-            throw new GlobalizationError(GlobalizationError.UNKNOWN_ERROR);
-        }
-    }
-        /*
-     * @Description: Returns a well-formed ITEF BCP 47 language tag representing this localestring identifier for the client's current locale 
+     * @Description: Returns a well-formed ITEF BCP 47 language tag representing
+     * the locale identifier for the client's current locale 
      *
      * @Return: String: The BCP 47 language tag for the current locale
      */
@@ -199,7 +183,28 @@ public class Globalization extends CordovaPlugin  {
         return bcp47Tag.toString();
     }
     /*
-     * @Description: Returns the string identifier for the client's current language
+     * @Description: Returns the BCP 47 Unicode locale identifier for current locale setting
+     * The locale is defined by a language code, a country code, and a variant, separated
+     * by a hyphen, for example, "en-US", "fr-CA", etc.,
+     *
+     * @Return: JSONObject
+     *          Object.value {String}: The locale identifier
+     *
+     * @throws: GlobalizationError.UNKNOWN_ERROR
+     */
+    private JSONObject getLocaleName() throws GlobalizationError{
+        JSONObject obj = new JSONObject();
+        try{
+            obj.put("value", toBcp47Language(Locale.getDefault()));
+            return obj;
+        }catch(Exception e){
+            throw new GlobalizationError(GlobalizationError.UNKNOWN_ERROR);
+        }
+    }
+    /*
+     * @Description: Returns the BCP 47 language tag for the client's 
+     * current language. Currently in Android this is the same as locale,
+     * since Java does not distinguish between locale and language.
      *
      * @Return: JSONObject
      *          Object.value {String}: The language identifier