Globalization obtains information and performs operations specific to the user's locale and timezone.
This short code example shows how to use the core Cordova* globalization plugin in an Intel XDK application.This application does not demonstrate all methods and properties associated with this plugin, please see the complete documentation in the plugin GitHub repo.
To include this plugin: open the Projects tab, expand Plugin Management, click Add Plugins to this Project, and from the Core Plugins list, select Globalization.
Get Preferred Language
Get the string identifier for the client's current language.
navigator.globalization.getPreferredLanguage(successCallback, errorCallback);
Quick example
Copy the below code and paste it into the index.html of a newly created project after you include the Globalization plugin in the Core plugins section of the Plugin Management tool on the Projects tab.
<!DOCTYPE HTML><html><head><title>getPreferredLanguage Example</title><script type="text/javascript" charset="utf-8" src="cordova.js"></script><script type="text/javascript" charset="utf-8"> function checkLanguage() { navigator.globalization.getPreferredLanguage( function (language) {alert('language: ' + language.value + '\n');}, function () {alert('Error getting language\n');} ); }</script></head><body><button onclick="checkLanguage()">Click for language</button></body></html>
How to copy the code?
Hover over the code block above. In the upper-right corner, click the "view source" button. A new window will pops up that shows the code you can easily copy and paste.
Reference:
https://github.com/apache/cordova-plugin-globalization
http://cordova.apache.org/docs/en/3.3.0/cordova/globalization/globalization.html