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

Request to Support RFC 5646 (BCP 47) Format for Localized Property #324

Open
1 task done
willysoft opened this issue Jan 3, 2025 · 1 comment
Open
1 task done
Assignees
Labels
type:feature_request Feature request

Comments

@willysoft
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the problem to be solved

Currently, the Localized property only supports ISO 639-1 format, which limits the ability to support different language regions (e.g., zh-TW and zh-CN) simultaneously. Navigator.language returns values in the RFC 5646 (BCP 47) format, which allows more specific language and regional tags. This discrepancy prevents a flexible localization setup that can support multiple variants of the same language, such as zh-TW (Traditional Chinese) and zh-CN (Simplified Chinese), which is important for applications targeting users in both Taiwan and Mainland China.

Suggest a solution

It would be great to extend the Localized property to support RFC 5646 (BCP 47) format, allowing it to handle language tags like zh-TW, zh-CN, and others that specify both language and region. This would enable better compatibility with modern browser behavior and allow localization to be more precise.

Additional context

  • Navigator.language and most modern web APIs return language tags in RFC 5646 format, which is more flexible than the ISO 639-1 standard.
  • Supporting RFC 5646 would also allow applications to serve different content based on both language and regional preferences, ensuring a more tailored user experience.

Key Code Section
The relevant code is located in ./l10n/l10n.js, which handles localization settings and language properties. Adjusting this logic to support RFC 5646 (BCP 47) format should allow multiple language variants to be used simultaneously.

@tarampampam
Copy link
Owner

Could you please make a PR with all the required changes? The feature sounds good to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature_request Feature request
Projects
None yet
Development

No branches or pull requests

2 participants