Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get language of the android device in Ionic3, Cordova and Angular4 application?

I want to get the android device language from the app developed using Ionic3, Cordova and Angular4.

How can I get it?

like image 265
Rajaa Avatar asked Oct 23 '17 18:10

Rajaa


People also ask

How do I use ionic Cordova app on Android?

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.

How do I check my platform on the ionic app?

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.


2 Answers

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.

like image 100
Filip Floryan Avatar answered Nov 11 '22 16:11

Filip Floryan


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

like image 45
mixalbl4 Avatar answered Nov 11 '22 18:11

mixalbl4