commit 83d34a9f778c57a43d8e9876ce5eef494c75c2a7
parent ac9d524a9f0fe7a1ff1c5ab353919dac469800e4
Author: Simon Kornblith <simon@simonster.com>
Date: Sat, 11 Dec 2010 07:00:42 +0000
load date strings from Fx dateFormat bundle instead of using citeproc-js
Diffstat:
2 files changed, 34 insertions(+), 41 deletions(-)
diff --git a/chrome/content/zotero/xpcom/cite.js b/chrome/content/zotero/xpcom/cite.js
@@ -372,39 +372,4 @@ Zotero.Cite.makeFormattedBibliography = function(cslEngine, format) {
Zotero.Cite.labels = ["page", "book", "chapter", "column", "figure", "folio",
"issue", "line", "note", "opus", "paragraph", "part", "section", "sub verbo",
- "volume", "verse"];
-
-Zotero.Cite._monthStrings = false;
-Zotero.Cite.getMonthStrings = function(form, locale) {
- if(Zotero.Cite._monthStrings){
- return Zotero.Cite._monthStrings[form];
- } else {
- Zotero.Cite._monthStrings = {"long":[], "short":[]};
-
- var sys = {'xml':new Zotero.CiteProc.CSL.System.Xml.Parsing()};
- if(!locale) locale = Zotero.locale;
-
- var cslLocale = Zotero.CiteProc.CSL.localeResolve(Zotero.locale);
- if(!Zotero.CiteProc.CSL.locale[cslLocale.best]) {
- let localexml = sys.xml.makeXml(Zotero.Cite.System.retrieveLocale(cslLocale.best));
- Zotero.CiteProc.CSL.localeSet.call(Zotero.CiteProc.CSL, sys, localexml, cslLocale.best, cslLocale.best);
- }
-
- var locale = Zotero.CiteProc.CSL.locale[cslLocale.best];
- if(!locale) {
- Zotero.log("No locale "+cslLocale.best+"; using en-US", "warning");
- return Zotero.Cite.getMonthStrings(form, "en-US");
- }
-
- for(let i=1; i<=12; i++) {
- let term = locale.terms["month-"+(i<10 ? "0" : "")+i];
- if(term) {
- Zotero.Cite._monthStrings["long"][i-1] = term["long"];
- Zotero.Cite._monthStrings["short"][i-1] = (term["short"] ? term["short"].replace(".", "", "g") : term["long"]);
- } else {
- Zotero.log("No month "+i+" specified for locale "+cslLocale.best, "warning");
- }
- }
- return Zotero.Cite._monthStrings[form];
- }
-}
-\ No newline at end of file
+ "volume", "verse"];
+\ No newline at end of file
diff --git a/chrome/content/zotero/xpcom/date.js b/chrome/content/zotero/xpcom/date.js
@@ -45,7 +45,35 @@ Zotero.Date = new function(){
this.getLocaleDateOrder = getLocaleDateOrder;
var _localeDateOrder = null;
+ var _months = null;
+ /**
+ * Load dateFormat bundle into _dateFormatsBundle
+ */
+ function _loadDateFormatsBundle() {
+ var src = 'chrome://global/locale/dateFormat.properties';
+ var localeService = Components.classes['@mozilla.org/intl/nslocaleservice;1'].
+ getService(Components.interfaces.nsILocaleService);
+ var appLocale = localeService.getApplicationLocale();
+
+ var bundle =
+ Components.classes["@mozilla.org/intl/stringbundle;1"]
+ .getService(Components.interfaces.nsIStringBundleService).createBundle(src, appLocale);
+
+ _months = {"short":[], "long":[]};
+ for(let i=1; i<=12; i++) {
+ _months.short.push(bundle.GetStringFromName("month."+i+".Mmm"));
+ _months.long.push(bundle.GetStringFromName("month."+i+".name"));
+ }
+ }
+
+ /**
+ * Lazy getter for reading month strings from dateFormat.properties
+ */
+ this.__defineGetter__("months", function() {
+ if(!_months) _loadDateFormatsBundle();
+ return _months;
+ });
/**
* Convert an SQL date in the form '2006-06-13 11:03:05' into a JS Date object
@@ -305,9 +333,9 @@ Zotero.Date = new function(){
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul',
'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
// If using a non-English bibliography locale, try those too
- if (Zotero.locale != 'en-US') {
- months = months.concat(Zotero.Cite.getMonthStrings("short"));
- }
+ //if (Zotero.locale != 'en-US') {
+ months = months.concat(Zotero.Date.months.short);
+ //}
if(!_monthRe) {
_monthRe = new RegExp("^(.*)\\b("+months.join("|")+")[^ ]*(?: (.*)$|$)", "i");
}
@@ -383,7 +411,7 @@ Zotero.Date = new function(){
string += date.part+" ";
}
- var months = Zotero.Cite.getMonthStrings("long");
+ var months = Zotero.Date.months.long;
if(date.month != undefined && months[date.month]) {
// get short month strings from CSL interpreter
string += months[date.month];