Skip to content

Commit

Permalink
Added localisation script. removed obsolete overlay for filter list
Browse files Browse the repository at this point in the history
  • Loading branch information
RealRaven2000 committed Oct 13, 2020
1 parent cec4ceb commit 750ab33
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 48 deletions.
49 changes: 49 additions & 0 deletions chrome/content/i18n.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
var i18n = {
updateString(string) {
let re = new RegExp(this.keyPrefix + "(.+?)__", "g");
return string.replace(re, matched => {
const key = matched.slice(this.keyPrefix.length, -2);
let rv = this.extension
? this.extension.localeData.localizeMessage(key)
: messenger.i18n.getMessage(key);
return rv || matched;
});
},

updateSubtree(node) {
const texts = document.evaluate(
'descendant::text()[contains(self::text(), "' + this.keyPrefix + '")]',
node,
null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
null
);
for (let i = 0, maxi = texts.snapshotLength; i < maxi; i++) {
const text = texts.snapshotItem(i);
if (text.nodeValue.includes(this.keyPrefix)) text.nodeValue = this.updateString(text.nodeValue);
}

const attributes = document.evaluate(
'descendant::*/attribute::*[contains(., "' + this.keyPrefix + '")]',
node,
null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
null
);
for (let i = 0, maxi = attributes.snapshotLength; i < maxi; i++) {
const attribute = attributes.snapshotItem(i);
if (attribute.value.includes(this.keyPrefix)) attribute.value = this.updateString(attribute.value);
}
},

updateDocument(options = {}) {
this.extension = null;
this.keyPrefix = "__MSG_";
if (options) {
if (options.extension) this.extension = options.extension;
if (options.keyPrefix) this.keyPrefix = options.keyPrefix;
}
this.updateSubtree(document);
}
};

44 changes: 2 additions & 42 deletions chrome/content/scripts/qf-filterlist.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* this module is obsolete */
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");

Services.scriptloader.loadSubScript("chrome://quickfolders/content/quickfolders.js", window, "UTF-8");
Expand All @@ -8,56 +9,15 @@ Services.scriptloader.loadSubScript("chrome://quickfolders/content/quickfolders-
Services.scriptloader.loadSubScript("chrome://quickfolders/content/quickfolders-filterList.js", window, "UTF-8");
Services.scriptloader.loadSubScript("chrome://quickfolders/content/overlayFilterList.js", window, "UTF-8");


function onLoad(activatedWhileWindowOpen) {
let layout = WL.injectCSS("chrome://quickfolders/content/filterList.css");

WL.injectElements(`
<window id="filterListDialog">
<label id="qf-FilterCount-n-of-m"
hidden="true"
value="&qf.label.filterCountN_of_M;" />
<label id="qf-FilterCount-items"
hidden="true"
value="&qf.label.filterEntities;" />
<label id="qf-FilterCount-1-item"
hidden="true"
value="&qf.label.filterSingleEntity;" />
<html:input id="qf-Filter"
flex="7"
type="search"
oncommand="QuickFolders.FilterList.onFindFilter(false, true);"
emptytext="&qf.textbox.searchBox.emptyText;"
tooltiptext="&qf.textbox.searchBox.toolTip;"
isempty="true"
timeout="300"
/>
<label id="qf-FilterCount"
flex="1"
/>
<button
id="qf-reorderButtonTop"
insertbefore="reorderUpButton"
label="&qf.button.reorderButtonTop;"
accesskey="&qf.button.reorderButtonTop.accessKey;"
tooltiptext="&qf.button.reorderButtonTop.toolTip;"
oncommand="QuickFolders.FilterList.onTop(event);"
/>
<button
id="qf-reorderButtonBottom"
insertafter="reorderDownButton"
label="&qf.button.reorderButtonBottom;"
accesskey="&qf.button.reorderButtonBottom.accessKey;"
tooltiptext="&qf.button.reorderButtonBottom.toolTip;"
oncommand="QuickFolders.FilterList.onBottom(event);"
/>
</window>
`, ["chrome://quickfolders/locale/overlay.dtd"]);
Expand Down
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"author" : "Axel Grude",
"manifest_version" : 2,
"name" : "QuickFolders",
"description" : "Bookmark your favorite mail folders in Thunderbird.",
"version" : "5.0pre98",
"description" : "__MSG_extensionDescription__",
"version" : "5.0pre100",
"default_locale": "en",
"author": "Axel Grude, Klaus Buecher/opto",
"developer" : {
Expand Down
2 changes: 0 additions & 2 deletions qf-background.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,12 @@ async function main() {
/* not necessary in Tb78+ */
messenger.WindowListener.registerWindow("chrome://messenger/content/messenger.xul", "chrome/content/scripts/qf-messenger.js");
messenger.WindowListener.registerWindow("chrome://messenger/content/messengercompose.xul", "chrome/content/scripts/qf-composer.js");
messenger.WindowListener.registerWindow("chrome://messenger/content/FilterListDialog.xul", "chrome/content/scripts/qf-filterlist.js");
messenger.WindowListener.registerWindow("chrome://messenger/content/SearchDialog.xul", "chrome/content/scripts/qf-searchDialog.js");
messenger.WindowListener.registerWindow("chrome://messenger/content/customizeToolbar.xul", "chrome/content/scripts/qf-customizetoolbar.js");
messenger.WindowListener.registerWindow("chrome://messenger/content/messageWindow.xul", "chrome/content/scripts/qf-messageWindow.js");

messenger.WindowListener.registerWindow("chrome://messenger/content/messenger.xhtml", "chrome/content/scripts/qf-messenger.js");
messenger.WindowListener.registerWindow("chrome://messenger/content/messengercompose.xhtml", "chrome/content/scripts/qf-composer.js");
messenger.WindowListener.registerWindow("chrome://messenger/content/FilterListDialog.xhtml", "chrome/content/scripts/qf-filterlist.js");
messenger.WindowListener.registerWindow("chrome://messenger/content/SearchDialog.xhtml", "chrome/content/scripts/qf-searchDialog.js");
messenger.WindowListener.registerWindow("chrome://messenger/content/customizeToolbar.xhtml", "chrome/content/scripts/qf-customizetoolbar.js");
messenger.WindowListener.registerWindow("chrome://messenger/content/messageWindow.xhtml", "chrome/content/scripts/qf-messageWindow.js");
Expand Down
1 change: 0 additions & 1 deletion release-notes.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
Starting from 0 again, as TbSync suggested.

<ul>
<li class="psa"> I am currently paying somebody to migrate all my Add-on support sites away from the free host on mozdev.org, which is going to close operation end of June. To keep having support sites and ongoing development, please <a href="http://sites.fastspring.com/quickfolders/product/quickfolders?referrer=qf-version-page">buy a license</a> (the migration will cost around $500, so there are some expense I hope to recover from the user community).
Expand Down
2 changes: 1 addition & 1 deletion revision.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
98
100

0 comments on commit 750ab33

Please sign in to comment.