This version of the documentation is outdated!
Click here for the latest released version.
globalization.getLocaleName
Get the string identifier for the client's current locale setting.
navigator.globalization.getLocaleName(successCB, errorCB);
Description
It returns the locale identifier string to the successCB callback 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 errorCB callback is invoked with a GlobalizationError object as a parameter. The expected code for this error is GlobalizationError.UNKNOWN_ERROR.
Supported Platforms
- Android
- BlackBerry WebWorks (OS 5.0 and higher)
- iPhone
Quick Example
In the case when the browser is set to the en_US locale, this should display 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');}
);
Full Example
<!DOCTYPE HTML>
<html>
<head>
<title>Cordova</title>
<script type="text/javascript" charset="utf-8" src="cordova-2.2.0.js"></script>
<script type="text/javascript" charset="utf-8">
function checkLocale() {
navigator.globalization.getLocaleName(
function (locale) {alert('locale: ' + locale.value + '\n');},
function () {alert('Error getting locale\n');}
);
}
</script>
</head>
<body>
<button onclick="checkLocale()">Click for locale</button>
</body>
</html>