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

Provide for localized plugin help.

This commit is contained in:
Kris Maglione
2010-11-18 17:12:10 -05:00
parent b01dde9b24
commit dba1b75edb
2 changed files with 26 additions and 3 deletions

View File

@@ -485,9 +485,25 @@ const Dactyl = Module("dactyl", {
let body = XML();
for (let [, context] in Iterator(plugins.contexts))
if (context && context.INFO instanceof XML)
if (context && context.INFO instanceof XML) {
let info = context.INFO;
if (info.*.@lang.length()) {
let langs = set([String(a) for each (a in info.*.@lang)]);
let lang = [window.navigator.language,
window.navigator.language.replace(/-.*/, ""),
"en", "en-US", info.*.@lang[0]
].filter(function (l) set.has(langs, l))[0];
info.* = info.*.(function::attribute("lang").length() == 0 || @lang == lang);
for each (let elem in info.NS::info)
for each (let attr in ["@name", "@summary", "@href"])
if (elem[attr].length())
info[attr] = elem[attr];
}
body += <h2 xmlns={NS.uri} tag={context.INFO.@name + '-plugin'}>{context.INFO.@summary}</h2> +
context.INFO;
}
let help =
'<?xml version="1.0"?>\n' +