I want to get the android device language from the app developed using Ionic3, Cordova and Angular4.
How can I get it?
You can use cordova-plugin-globalization which also offers an ionic-native wrapper. It offers a lot of useful methods, but you are probably looking for getPreferredLanguage()
or getLocaleName()
.
Installation:
ionic cordova plugin add cordova-plugin-globalization
npm install --save @ionic-native/globalization
Example:
import { Globalization } from '@ionic-native/globalization';
constructor(private globalization: Globalization) {
this.globalization.getPreferredLanguage()
.then(res => console.log(res))
.catch(e => console.log(e));
}