Page MenuHomePhabricator

[Task] Handle title language properly as part of citoid support for Wikidata
Closed, ResolvedPublic0 Estimated 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

Event Timeline

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

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...)

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.