cordova-plugin-locale
v2.0.2
Published
Cordova Plugin used for retrieving Locale info
Downloads
16
Maintainers
Readme
title: Locale description: Get locale information.
cordova-plugin-locale
This plugin defines a global Locale
object, which describes the device's locale info like current language, preferred languages and region.
Although the object is in the global scope, it is not available until after the deviceready
event.
Installation
cordova plugin add cordova-plugin-locale
Properties
- Locale.language
- Locale.preferredLanguages
- Locale.region
Locale.language
Get the current language on the device.
Supported Platforms
- Android
- iOS
Quick Example
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log(Locale.language);
}
Locale.preferredLanguages
Get the preferred languages on the device. These are the list of languages the user has picked for the devices.
Supported Platforms
- Android
- iOS
Quick Example
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
for(let language of Locale.preferredLanguages){
console.log(language);
}
}
Locale.region
Get the device region.
Supported Platforms
- Android
- iOS
Quick Example
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log(Locale.region);
}