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
translator_overview [2007/11/07 10:04] – Where the hack is Zotero's metadata format documented? I'll do it. jvossdev:translator_overview [2010/07/18 10:14] – what to do once one has developed one's translator tomrochewiki
Line 4: Line 4:
  
 ===== Step 1: Should I Run? ===== ===== Step 1: Should I Run? =====
-The first thing that a site translator needs to know is whether it should run on a web page.  Every time a Zotero visits any web page at all, Zotero checks the page URL against its translator database to see whether it finds any matching translators.  This operation is extremely quick and is meant only to find a match at the very highest level.  We don't yet care whether the web page has any metadata or search results: we just want to know whether we're in the ballpark.  This scanning operation uses a regular expression.  For example, to determine whether we should run the Amazon.com translator, we search for: <code>^http://(?:www\.)amazon</code>+The first thing that a site translator needs to know is whether it should run on a web page.  Every time a Zotero user visits any web page at all, Zotero checks the page URL against its translator database to see whether it finds any matching translators.  This operation is extremely quick and is meant only to find a match at the very highest level.  We don't yet care whether the web page has any metadata or search results: we just want to know whether we're in the ballpark.  This scanning operation uses a regular expression.  For example, to determine whether we should run the Amazon.com translator, we search for: <code>^http://(?:www\.)amazon</code>
  
 Any page with a URL beginning with <code>http://amazon</code> or <code>http://www.amazon</code> will bind to this translator.  By leaving off ''.com'' we allow this particular translator to to run on any of Amazon's international sites: amazon.ca, amazon.co.jp, amazon.co.uk, amazon.de, and amazon.fr.  Any page with a URL beginning with <code>http://amazon</code> or <code>http://www.amazon</code> will bind to this translator.  By leaving off ''.com'' we allow this particular translator to to run on any of Amazon's international sites: amazon.ca, amazon.co.jp, amazon.co.uk, amazon.de, and amazon.fr. 
Line 32: Line 32:
 ===== Step 4: Put Everything in Its Place ===== ===== Step 4: Put Everything in Its Place =====
 Once we have our metadata, we need only to create a new Zotero item and then populate its fields.  Usually translators perform this task inline with parsing the metadata, so that as each piece of metadata is retrieved, it goes into the appropriate [[Zotero metadata format|Zotero item field]].  Sometimes we might want to add some additional information that does not appear in the metadata or that does not have an appropriate item field in the Zotero case type.  Perhaps we are looking at a journal article and have pulled a clean set of metadata about the article, but we also want to include the article's associated PDF file.  We can tailor the translator to download that file and add it as an attachment to the Zotero item.  Alternatively, we may find a good piece of miscellaneous metadata that we want to keep.  Amazon, for example, provides two release dates for DVD films: the DVD release date and the original theatrical release date.  If we want to include the latter, we can simply add it to the "extra" field so that it is saved along with the rest of the item's metadata. Once we have our metadata, we need only to create a new Zotero item and then populate its fields.  Usually translators perform this task inline with parsing the metadata, so that as each piece of metadata is retrieved, it goes into the appropriate [[Zotero metadata format|Zotero item field]].  Sometimes we might want to add some additional information that does not appear in the metadata or that does not have an appropriate item field in the Zotero case type.  Perhaps we are looking at a journal article and have pulled a clean set of metadata about the article, but we also want to include the article's associated PDF file.  We can tailor the translator to download that file and add it as an attachment to the Zotero item.  Alternatively, we may find a good piece of miscellaneous metadata that we want to keep.  Amazon, for example, provides two release dates for DVD films: the DVD release date and the original theatrical release date.  If we want to include the latter, we can simply add it to the "extra" field so that it is saved along with the rest of the item's metadata.
 +
 +===== Step 5: Contribute Your Translator =====
 +If your new or modified translator would be useful to others, cut'n'paste its code into a post to the [[http://groups.google.com/group/zotero-dev|Zotero developers mailing list]].
 +
dev/translator_overview.txt · Last modified: 2017/11/12 19:53 by 127.0.0.1