- modifications to citation engine's handling of localized strings

- added the missing integrationDocPrefs.xul file
This commit is contained in:
Simon Kornblith 2006-08-30 04:00:19 +00:00
parent 68c480b7b5
commit 1c21bddbfc
4 changed files with 167 additions and 138 deletions

View file

@ -0,0 +1,20 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://scholar/locale/scholar.dtd">
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&integration.docPrefs.title;" buttons="accept"
ondialogaccept="Scholar_File_Interface_Bibliography.acceptSelection()"
id="scholar-bibliography"
onload="Scholar_File_Interface_Bibliography.init()">
<script src="include.js"/>
<script src="bibliography.js"/>
<hbox>
<label value="&bibliography.style.label;" control="style-menu"/>
<menulist id="style-menu">
<menupopup id="style-popup">
</menupopup>
</menulist>
</hbox>
</dialog>

View file

@ -70,7 +70,7 @@ Scholar.Cite = new function() {
* from the cache * from the cache
*/ */
function _getCSL(cslID) { function _getCSL(cslID) {
if(_lastStyle != cslID) { if(_lastStyle != cslID || Scholar.Prefs.get("cacheTranslatorData") == false) {
// get style // get style
var sql = "SELECT csl FROM csl WHERE cslID = ?"; var sql = "SELECT csl FROM csl WHERE cslID = ?";
var style = Scholar.DB.valueQuery(sql, [cslID]); var style = Scholar.DB.valueQuery(sql, [cslID]);
@ -114,6 +114,14 @@ CSL = function(csl) {
// parse bibliography options, since these will be necessary for // parse bibliography options, since these will be necessary for
// disambiguation purposes even for citations // disambiguation purposes even for citations
this._parseBibliographyOptions(); this._parseBibliographyOptions();
// if no bibliography exists, parse citation element as bibliography
if(!this._bib) {
Scholar.debug("CSL: using citation element");
if(!this._cit) {
this._parseCitationOptions();
}
this._bib = this._cit;
}
} }
/* /*
@ -137,11 +145,11 @@ CSL.prototype.setItems = function(items) {
Scholar.debug("CSL: items set to "+serializedItemString); Scholar.debug("CSL: items set to "+serializedItemString);
if(serializedItemString != this._serializedItemString) { //if(serializedItemString != this._serializedItemString) {
// only re-process if there are new items // only re-process if there are new items
this._serializedItemString = serializedItemString; this._serializedItemString = serializedItemString;
this._preprocessItems(); this._preprocessItems();
} //}
} }
/* /*
@ -182,15 +190,6 @@ CSL.prototype.createCitation = function(items, format) {
* (items is expected to be an array of items) * (items is expected to be an array of items)
*/ */
CSL.prototype.createBibliography = function(format) { CSL.prototype.createBibliography = function(format) {
if(!this._bib) {
// decide whether to parse bibliography, or, if none exists, citation
Scholar.debug("CSL: using citation element");
if(!this._cit) {
this._parseCitationOptions();
}
this._bib = this._cit;
}
// preprocess this._items // preprocess this._items
Scholar.debug("CSL: preprocessing items"); Scholar.debug("CSL: preprocessing items");
this._preprocessItems(); this._preprocessItems();
@ -340,7 +339,7 @@ CSL.prototype._parseLocales = function(termXML) {
// ugh. copy default array. javascript dumb. // ugh. copy default array. javascript dumb.
for(var i in CSL._defaultTerms) { for(var i in CSL._defaultTerms) {
termArray[i] = new Object(); termArray[i] = new Object();
for(var j in CSL._defaulTerms[i]) { for(var j in CSL._defaultTerms[i]) {
if(typeof(CSL._defaultTerms[i]) == "object") { if(typeof(CSL._defaultTerms[i]) == "object") {
termArray[i][j] = [CSL._defaultTerms[i][j][0], termArray[i][j] = [CSL._defaultTerms[i][j][0],
CSL._defaultTerms[i][j][1]]; CSL._defaultTerms[i][j][1]];
@ -352,50 +351,45 @@ CSL.prototype._parseLocales = function(termXML) {
} }
// loop through terms // loop through terms
this._parseTerms(locale.term, termArray["default"]); for each(var term in locale.term) {
// loop through term sets
locale._termSets = new Object();
for each(var termSet in locale["term-set"]) {
var name = termSet.@name.toString();
if(!termArray[name]) {
termArray[name] = new Object();
}
this._parseTerms(termSet.term, termArray[name]);
}
return termArray;
}
CSL.prototype._parseTerms = function(terms, termArray) {
for each(var term in terms) {
var name = term.@name.toString(); var name = term.@name.toString();
if(!name) { if(!name) {
throw("citations cannot be generated: no name defined on term in CSL"); throw("citations cannot be generated: no name defined on term in CSL");
} }
// unless otherwise specified, assume "long" form
var form = term.@form.toString();
if(!form) {
var form = "long";
}
if(!termArray[form]) {
termArray[form] = new Object();
}
var single = term.single.text().toString(); var single = term.single.text().toString();
var multiple = term.multiple.text().toString(); var multiple = term.multiple.text().toString();
if(single || multiple) { if(single || multiple) {
if((single && multiple) // if there's both elements or if((single && multiple) // if there's both elements or
|| !termArray[name]) { // no previously defined value || !termArray[form][name]) { // no previously defined value
termArray[name] = [single, multiple]; termArray[form][name] = [single, multiple];
} else { } else {
if(typeof(termArray[name]) != "object") { if(typeof(termArray[name]) != "object") {
termArray[name] = [termArray[name], termArray[name]]; // if old object was just a single value, make it two copies
termArray[form][name] = [termArray[form][name], termArray[form][name]];
} }
// redefine either single or multiple // redefine either single or multiple
if(single) { if(single) {
termArray[name][0] = single; termArray[form][name][0] = single;
} else { } else {
termArray[name][1] = multiple; termArray[form][name][1] = multiple;
} }
} }
} else { } else {
termArray[name] = term.text().toString(); termArray[form][name] = term.text().toString();
} }
} }
return termArray;
} }
/* /*
@ -558,6 +552,10 @@ CSL.prototype._parseEtAl = function(etAl, bibCitElement) {
* optional array of cs-format * optional array of cs-format
*/ */
CSL.prototype._parseBibliographyOptions = function() { CSL.prototype._parseBibliographyOptions = function() {
if(!this._csl.bibliography.length()) {
return;
}
var bibliography = this._csl.bibliography; var bibliography = this._csl.bibliography;
this._bib = new Object(); this._bib = new Object();
@ -727,24 +725,24 @@ CSL.prototype._getFieldDefaults = function(elementName) {
/* /*
* gets a term, in singular or plural form * gets a term, in singular or plural form
*/ */
CSL.prototype._getTerm = function(term, plural, termSet) { CSL.prototype._getTerm = function(term, plural, form) {
if(!termSet) { if(!form) {
termSet = "default"; form = "long";
} }
if(!this._terms[termSet][term]) { if(!this._terms[form][term]) {
return ""; return "";
} }
if(typeof(this._terms[termSet][term]) == "object") { // singular and plural forms if(typeof(this._terms[form][term]) == "object") { // singular and plural forms
// are available // are available
if(plural) { if(plural) {
return this._terms[termSet][term][1]; return this._terms[form][term][1];
} else { } else {
return this._terms[termSet][term][0]; return this._terms[form][term][0];
} }
} }
return this._terms[termSet][term]; return this._terms[form][term];
} }
/* /*
@ -915,10 +913,10 @@ CSL.prototype._formatLocator = function(identifier, element, number, format) {
} else if(child.name == "text") { } else if(child.name == "text") {
var plural = (identifier && (number.indexOf(",") != -1 var plural = (identifier && (number.indexOf(",") != -1
|| number.indexOf("-") != -1)); || number.indexOf("-") != -1));
string = this._getTerm(child["term-name"], plural); string = this._getTerm(child["term-name"], plural, child["form"]);
} else if(identifier && child.name == "label") { } else if(identifier && child.name == "label") {
var plural = (number.indexOf(",") != -1 || number.indexOf("-") != -1); var plural = (number.indexOf(",") != -1 || number.indexOf("-") != -1);
string = this._getTerm(identifier, plural, child["term-set"]); string = this._getTerm(identifier, plural, child["form"]);
} }
if(string) { if(string) {
@ -1216,7 +1214,7 @@ CSL.prototype._processCreators = function(type, element, creators, format, bibCi
} }
string = authorStrings.join(joinString); string = authorStrings.join(joinString);
} else if(child.name == "label") { } else if(child.name == "label") {
string = this._getTerm(type, (maxCreators != 1), child["term-set"]); string = this._getTerm(type, (maxCreators != 1), child["form"]);
} }

View file

@ -8,77 +8,81 @@
<term name="references">References</term> <term name="references">References</term>
<term name="and">and</term> <term name="and">and</term>
<term name="et-al">et al.</term> <term name="et-al">et al.</term>
<term-set name="locators">
<term name="page"> <!-- LONG LOCATOR FORMS -->
<single>page</single> <term name="page">
<multiple>pages</multiple> <single>page</single>
</term> <multiple>pages</multiple>
<term name="paragraph"> </term>
<single>paragraph</single> <term name="paragraph">
<multiple>paragraph</multiple> <single>paragraph</single>
</term> <multiple>paragraph</multiple>
</term-set> </term>
<term-set name="locators-short"> <term name="volume">volume</term>
<term name="page"> <term name="issue">issue</term>
<single>p</single>
<multiple>pp</multiple> <!-- SHORT LOCATOR FORMS -->
</term> <term name="page" form="short">
<term name="paragraph"> <single>p</single>
<single></single> <multiple>pp</multiple>
<multiple>¶¶</multiple> </term>
</term> <term name="paragraph" form="short">
</term-set> <single></single>
<term-set name="roles"> <multiple>¶¶</multiple>
<term name="editor"> </term>
<single>editor</single> <term name="volume" form="short">vol</term>
<multiple>editors</multiple> <term name="issue" form="short">iss</term>
</term>
<term name="translator"> <!-- LONG ROLE FORMS -->
<single>translator</single> <term name="editor">
<multiple>translators</multiple> <single>editor</single>
</term> <multiple>editors</multiple>
</term-set> </term>
<term-set name="roles-short"> <term name="translator">
<term name="editor"> <single>translator</single>
<single>ed</single> <multiple>translators</multiple>
<multiple>eds</multiple> </term>
</term>
<term name="translator"> <!-- SHORT ROLE FORMS -->
<single>tran</single> <term name="editor" form="short">
<multiple>trans</multiple> <single>ed</single>
</term> <multiple>eds</multiple>
</term-set> </term>
<term-set name="roles-verb"> <term name="translator" form="short">
<term name="editor">edited by</term> <single>tran</single>
<term name="translator">translated by</term> <multiple>trans</multiple>
</term-set> </term>
<term-set name="months">
<term name="month-01">January</term> <!-- VERB ROLE FORMS -->
<term name="month-02">February</term> <term name="editor" form="verb">edited by</term>
<term name="month-03">March</term> <term name="translator" form="verb">translated by</term>
<term name="month-04">April</term>
<term name="month-05">May</term> <!-- LONG MONTH FORMS -->
<term name="month-06">June</term> <term name="month-01">January</term>
<term name="month-07">July</term> <term name="month-02">February</term>
<term name="month-08">August</term> <term name="month-03">March</term>
<term name="month-09">September</term> <term name="month-04">April</term>
<term name="month-10">October</term> <term name="month-05">May</term>
<term name="month-11">November</term> <term name="month-06">June</term>
<term name="month-12">December</term> <term name="month-07">July</term>
</term-set> <term name="month-08">August</term>
<term-set name="months-short"> <term name="month-09">September</term>
<term name="month-01">Jan</term> <term name="month-10">October</term>
<term name="month-02">Feb</term> <term name="month-11">November</term>
<term name="month-03">Mar</term> <term name="month-12">December</term>
<term name="month-04">Apr</term>
<term name="month-05">May</term> <!-- SHORT MOTH FORMS -->
<term name="month-06">Jun</term> <term name="month-01" form="short">Jan</term>
<term name="month-07">Jul</term> <term name="month-02" form="short">Feb</term>
<term name="month-08">Aug</term> <term name="month-03" form="short">Mar</term>
<term name="month-09">Sep</term> <term name="month-04" form="short">Apr</term>
<term name="month-10">Oct</term> <term name="month-05" form="short">May</term>
<term name="month-11">Nov</term> <term name="month-06" form="short">Jun</term>
<term name="month-12">Dec</term> <term name="month-07" form="short">Jul</term>
</term-set> <term name="month-08" form="short">Aug</term>
<term name="month-09" form="short">Sep</term>
<term name="month-10" form="short">Oct</term>
<term name="month-11" form="short">Nov</term>
<term name="month-12" form="short">Dec</term>
</locale> </locale>
</terms> </terms>

View file

@ -1,4 +1,4 @@
-- 62 -- 63
-- Set the following timestamp to the most recent scraper update date -- Set the following timestamp to the most recent scraper update date
REPLACE INTO "version" VALUES ('repository', STRFTIME('%s', '2006-08-15 15:42:00')); REPLACE INTO "version" VALUES ('repository', STRFTIME('%s', '2006-08-15 15:42:00'));
@ -5914,7 +5914,7 @@ function doImport() {
} }
}'); }');
REPLACE INTO "csl" VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2006-08-12 19:22:00', 'APA', REPLACE INTO "csl" VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2006-08-29 23:05:00', 'American Psychological Association',
'<?xml version="1.0" encoding="UTF-8"?> '<?xml version="1.0" encoding="UTF-8"?>
<?oxygen RNGSchema="file:/Users/darcusb/xbiblio/csl/schema/trunk/csl-alt.rnc" type="compact"?> <?oxygen RNGSchema="file:/Users/darcusb/xbiblio/csl/schema/trunk/csl-alt.rnc" type="compact"?>
<style xmlns="http://purl.org/net/xbiblio/csl" class="author-date" xml:lang="en"> <style xmlns="http://purl.org/net/xbiblio/csl" class="author-date" xml:lang="en">
@ -5934,16 +5934,16 @@ REPLACE INTO "csl" VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '200
<name>Johan Kool</name> <name>Johan Kool</name>
<email>johankool@users.sourceforge.net</email> <email>johankool@users.sourceforge.net</email>
</contributor> </contributor>
<updated>2006-08-24T16:30:00+01:00</updated> <updated>2006-08-29T23:05:00+05:00</updated>
</info> </info>
<defaults> <defaults>
<contributor name-as-sort-order="no"> <contributor name-as-sort-order="no">
<name and="symbol" initialize-with="." delimiter=", "/> <name and="symbol" initialize-with="." delimiter=", " delimiter-precedes-last="always"/>
<label term-set="roles-short" prefix=", " text-transform="capitalize" suffix="."/> <label form="short" prefix=", " text-transform="capitalize" suffix="."/>
</contributor> </contributor>
<author name-as-sort-order="all"> <author name-as-sort-order="all">
<name and="symbol" sort-separator=", " initialize-with="." delimiter=", "/> <name and="symbol" sort-separator=", " initialize-with="." delimiter=", " delimiter-precedes-last="always"/>
<label term-set="roles-short" prefix=" (" suffix=".)" text-transform="capitalize"/> <label form="short" prefix=" (" suffix=".)" text-transform="capitalize"/>
<substitute> <substitute>
<choose> <choose>
<editor/> <editor/>
@ -5987,7 +5987,10 @@ REPLACE INTO "csl" VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '200
<et-al min-authors="6" use-first="1" position="subsequent"/> <et-al min-authors="6" use-first="1" position="subsequent"/>
<layout> <layout>
<item> <item>
<author form="short"/> <author form="short">
<name and="symbol" delimiter=", "/>
<label form="short" prefix=", " text-transform="capitalize" suffix="."/>
</author>
<date prefix=", "> <date prefix=", ">
<year/> <year/>
</date> </date>
@ -6031,17 +6034,17 @@ REPLACE INTO "csl" VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '200
<text term-name="in" text-transform="capitalize"/> <text term-name="in" text-transform="capitalize"/>
<editor prefix=" " suffix=","> <editor prefix=" " suffix=",">
<name and="symbol" sort-separator=", " initialize-with="."/> <name and="symbol" sort-separator=", " initialize-with="."/>
<label term-set="roles-short" prefix=" (" suffix=")" text-transform="capitalize"/> <label form="short" prefix=" (" suffix=")" text-transform="capitalize"/>
</editor> </editor>
<translator prefix=" " suffix=","> <translator prefix=" " suffix=",">
<name and="symbol" sort-separator=", " initialize-with="."/> <name and="symbol" sort-separator=", " initialize-with="."/>
<label term-set="roles-short" prefix=" (" suffix=")" text-transform="capitalize"/> <label form="short" prefix=" (" suffix=")" text-transform="capitalize"/>
</translator> </translator>
<titles relation="container" font-style="italic" prefix=" " suffix="."/> <titles relation="container" font-style="italic" prefix=" " suffix="."/>
<titles relation="collection" prefix=" " suffix="."/> <titles relation="collection" prefix=" " suffix="."/>
<publisher prefix=" "/> <publisher prefix=" "/>
<pages prefix=" (" suffix=")"> <pages prefix=" (" suffix=")">
<label term-set="locators-short" text-transform="capitalize" suffix=". "/> <label form="short" text-transform="capitalize" suffix=". "/>
<number/> <number/>
</pages> </pages>
</group> </group>
@ -6073,7 +6076,7 @@ REPLACE INTO "csl" VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '200
</bibliography> </bibliography>
</style>'); </style>');
REPLACE INTO "csl" VALUES('http://purl.org/net/xbiblio/csl/styles/chicago-note.csl', '2006-08-12 19:22:00', 'Chicago (Footnote)', REPLACE INTO "csl" VALUES('http://purl.org/net/xbiblio/csl/styles/chicago-note.csl', '2006-08-29 23:05:00', 'Chicago Manual of Style (Note)',
'<?xml version="1.0" encoding="UTF-8"?> '<?xml version="1.0" encoding="UTF-8"?>
<?oxygen RNGSchema="../schema/trunk/csl.rnc" type="compact"?> <?oxygen RNGSchema="../schema/trunk/csl.rnc" type="compact"?>
<style xmlns="http://purl.org/net/xbiblio/csl" class="note" xml:lang="en"> <style xmlns="http://purl.org/net/xbiblio/csl" class="note" xml:lang="en">
@ -6088,17 +6091,21 @@ REPLACE INTO "csl" VALUES('http://purl.org/net/xbiblio/csl/styles/chicago-note.c
<name>Simon Kornblith</name> <name>Simon Kornblith</name>
<email>simon@simonster.com</email> <email>simon@simonster.com</email>
</contributor> </contributor>
<updated>2006-08-19T17:12:00-05:00</updated> <contributor>
<name>Johan Kool</name>
<email>johankool@users.sourceforge.net</email>
</contributor>
<updated>2006-08-24T16:30:00+01:00</updated>
<summary>The note-without-bibliography variant of the Chicago style.</summary> <summary>The note-without-bibliography variant of the Chicago style.</summary>
</info> </info>
<defaults> <defaults>
<contributor> <contributor>
<label term-set="roles-short" suffix=". " text-transform="lowercase"/> <label form="short" suffix=". " text-transform="lowercase"/>
<name and="text"/> <name and="text" delimiter=", "/>
</contributor> </contributor>
<author> <author>
<name and="text"/> <name and="text" delimiter=", "/>
<label term-set="roles-short" prefix=", " suffix="." text-transform="lowercase"/> <label form="short" prefix=", " suffix="." text-transform="lowercase"/>
<substitute> <substitute>
<choose> <choose>
<editor/> <editor/>