How can I make an Ionic application auto change it language based on user device settings

I want to create an Ionic Project where the ionic application’s language on both iOS and android device will auto change to the language based on the user device where they have choose their prefer language in the settings during set-up their phone.

Then you want to read the Capacitor documentation involving getLanguageCode.