Skip to content

v1.1.0

Latest

Choose a tag to compare

@wneel wneel released this 04 Sep 09:52

getDeviceLocaleInfo — the ranked device locales, with language and region kept apart

Full Changelog: v1.0.3...v1.1.0

Current library support:

Support
react-native version >=0.68
Android ✅
iOS ✅
New Architecture ✅
Old Architecture ✅

New:

  • getDeviceLocaleInfo(defaultLocaleInfo?): Promise<DeviceLocaleInfo>, plus the exported DeviceLocaleInfo type. Four fields in one native round trip:

    Field What it is
    locales every locale the user has ranked in their OS settings, most-preferred first, as BCP-47 tags (["en-FR", "fr-FR"])
    languageCode ISO 639-1, lowercase
    regionCode ISO 3166-1 alpha-2 uppercase, or null
    identifier the raw platform identifier, unnormalized, for logs and bug reports
  • The region no longer has to be recovered from the identifier string. On iOS regionCode is NSLocale.currentLocale.countryCode, so a phone set to Language English, Region France reports FR even though its identifier reads en_001@rg=frzzzz — which no string split would have recovered. That was the whole reason this release exists.

  • The ranked list is exposed, so an app can walk the user's own preference order and pick the first language it actually ships, instead of guessing from a single locale.

  • Both roadmap entries are now callable, and the README roadmap no longer lists unshipped intent.

  • Still zero runtime dependencies, still no permissions, and getSimCountryIso() needs none either, so no Expo config plugin is required.

Breaking changes:

  • none. getDeviceLocale(defaultLocale?) is untouched: same signature, same platform reads, same fallback. Upgrading changes nothing you already call.

Note

regionCode does not mean quite the same thing on both platforms, and the README says so on the field itself. iOS has a Region setting genuinely independent of language. Android has none, so it is the top locale's country, falling back to the SIM country only when that locale carries no country at all (a device set to bare de). Because the SIM is a last resort and not a preference, a phone set to German with a French SIM still reports DE.


Total package size:

  • 23.3 kB Brotli ≈ +21.51 %
  • 27.9 kB Gzip ≈ +21.44 %
  • 70.9 kB unpacked ≈ +39.34 %