Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
dev:translators:coding [2019/09/30 00:18] – Change GitHub utilities.js link from 4.0 to master dstillmandev:translators:coding [2020/04/22 18:15] – [detectWeb] dstillman
Line 3: Line 3:
 Below we will describe how the ''detect*'' and ''do*'' functions of Zotero [[dev/translators]] can and should be coded. If you are unfamiliar with JavaScript, make sure to check out a [[https://developer.mozilla.org/en/JavaScript/A_re-introduction_to_JavaScript|JavaScript tutorial]] to get familiar with the syntax. In addition to the information on this page, it can often be very informative to look at existing translators to see how things are done. A [[https://www.mediawiki.org/wiki/Citoid/Creating_Zotero_translators|particularly helpful guide]] with up-to-date recommendation on best coding practices is provided by the wikimedia foundation, whose tool Citoid uses Zotero translators. Below we will describe how the ''detect*'' and ''do*'' functions of Zotero [[dev/translators]] can and should be coded. If you are unfamiliar with JavaScript, make sure to check out a [[https://developer.mozilla.org/en/JavaScript/A_re-introduction_to_JavaScript|JavaScript tutorial]] to get familiar with the syntax. In addition to the information on this page, it can often be very informative to look at existing translators to see how things are done. A [[https://www.mediawiki.org/wiki/Citoid/Creating_Zotero_translators|particularly helpful guide]] with up-to-date recommendation on best coding practices is provided by the wikimedia foundation, whose tool Citoid uses Zotero translators.
  
-While translators can be written with any text editor, the Zotero add-on [[dev/translators/scaffold|Scaffold]] can make writing them much easier, as it provides the option to test and troubleshoot translators relatively quickly.+While translators can be written with any text editor, the built-in [[dev/translators/scaffold|Translator Editor]] can make writing them much easier, as it provides the option to test and troubleshoot translators relatively quickly.
  
  
Line 15: Line 15:
  
 <code javascript>function detectWeb(doc, url) { <code javascript>function detectWeb(doc, url) {
-  
  if (url.indexOf("search/results") != -1) {  if (url.indexOf("search/results") != -1) {
  return "multiple";  return "multiple";
- } else if (url.indexOf("content/article") != -1) {+ } 
 + else if (url.indexOf("content/article") != -1) {
  return "journalArticle";  return "journalArticle";
  }  }
 + return false;
 }</code> }</code>
  
dev/translators/coding.txt · Last modified: 2023/08/04 01:14 by dstillman