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

[Feature Request] Enhance locale file detection to support Unicode LDML identifiers #12659

Open
baohouse opened this issue Aug 26, 2024 · 1 comment

Comments

@baohouse
Copy link

baohouse commented Aug 26, 2024

Background

In the locales folder, you put files of the message bundle, e.g. en-US.ts, zh-CN.json, or fr.js. The format is generally 2-letter language code (ISO 639-1), followed by base separator - or _, and then an optional 2-letter region code (ISO 3166-1 alpha-2). However, Filipino has a language code of fil, which is 3 letters (ISO 639-2). So naming a file fil.js will not get picked up.

The reason for this is that the code currently uses a regex that assumes 2-letter language code.

const localeFileMath = new RegExp(
`^([a-z]{2})${separator}?([A-Z]{2})?\.(js|json|ts)$`,
);

Proposal

Enhance the code to use a regex that supports Unicode LDML. In addition to supporting 2 or 3-letter language code (e.g. zh, fil, en), it allows for optional script tag, so sr-Latn and sr-Cyrl (Serbian written in Latin and Cyrillic respectively) would be supported, and the region code can either be 2 letters or 3 digits, e.g. es-419 which is Spanish as spoken in Latin America.

Additional context

There is ietf-language-tag-regex library which provides a regex to match on IETF BCP 47 which is the basis for Unicode LDML.

@Jinbao1001
Copy link
Member

what about use tl_PH?

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

5 participants
@baohouse @Jinbao1001 and others