parent
5c1f6d065d
commit
d6d9979f19
2 changed files with 23 additions and 2 deletions
18
chrome/content/zotero/dateOverrides.js
Normal file
18
chrome/content/zotero/dateOverrides.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* eslint-disable no-extend-native */
|
||||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
let originalToLocaleString = Date.prototype.toLocaleString;
|
||||
Date.prototype.toLocaleString = function (locales, options) {
|
||||
if (locales === undefined || (Array.isArray(locales) && !locales.length)) {
|
||||
locales = Services.locale.requestedLocales;
|
||||
}
|
||||
return originalToLocaleString.call(this, locales, options);
|
||||
};
|
||||
|
||||
let originalToLocaleDateString = Date.prototype.toLocaleDateString;
|
||||
Date.prototype.toLocaleDateString = function (locales, options) {
|
||||
if (locales === undefined || (Array.isArray(locales) && !locales.length)) {
|
||||
locales = Services.locale.requestedLocales;
|
||||
}
|
||||
return originalToLocaleDateString.call(this, locales, options);
|
||||
};
|
|
@ -221,6 +221,8 @@ XPCOMUtils.defineLazyModuleGetters(ZoteroContext.prototype, {
|
|||
* components may not have yet been initialized.
|
||||
*/
|
||||
function makeZoteroContext() {
|
||||
var subscriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader);
|
||||
|
||||
if(zContext) {
|
||||
// Swap out old zContext
|
||||
var oldzContext = zContext;
|
||||
|
@ -232,10 +234,11 @@ function makeZoteroContext() {
|
|||
} else {
|
||||
zContext = new ZoteroContext();
|
||||
zContext.Zotero = function() {};
|
||||
|
||||
// Override Date prototype to follow Zotero configured locale #3880
|
||||
subscriptLoader.loadSubScript("chrome://zotero/content/dateOverrides.js");
|
||||
}
|
||||
|
||||
var subscriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader);
|
||||
|
||||
// Load zotero.js first
|
||||
subscriptLoader.loadSubScript("chrome://zotero/content/xpcom/" + xpcomFilesAll[0] + ".js", zContext, 'utf-8');
|
||||
|
||||
|
|
Loading…
Reference in a new issue