openlibrary icon indicating copy to clipboard operation
openlibrary copied to clipboard

Allow setting a default language

Open omentic opened this issue 5 years ago • 2 comments

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

omentic avatar Jun 10 '21 18:06 omentic

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

mekarpeles avatar Nov 28 '23 23:11 mekarpeles

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() in openlibrary/core/models.py), next to safe_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?

Animesh-Jantwal avatar Oct 31 '26 03:10 Animesh-Jantwal