Don't use "Create Bib" locale for Quick Copy when no explicit locale set

If you'd never set a Quick Copy locale, the option would show as using
the current locale, but Quick Copy itself would use the last locale from
"Create Bibliography from Items". That was a side effect of behavior we
put in place in 2015 so that documents created before 4.0.27 that relied
on the removed bibliographyLocale pref would continue using the migrated
locale, but now that we've had an explicit locale option for years in
the document preferences I think we can stop doing that.
This commit is contained in:
Dan Stillman 2020-03-13 17:06:29 -04:00
parent 3129f35804
commit 9175f9ade8
2 changed files with 27 additions and 1 deletions

View file

@ -689,7 +689,7 @@ Zotero.Style = function (style, path) {
*/
Zotero.Style.prototype.getCiteProc = function(locale, automaticJournalAbbreviations) {
if(!locale) {
var locale = Zotero.Prefs.get('export.lastLocale') || Zotero.locale;
var locale = Zotero.locale;
if(!locale) {
var locale = 'en-US';
}

View file

@ -74,4 +74,30 @@ describe("Zotero.QuickCopy", function() {
assert.isTrue(content.trim().startsWith('@'));
});
});
it("should generate bibliography in default locale if Quick Copy locale not set", async function () {
var item = createUnsavedDataObject('item', { itemType: 'webpage', title: 'Foo' });
item.setField('date', '2020-03-11');
await item.saveTx();
var content = "";
var worked = false;
// Quick Copy locale not set
Zotero.Prefs.clear('export.quickCopy.locale');
// This shouldn't be used
Zotero.Prefs.set('export.lastLocale', 'fr-FR');
await Zotero.Styles.init();
var format = 'bibliography=http://www.zotero.org/styles/apa';
Zotero.Prefs.set(prefName, format);
var { text, html } = Zotero.QuickCopy.getContentFromItems([item], format);
Zotero.debug(text);
Zotero.debug(html);
assert.isTrue(text.startsWith('Foo'));
assert.include(text, 'March');
assert.isTrue(html.startsWith('<div'));
assert.include(html, '<i>Foo</i>');
assert.include(html, 'March');
});
})