Load DTD strings lazily (#4664)
This commit is contained in:
parent
dbeb1f167c
commit
af3602124b
1 changed files with 16 additions and 11 deletions
|
@ -79,17 +79,6 @@ Zotero.Intl = new function () {
|
|||
Zotero.arrowPreviousKey = Zotero.rtl ? 'ArrowRight' : 'ArrowLeft';
|
||||
Zotero.arrowNextKey = Zotero.rtl ? 'ArrowLeft' : 'ArrowRight';
|
||||
|
||||
this.strings = {};
|
||||
const intlFiles = ['zotero.dtd', 'preferences.dtd', 'mozilla/editMenuOverlay.dtd'];
|
||||
for (let intlFile of intlFiles) {
|
||||
let localeXML = Zotero.File.getContentsFromURL(`chrome://zotero/locale/${intlFile}`);
|
||||
let regexp = /<!ENTITY ([^\s]+)\s+"([^"]+)/g;
|
||||
let regexpResult;
|
||||
while (regexpResult = regexp.exec(localeXML)) {
|
||||
this.strings[regexpResult[1]] = regexpResult[2];
|
||||
}
|
||||
}
|
||||
|
||||
// Provide synchronous access to Fluent strings for getString()
|
||||
ftl = new Localization([
|
||||
'branding/brand.ftl',
|
||||
|
@ -101,6 +90,22 @@ Zotero.Intl = new function () {
|
|||
};
|
||||
|
||||
|
||||
ChromeUtils.defineLazyGetter(this, 'strings', () => {
|
||||
const intlFiles = ['zotero.dtd', 'preferences.dtd', 'mozilla/editMenuOverlay.dtd'];
|
||||
|
||||
let strings = [];
|
||||
for (let intlFile of intlFiles) {
|
||||
let localeXML = Zotero.File.getContentsFromURL(`chrome://zotero/locale/${intlFile}`);
|
||||
let regexp = /<!ENTITY ([^\s]+)\s+"([^"]+)/g;
|
||||
let regexpResult;
|
||||
while ((regexpResult = regexp.exec(localeXML))) {
|
||||
strings[regexpResult[1]] = regexpResult[2];
|
||||
}
|
||||
}
|
||||
return strings;
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @param {String} name
|
||||
* @param {String[]} [params=[]] - Strings to substitute for placeholders
|
||||
|
|
Loading…
Reference in a new issue