erickguan / ffi-icu

FFI wrappers for ICU. MRI extension with the dynamic C library.
https://github.com/erickguan/ffi-icu
MIT License
35 stars 22 forks source link

Display locale name with alternative territory name #67

Closed damiann closed 1 year ago

damiann commented 1 year ago

Adding a new method that returns a locale's display name with a short alternative territory name. The ICU library provides the uldn_openForContext() function that helps you to specify different types of context you want to display the locale. This change only adds the display context for lengths UDISPCTX_LENGTH_FULL and UDISPCTX_LENGTH_SHORT. There are other display context options available from ICU that can be easily added to the DISPLAY_CONTEXT constant.

Currently, this is the best option we have to display alt-short names that are available in CLDR. There is an open ICU ticket (ICU-8462) from 2018 to add alternative display name variants for locale and territory, but unsure how long it will be until it's implemented and available.

Examples of alternative names: Screenshot 2023-10-30 at 3 29 51 PM

Screenshot 2023-10-30 at 3 30 40 PM

CLDR Territory data example

ICU References

lwelti commented 1 year ago

👏