[Task] Handle title language properly as part of citoid support for Wikidata
Closed, ResolvedPublic0 Story Points

Description

This is the only remaining thing we need to solve before the first release of the gadget.

When a user adds a reference with it we need to handle the language of the reference title properly. We need to do two things:

  • Guess the default for the selection based on the user language
  • Add the ability for the user to chose the language
Mvolz added a subscriber: Mvolz.Aug 15 2016, 1:14 PM

FYI, you can try to get a particular language by setting the accept-language header in citoid. It doesn't work a lot of the time because it doesn't work in Zotero, and of course it depends on if the resource accepts the accept-language header.

But, for instance, it works with twitter.com and 'de' so you would do:

$.ajax( {
	beforeSend: function (request) {
		request.setRequestHeader('Content-Type', 'application/json');
		request.setRequestHeader('Accept-Language', 'de'); // Use this header to request the resource in the particular language, i.e. 'en', 'de'

	},
	url: ' https://citoid.wikimedia.org/api'
	type: 'GET',
	data: { 
		search: encodeURIComponent('http://twitter.com'),
		format: 'mediawiki'
	},
	dataType: 'json',
	success: function ( citationArray ) {
		doSomething( citationArray );
	},
	error: function ( request, textStatus, errorThrown) {
		alert( 'Status:'  + textStatus +  'Error: ' + errorThrown );
	}
} );

This wasn't documented anywhere before but I just added some:

https://www.mediawiki.org/wiki/Citoid/API#Headers

https://www.mediawiki.org/wiki/Citoid/API#In_a_JavaScript_userscript

aude added a comment.Aug 29 2016, 12:11 PM

code is currently at https://github.com/filbertkm/wikidata-citetool but could be moved to gerrit, differential, or wmde github.

It now sets title language based on user language, but not yet ability for user to change it except after saving the reference. (workign on making this nicer...)

aude added a comment.Aug 29 2016, 12:16 PM

It would be better, ideally, to have language provided by citoid in the backend.

some sources have html lang="en" (or whatever language) in the header. Maybe that could be used?

Also, there are language detection capabilities in elasticsearch and maybe available some other way.

For now, user language with ability to be able to change it is okay to keep things simple.

@Jan_Dittrich can you please add what you discussed with Katie here for the design? And mockups if there are any.

@Lydia_Pintscher: We did not discuss much, I only remarked that two buttons side by side that both insert a reference but resort to different methods are not ideal.

Mvolz moved this task from Backlog to Zotero & External on the Citoid board.Oct 28 2016, 3:19 PM
aude moved this task from Doing to Done on the Wikidata-Sprint board.Jan 3 2017, 1:04 PM
Lydia_Pintscher closed this task as Resolved.Jan 3 2017, 2:38 PM
Jdforrester-WMF set the point value for this task to 0.Jan 10 2017, 11:26 PM