Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
dev:translators_reference_guide [2009/07/26 05:32] – rmzelle | dev:translators_reference_guide [2017/11/12 19:53] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | < | ||
+ | in the process of updating the documentation for | ||
+ | <a href=" | ||
+ | may be outdated in the meantime. Thanks for your understanding.</ | ||
+ | |||
+ | |||
====== Zotero Translators - The Missing Manual ====== | ====== Zotero Translators - The Missing Manual ====== | ||
Line 6: | Line 12: | ||
* [[/ | * [[/ | ||
- | * [[/ | + | * [[/ |
* XPath tools - most translators rely on XPath to extract information from HTML web pages or from XML data files. To quickly construct robust XPaths, consider using one of the following tools: | * XPath tools - most translators rely on XPath to extract information from HTML web pages or from XML data files. To quickly construct robust XPaths, consider using one of the following tools: | ||
* [[http:// | * [[http:// | ||
- | * [[http:// | ||
* [[http:// | * [[http:// | ||
- | ===== Translator Metadata ===== | ||
- | |||
- | Each translator is described by several metadata fields. For the stand-alone javascript translator files in Zotero 2.0, this metadata is included at the beginning of the file in a JSON block, e.g.: | ||
- | |||
- | < | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | }</ | ||
- | |||
- | A description of the metadata fields: | ||
- | |||
- | * **translatorID** \\ The internal ID by which Zotero identifies the translator. It is recommended to use a [[http:// | ||
- | * **translatorType** \\ Four types of translator exist, web translators being the most common. The four types are: import (1), export (2), web (4) and search (8). The value of translatorType should be the number listed after the relevant type. Some translators belong to multiple types. In those cases, the value of translatorType is the sum of the types (e.g. an web/search translator will have a translatorType value of 12). In [[scaffold|Scaffold]] the translatorType is set with checkboxes. | ||
- | * **label** \\ The name of the translator | ||
- | * **creator** \\ The author(s) of the translator | ||
- | * **target** \\ For web translators, | ||
- | * **minVersion** \\ The minimum version of Zotero for which the translators works properly | ||
- | * **maxVersion** \\ The maximum version of Zotero for which the translators works properly | ||
- | * **priority** \\ The priority number is used to determine which translator should be used, if multiple translators are found to be able to translate a certain web page. A lower number indicates a higher priority. | ||
- | * **inRepository** \\ FIXME This probably indicates whether the translator is shipped with Zotero. | ||
- | * **lastUpdated** \\ The date and time when the translator was last modified (format YYYY-MM-DD HH:MM:SS). Scaffold automatically updates this fields when the translator is saved (or run). | ||
===== Zotero.Utilities ===== | ===== Zotero.Utilities ===== | ||
Line 125: | Line 101: | ||
* < | * < | ||
- | Zotero.Utilities.unescapeHTML | + | === unescapeHTML |
+ | **Function description** \\ | ||
https:// | https:// | ||
+ | Zotero.Utilities.prototype.unescapeHTML = function(str) | ||
+ | @type String | ||
- | Zotero.Utilities.parseMarkup | + | Converts all HTML entities in a string into Unicode characters. |
+ | |||
+ | === parseMarkup | ||
+ | **Function description** \\ | ||
https:// | https:// | ||
+ | Zotero.Utilities.prototype.parseMarkup = function(str) | ||
+ | @return {Array} An array of objects with the following form: | ||
+ | { | ||
+ | type: ' | ||
+ | text: "text content", | ||
+ | [ attributes: { key1: val [ , key2: val, ...] } | ||
+ | }</ | ||
- | Zotero.Utilities.isInt | + | Parses a text string for HTML/XUL markup and returns an array of parts. Currently only finds HTML links (<a> tags) |
+ | |||
+ | === isInt === | ||
+ | **Function description** \\ | ||
https:// | https:// | ||
+ | Zotero.Utilities.prototype.isInt = function(x) | ||
+ | @deprecated Use isNaN(parseInt(x)) | ||
+ | @type Boolean | ||
- | Zotero.Utilities.getPageRange | + | Tests if a string is an integer |
+ | |||
+ | === getPageRange | ||
+ | **Function description** \\ | ||
https:// | https:// | ||
+ | Zotero.Utilities.prototype.getPageRange = function(pages) | ||
+ | @param {String} Page range to parse | ||
+ | @return {Integer[]} Start and end pages | ||
- | Zotero.Utilities.lpad | + | Parses a page range |
+ | |||
+ | === lpad === | ||
+ | **Function description** \\ | ||
https:// | https:// | ||
+ | Zotero.Utilities.prototype.lpad = function(string, | ||
+ | @param {String} string String to pad | ||
+ | @param {String} pad String to use as padding | ||
+ | @length {Integer} length Length of new padded string | ||
+ | @type String | ||
- | Zotero.Utilities.itemTypeExists | + | Pads a number or other string with a given string on the left |
+ | |||
+ | === getLocalizedCreatorType === | ||
+ | **Function description** \\ | ||
+ | https:// | ||
+ | Zotero.Utilities.prototype.capitalizeTitle = function(string, | ||
+ | @param {String} string | ||
+ | @param {Boolean} force Forces title case conversion, even if the capitalizeTitles pref is off | ||
+ | @type String | ||
+ | |||
+ | Cleans a title, converting it to title case and replacing " :" with ":" | ||
+ | |||
+ | ==== Other functions ==== | ||
+ | |||
+ | === itemTypeExists | ||
+ | **Function description** \\ | ||
https:// | https:// | ||
+ | Zotero.Utilities.prototype.itemTypeExists = function(type) | ||
+ | @param {String} type Item type | ||
+ | @type Boolean | ||
- | Zotero.Utilities.getCreatorsForType | + | Tests if an item type exists (FIXME: what is the use case for this?) |
+ | |||
+ | === getCreatorsForType | ||
+ | **Function description** \\ | ||
https:// | https:// | ||
+ | Zotero.Utilities.prototype.getCreatorsForType = function(type) | ||
+ | @param {String} type Item type | ||
+ | @return {String[]} Creator types | ||
- | Zotero.Utilities.getLocalizedCreatorType | + | Find valid creator types for a given item type (FIXME: what is the use case for this?) |
+ | |||
+ | === getLocalizedCreatorType | ||
+ | **Function description** \\ | ||
https:// | https:// | ||
+ | Zotero.Utilities.prototype.getLocalizedCreatorType = function(type) | ||
+ | @param {String} type Creator type | ||
+ | @param {String} Localized creator type | ||
+ | @type Boolean | ||
- | Zotero.Utilities.capitalizeTitle | + | Gets a creator type name, localized to the current locale (FIXME: what is the use case for this?) |
- | https:// | + | |
Zotero.Utilities.processAsync | Zotero.Utilities.processAsync | ||
https:// | https:// | ||
+ | |||
+ | To Do: | ||
+ | |||
+ | processDocuments, | ||
===== Item properties ===== | ===== Item properties ===== | ||
Line 159: | Line 202: | ||
Especially for screen scraper translators, | Especially for screen scraper translators, | ||
- | https://www.zotero.org/trac/browser/ | + | http://aurimasv.github.io/z2csl/typeMap.xml |
Note that the different item types make use of different combinations of item fields (e.g. the '' | Note that the different item types make use of different combinations of item fields (e.g. the '' |