1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 12:17:59 +01:00

Localize pageinfo titles.

This commit is contained in:
Kris Maglione
2011-03-07 18:43:13 -05:00
parent 7e2e11f09b
commit 50818caeea
3 changed files with 24 additions and 8 deletions

View File

@@ -302,7 +302,7 @@ var Buffer = Module("buffer", {
* section's output. * section's output.
*/ */
addPageInfoSection: function addPageInfoSection(option, title, func) { addPageInfoSection: function addPageInfoSection(option, title, func) {
this.pageInfo[option] = [func, title]; // TODO: are these reversed intentionally? --djk this.pageInfo[option] = Buffer.PageInfo(option, title, func);
}, },
/** /**
@@ -802,7 +802,7 @@ var Buffer = Module("buffer", {
let title = content.document.title || "[No Title]"; let title = content.document.title || "[No Title]";
let info = template.map("gf", let info = template.map("gf",
function (opt) template.map(buffer.pageInfo[opt][0](), util.identity, ", "), function (opt) template.map(buffer.pageInfo[opt].action(), util.identity, ", "),
", "); ", ");
if (bookmarkcache.isBookmarked(this.URL)) if (bookmarkcache.isBookmarked(this.URL))
@@ -814,8 +814,8 @@ var Buffer = Module("buffer", {
} }
let list = template.map(sections || options["pageinfo"], function (option) { let list = template.map(sections || options["pageinfo"], function (option) {
let [data, title] = buffer.pageInfo[option]; let { action, title } = buffer.pageInfo[option];
return template.table(title, data(true)); return template.table(title, action(true));
}, <br/>); }, <br/>);
dactyl.echo(list, commandline.FORCE_MULTILINE); dactyl.echo(list, commandline.FORCE_MULTILINE);
}, },
@@ -1029,6 +1029,9 @@ var Buffer = Module("buffer", {
scrollTo: deprecated("Buffer.scrollTo", function scrollTo(x, y) content.scrollTo(x, y)), scrollTo: deprecated("Buffer.scrollTo", function scrollTo(x, y) content.scrollTo(x, y)),
textZoom: deprecated("buffer.zoomValue and buffer.fullZoom", function textZoom() config.browser.markupDocumentViewer.textZoom * 100) textZoom: deprecated("buffer.zoomValue and buffer.fullZoom", function textZoom() config.browser.markupDocumentViewer.textZoom * 100)
}, { }, {
PageInfo: Struct("PageInfo", "name", "title", "action")
.localize("title"),
ZOOM_MIN: Class.memoize(function () prefs.get("zoom.minPercent")), ZOOM_MIN: Class.memoize(function () prefs.get("zoom.minPercent")),
ZOOM_MAX: Class.memoize(function () prefs.get("zoom.maxPercent")), ZOOM_MAX: Class.memoize(function () prefs.get("zoom.maxPercent")),
@@ -1827,7 +1830,7 @@ var Buffer = Module("buffer", {
options.add(["pageinfo", "pa"], options.add(["pageinfo", "pa"],
"Define which sections are shown by the :pageinfo command", "Define which sections are shown by the :pageinfo command",
"charlist", "gfm", "charlist", "gfm",
{ get values() [[k, v[1]] for ([k, v] in Iterator(buffer.pageInfo))] }); { get values() values(buffer.pageInfo).toObject() });
options.add(["scroll", "scr"], options.add(["scroll", "scr"],
"Number of lines to scroll with <C-u> and <C-d> commands", "Number of lines to scroll with <C-u> and <C-d> commands",

View File

@@ -1,4 +1,4 @@
# TODO: normalise this debacle of Vim legacy messages # TODO: normalize this debacle of Vim legacy messages
# : are we losing the error code prefixes? --djk # : are we losing the error code prefixes? --djk
abbrev.noSuch = No such abbreviation abbrev.noSuch = No such abbreviation

View File

@@ -1021,8 +1021,14 @@ Module.INIT = {
* @returns {function} The constructor for the new Struct. * @returns {function} The constructor for the new Struct.
*/ */
function Struct() { function Struct() {
let args = Array.slice(arguments); if (!/^[A-Z]/.test(arguments[0]))
const Struct = Class("Struct", StructBase, { var args = Array.slice(arguments, 0);
else {
var className = arguments[0];
args = Array.slice(arguments, 1);
}
const Struct = Class(className || "Struct", StructBase, {
length: args.length, length: args.length,
members: array.toObject(args.map(function (v, k) [v, k])) members: array.toObject(args.map(function (v, k) [v, k]))
}); });
@@ -1075,6 +1081,13 @@ let StructBase = Class("StructBase", Array, {
this.prototype.__defineGetter__(i, function () (this[i] = val.call(this))); this.prototype.__defineGetter__(i, function () (this[i] = val.call(this)));
this.prototype.__defineSetter__(i, function (value) this.prototype.__defineSetter__(i, function (value)
Class.replaceProperty(this, i, value)); Class.replaceProperty(this, i, value));
return this;
},
localize: function localize(key, defaultValue) {
let i = this.prototype.members[key];
Object.defineProperty(this.prototype, i, require("messages").Messages.Localized(defaultValue).init(key, this.prototype));
return this;
} }
}); });