-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Feature Request
Problem / Opportunity
There are (at least) three different mappings which need to be made, independently, from the user's browser's language settings, taking into account their language preferences in priority order:
- Book text language - Browser language lookup is incorrectly using ISO 639-1 instead of BCP 47 #12003 covers this.
- UI localization language for Babel - this should use Babel's
negotiate_localeto find the best match - Preferred Wikipedia link - I suspect Wikipedia has an algorithm / lookup to do this, but it would require investigation
As an example, consider zh-HK and zh-TW:
BCP 47 code: zh-HK
Book language codes: cmn + chi (chi is a macro language code for Chinese, while cmn refers to Mandarin Chinese)
Wikipedia code: zh (Chinese Wikipedia)
BCP 47 code: zh-TW
Book language codes: yue + chi
Wikipedia code: zh-yue? (Cantonese Wikipedia is much smaller than Chinese, so zh might be a better recommendation)
Unfortunately, the current implementation conflates these three mappings. It also only considers the first language in the Accept-Language header, when the user may have a localization that's supported and preferred to English as their second or third choice. eg. pt-BR, pt, es-419, en
Proposal
The full browser Accept-Language info should be retained for use in these mappings and for future uses like identifying locales which share a common language across multiple nations, such as Portugese Brazilian (pt-BR) or Latin American Spanish (es-419).
Babel's Locale.negotiate_locale should be used to find best matches so that more than the first locale/language is considered.
Breakdown
Implementation Details (for maintainers)
Related files
Refer to this map of common Endpoints:
*
Requirements Checklist
Checklist of requirements that need to be satisfied in order for this issue to be closed:
- [ ]
Stakeholders
Instructions for Contributors
- Before creating a new branch or pushing up changes to a PR, please first run these commands to ensure your repository is up to date, as the pre-commit bot may add commits to your PRs upstream.