govdirectory / website

Website repository for Govdirectory - a crowdsourced and fact-checked directory of official governmental online accounts and services.
https://govdirectory.org
Creative Commons Zero v1.0 Universal
48 stars 33 forks source link

Fallback chain for language selection of website (P856) #331

Open Ainali opened 10 months ago

Ainali commented 10 months ago

The feature

Right now, we just take the first language available, but we could choose which language a bit smarter. We need to discuss which order it should be, though. Until we have a fully multilingual website, I suggest the following selection chain.

  1. The language of the user's browser
  2. English
  3. Official language of the place the page is about
  4. The first entry delivered by Wikidata

However, for 1. we need to do it dynamically, so perhaps we should just start with 2-4.

Why?

So that we serve the users more relevant links.

Examples and inspiration

On German Wikivoyage, they have Module:GetP856 to select language. They have this selection chain:

  1. The language of the wiki
  2. English
  3. Official language of the place the article is about
  4. The first entry delivered by Wikidata

So obviously, they have some logic to be inspired by.

Abbe98 commented 10 months ago

For most part we do try to first pick English then a local language (example).

The query that might need some tuning would be organization-optional.rq as it does not take the local language into account. We should fix that by making the language a query parameter:

https://github.com/govdirectory/website/blob/main/queries/organization-optional.rq#L54

Ainali commented 10 months ago

For most part we do try to first pick English then a local language (example).

For labels, yes. As the title suggests, I was thinking specifically for the website.

Ainali commented 10 months ago

Could we set a language in the VALUES in countries.rqto use later? Like this?

VALUES (?uri ?name ?safeName ?description ?lang) {
    (wd:Q34 'Sweden' 'sweden' 'All Swedish government agencies are included.' 'sv')

Sure, it will only be one language per country (and for some countries this might be important), but it is perhaps an improvement anyway.

Abbe98 commented 10 months ago

I'm thinking we make it a comma separated list fi,se,....

Ainali commented 10 months ago

Oh, yes. At least that is putting them in the conversation. I guess in some countries, the order might be debatable and contentious, but that is one step closer.