Allow setting a default language
Describe the problem that you'd like solved
The Open Library catalogs books in every language they've ever been published in, which is fantastic, but currently that also means that when I open, say, the books in the Harry Potter series, half of them are in a different language.
Proposal & Constraints
It would be great if users could set a default language (or country), and be treated with the localized (or non-localized) version of that book to where they are.
Whether this is set by country or by language, there might have to be a fallback for books that aren't published in that country / language. This could probably just be the first published version.
Additional context
Stakeholders
The solution may look very similar to this PR (which lets patrons set a "Safe For Work" mode): https://github.com/internetarchive/openlibrary/pull/7775
Hi @cdrini, I'd like to work on this if it's still wanted.
My understanding: people want to pick a default book language, so search results (and carousels, which use search) show an edition in that language first when one exists.
What happens today: search already prefers editions in the request's language (language:{user_lang}^40 in openlibrary/plugins/worksearch/schemes/works.py). So someone who uses the site in English but reads in Spanish can't get Spanish editions first.
Plan, following the safe mode example Mek linked (#7775):
- save a "preferred book language" with the other account preferences (
User.preferences()/save_preferences()inopenlibrary/core/models.py), next tosafe_mode - add the setting to the same settings page as safe mode (
account/privacy.html), using the new language selector component if it fits - when it's set, use it instead of the request language for the edition boost in search
- add tests for the preference and the search params
Questions:
- language only for now, or country too? I'd start with language.
- logged-in users only at first, or also a cookie for logged-out users?
- #12102 and #12003 are about reading the language from the browser. Should the saved setting win over the browser language?