Skip to content

Map three different language lookups correctly #12102

@tfmorris

Description

@tfmorris

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:

  1. Book text language - Browser language lookup is incorrectly using ISO 639-1 instead of BCP 47 #12003 covers this.
  2. UI localization language for Babel - this should use Babel's negotiate_locale to find the best match
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Lead: @mekarpelesIssues overseen by Mek (Staff: Program Lead) [managed]Needs: BreakdownThis big issue needs a checklist or subissues to describe a breakdown of work. [managed]Needs: ResponseIssues which require feedback from leadPriority: 3Issues that we can consider at our leisure. [managed]State: BlockedWork has stopped, waiting for something (Info, Dependent fix, etc. See comments). [managed]Theme: InternationalizationMaking OpenLibrary work for both foreign-language users and books. [managed]Type: Feature RequestIssue describes a feature or enhancement we'd like to implement. [managed]

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions