Skip to content

ability to get full language tag with unicode extensions - #340

Draft
atlj wants to merge 1 commit into
zoontek:masterfrom
atlj:extended-bcp47
Draft

ability to get full language tag with unicode extensions#340
atlj wants to merge 1 commit into
zoontek:masterfrom
atlj:extended-bcp47

Conversation

@atlj

@atlj atlj commented Jul 30, 2026

Copy link
Copy Markdown

Summary

  • Existing languageTag inside the Locale type ignores any Unicode extensions despite the documentation saying "Full BCP 47 language tag". This is intended.
  • These Unicode Extensions are valuable on languages such as Arabic since they contain the numbering system preference (e.g. arab or latn). The numbering system preference affects how APIs like Intl.NumberFormatter work.
  • This PR adds a new field to `Locale' type called 'languageTagWithExtensions' which returns the tag as is without stripping anything.
  • New field is intentional since changing the existing 'languageTag would be breaking.

Test Plan

What's required for testing (prerequisites)?

  • Android device or emulator
  • iOS device or simulator

What are the steps to test it (after prerequisites)?

Android

  1. Build and install the example app
  2. Go to Settings > System > Languages (might be different based on your OEM)
  3. Click "Add language" and search for "Arabic".
  4. When it asks for region, search "Saudi".
  5. When it asks for the numbering system, pick eastern digits (you can use Google lens to translate the screen)
  6. Go to the app and make sure the first locale returned from getLocales has ar-SA as languageTagWithExtensions
  7. Go back to language settings and set it to Arabic again, this time set the numbering preference to western digits
  8. Get back to app, and make sure first value of getLocales has ar-SA-u-nu-latn (capitalization is not important) as languageTagWithExtensions.

iOS

  1. Build and install the eaxmple app
  2. Go to Settings > General > Language & Region
  3. Set the region to Saudi Arabia
  4. Click Add Language and search for Arabic
  5. Make sure the numbering system is set to latin/western digits (you can use Google lens for translation)
  6. Go to the app and make sure the first locale returned from getLocales has ar-SA as languageTagWithExtensions.
  7. Get back to settings and change the numbering system to Arabic/Eastern digits
  8. Get back to app, and make sure first value of getLocales has ar-SA-u-nu-latn (capitalization is not important) as languageTagWithExtensions.

Compatibility

OS Implemented
iOS
Android

Checklist

  • I have tested this on a device and a simulator
  • I added the documentation in README.md
  • I added a sample use of the API in the example project (example/src/App.js)

@atlj

atlj commented Jul 30, 2026

Copy link
Copy Markdown
Author

iOS isn't working properly yet. We either need to use this Swift-only API which only works >= iOS 16, or link against the ICU library and forward declare.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant