Skip to content
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

Accept Unicode extensions in localized name subkeys #1162

Open
1ec5 opened this issue Jan 29, 2025 · 0 comments
Open

Accept Unicode extensions in localized name subkeys #1162

1ec5 opened this issue Jan 29, 2025 · 0 comments

Comments

@1ec5
Copy link

1ec5 commented Jan 29, 2025

The code for validating name:*=* keys rejects extension syntaxes that are allowed under BCP 47.

For example, this peak in Hong Kong has name:en-t-zh=* set to an English translation of a Chinese name. While a user is unlikely to specifically ask for a map labeled by mode of derivation, they might be interested in labels that take one side or another in a geopolitical dispute. This lake whose name is disputed between two U.S. states. I’ve tagged each state’s recognized name in name:en-u-sd-usnc=* and name:en-u-sd-usva=*, using Unicode subdivision identifiers. This syntax is also being suggested for a more prominent dispute in current events.

These keys fail the test because it doesn’t account for the one-letter -t- or -u- extension marker:

.compile("^name:[a-z]{2,3}(-[A-Z][a-z]{3})?([-_](x-)?[a-z]{2,})?(-([A-Z]{2}|\\d{3}))?$")

Names in Gallo are tagged name:fr-x-gallo=* because no ISO 639 code has been assigned yet. This does pass because we’re specifically looking for -x-.

Instead of continuing to patch this homegrown regular expression, we could look around for more comprehensive ones such as this JavaScript implementation.

@1ec5 1ec5 changed the title Accept Unicode extensions in localized name subkeys Accept extensions in localized name subkeys Jan 29, 2025
@1ec5 1ec5 changed the title Accept extensions in localized name subkeys Accept Unicode extensions in localized name subkeys Jan 29, 2025
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

No branches or pull requests

1 participant