4

For instance I am writing an article in english about revision control that I would like to translate to several other languages. I would like to avoid manually translating the link to the Wikipedia article as the page name can be different in other languages.

Using the Wikipedia API (or other hacks), is it possible to build a language independent URL to the wikipedia article with the language as parameter ?

It doesn't seem so difficult given that:

However I don't find any way or hack to get the particular page in the specified language using simply an URL (with ?lang=fr for instance). Of course it would have been easy if I could rewrite the URL before displaying it, but I am looking for a solution which can be used everywhere (so a simple URL).

Note 1: I know that it may be a bad idea in general, as the same page in a language can be represented by several other pages in a different language. However I will only use that on some very precise subjects which won't have this drawback.
Note 2: If the article doesn't exist in the specified language, a fallback to the original english article would be nice.

1 Answers1

4

Assuming that the article in question has an entry in WikiData you could do this by first finding the corresponding WikiData entry and then using the Special:GoToLinkedPage functionality.

So https://www.wikidata.org/wiki/Special:GoToLinkedPage/frwiki/Q189439 would take you to the French Wikipedia article corresponding to Revision_control on English Wikipedia.

The downside is that if the article doesn't exist in that language you simply end up on Wikidata (see e.g. https://www.wikidata.org/wiki/Special:GoToLinkedPage/dawiki/Q189439)

You would still need to know the WikiData entity though which can be got through the Wikipedia API e.g. https://en.wikipedia.org/w/api.php?action=query&prop=pageprops&format=json&ppprop=wikibase_item&titles=Revision_control

Lokal_Profil
  • 384
  • 1
  • 13
  • @lokal_profil how can I get the wikipedia mobile version? – J.Williams Oct 17 '15 at 20:04
  • Don't think that is possible at the moment. Definitely should be though so I've opened a ticket at https://phabricator.wikimedia.org/T78526 – Lokal_Profil Oct 18 '15 at 09:11
  • My mistake. If you go to the above link on a mobile browser (and haven't opted out of mobile mode) then you end up on the mobile version of the target site (if you haven't opted out there). If you are on a desktop you would need to modify the url yourself. – Lokal_Profil Oct 19 '15 at 10:34