I want to get the android device language from the app developed using Ionic3, Cordova and Angular4.
How can I get it?
To run your app, all you have to do is enable USB debugging and Developer Mode on your Android device, then run ionic cordova run android --device from the command line. Enabling USB debugging and Developer Mode can vary between devices, but is easy to look up with a Google search.
Now how to check for the host platform? import { Platform } from 'ionic-angular'; Then check if the platform is ready and use the Promise source to get your platform.
Follow up to David's answer, the Globalization API is deprecated.
With the ECMA Internationalization API now supported on iOS, Android and Windows devices, this plugin is not required any more. * Migrating from this plugin to the ECMA Internationalization API is explained in this Cordova blog post.
For ionic 5 with capacitor:
npm install @capacitor/device
npx cap sync
in code:
import { Device } from '@capacitor/device';
console.log((await Device.getLanguageCode()).value); // en-US
https://capacitorjs.com/docs/apis/device
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With