Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected behavior / Destination is Wikimedia Commons / Destination should be Wikipedia article #21

Open
urban-06421 opened this issue Dec 13, 2021 · 6 comments

Comments

@maxlath
Copy link
Owner

maxlath commented Dec 14, 2021

The hub looks at the accept-language header to determine your favorite language, with English as default value. In your case, there would be several ways to get the desired page:

  • set the accept-language header to pl: curl -I -H 'accept-language: pl' https://hub.toolforge.org/Q26693912
  • set the lang query string parameter to pl: curl -I https://hub.toolforge.org/Q26693912?lang=pl
  • set the site query string parameter to wp to indicate that you prefer a Wikipedia page, whatever the language: curl -I https://hub.toolforge.org/Q26693912?site=wp

@urban-06421
Copy link
Author

Thanks

https://hub.toolforge.org/

Default

By default, the destination is Wikipedia in the user language, which is guessed from the request accept-language header, falling back to English if the language header can't be found or the Wikipedia page doesn't exist in this language.

I thought, the default destination Wikipedia remains as the default destination even when the language header doesn't fit to the existing Wikipedia page.
In the case of Q26693912 the hub redirects not to the only existing polish Wikipedia page but changes the default destination to Wikimedia Commons and redirects to Wikimedia Commons.

Another example: https://www.wikidata.org/wiki/Q26693912 = Īle (latvian settlement) 4 WP-entries (et, lt, lv, ru)
accept-language header = de, no existing English page
Request: https://hub.toolforge.org/Q13416642
Redirection: https://et.wikipedia.org/wiki/%C4%AAle

In the case of Q13416642 the hub redirects to the estonian WP-page. Why?

Is it possible to customize the fallback chain like:
https://hub.toolforge.org/Q13416642&fallback=https%3A%2F%2Fhub.toolforge.org%2FQ13416642?s=wp&l=lv
If the accept-language header is "de" and there are no german or english pages in Wikipedia, redirect to the latvian (lv) page, because the town Īle is located in Latvia.

The easy solution: https://hub.toolforge.org/Q13416642?s=wp&l=de,en,lv
But this customized request will not work if the request will be sent from France or Italy with an accept-language header "fr" or "it".

@maxlath
Copy link
Owner

maxlath commented Dec 14, 2021

In the case of Q13416642 the hub redirects to the estonian WP-page. Why?

I guess that's because that's the first sitelink alphabetically, so in absence of a matching preferred language, that's the next best thing

@urban-06421
Copy link
Author

Hi maxlath and thank you!

Is it possible to customize the redirection of Wikidata Q13416642 (= Īle Town in Latvia, WP-pages et, lv, lt, ru)
like https://hub.toolforge.org/Q13416642?s=wp&l=*,en,lv

  • = accept-language header

Desired behaviour: Redirect Q13416642 to Wikipedia-Page, in absence of a matching preferred language *
fallback to the english version and if this fails to the latvian version of Wikipedia.

maxlath added a commit that referenced this issue Jan 13, 2022
@maxlath
Copy link
Owner

maxlath commented Jan 13, 2022

I gave it a try in 232dcde: you should now be able to do that with https://hub.toolforge.org/Q13416642?s=wp&l=auto,en,lv

@urban-06421
Copy link
Author

urban-06421 commented Jan 17, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants