Capacitor plugin for getting native device locale
The Capacitor Device Locale package is a comprehensive solution that enables developers to effortlessly obtain the device locale information from both iOS and Android platforms. With its robust capabilities, this package simplifies the process of retrieving locale data. By integrating this package into your application, you can efficiently access and utilize device-specific locale information.
npm install capacitor-device-locale
npx cap sync
Device locale plugin.
getDeviceLocale() => Promise<DeviceLocale>
Get the device locale.
Returns: Promise<DeviceLocale>
Prop | Type | Description |
---|---|---|
regionCode |
string |
The region code of the device locale. Example: "US" |
country |
string |
The country of the device locale. Example: "United States" |
languageCode |
string |
The language code of the device locale. Example: "en" |
language |
string |
The language of the device locale. Example: "English" |
currencySymbol |
string |
The symbol used for the currency in the device locale. Example: "$" |
currencyCode |
string |
The currency code of the device locale. Example: "USD" |
currencyName |
string |
The name of the currency in the device locale. Example: "US Dollar" |
timezone |
string |
The timezone of the device locale. Example: "America/New_York" |
import { getDeviceLocale, DeviceLocale } from 'capacitor-device-locale';
async function getDeviceLocaleInformation() {
try {
const deviceLocale: DeviceLocale = await getDeviceLocale();
console.log('Device Locale:', deviceLocale);
// Perform operations with the device locale
} catch (error) {
console.error('Error retrieving device locale:', error);
// Handle error
}
}
getDeviceLocaleInformation();