Skip to content

[intl] Add support for adding and removing likely subtags for a locale, as defined in UTS#35 #18344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
stof opened this issue Apr 17, 2025 · 2 comments

Comments

@stof
Copy link
Contributor

stof commented Apr 17, 2025

Description

UTS#35 has algorithms to add or remove likely subtags for a locale. This is useful for instance when wanting to use \Locale::getScript to get the script associated with a locale, to get the likely script instead of getting null when the locale string does not specify a script explicitly.

ICU4X (the Rust implementation of ICU) has a LocaleExpander class with maximize and minimize methods: https://unicode-org.github.io/icu4x/rustdoc/icu/locale/struct.LocaleExpander.html (their implementation mutates the identifier object in place and returns an info about whether it was modified or no, but the PHP implementation should likely return the new string instead as PHP does not use objects for language identifiers anyway).
ICU4C has functions uloc_addLikelySubtags and uloc_minimizeSubtags

It would be great to expose this ICU capability to PHP code.

@youkidearitai
Copy link
Contributor

Thank you very much for feature request. Seems need this. Just a moment please.

@devnexen
Copy link
Member

devnexen commented Apr 19, 2025

@youkidearitai I can have a look unless you really want to do it yourself, since it is related to this feature.

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

No branches or pull requests

3 participants