From dba1b75edb1263aa34ebda6da7814e90bbb2038a Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Thu, 18 Nov 2010 17:12:10 -0500 Subject: [PATCH] Provide for localized plugin help. --- common/content/dactyl.js | 18 +++++++++++++++++- common/locale/en-US/developer.xml | 11 +++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/common/content/dactyl.js b/common/content/dactyl.js index fb2336d4..e1961c62 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -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 +=

{context.INFO.@summary}

+ context.INFO; + } let help = '\n' + diff --git a/common/locale/en-US/developer.xml b/common/locale/en-US/developer.xml index 32e443f9..f7d16d8a 100644 --- a/common/locale/en-US/developer.xml +++ b/common/locale/en-US/developer.xml @@ -108,16 +108,23 @@
Plugins
+
@lang
When applied to any element under + <plugin>, that element is only visible for a specific + locale.
plugin
The container tag used for describing a plugin.
&tab;@name
The name of the plugin. Used as the plugin's help tag.
&tab;@version
The plugin's version number.
&tab;@href
The plugin's home page.
&tab;@summary
A short description of the plugin, shown in its section head.
+
info
An element with the same + attributes as plugin, which may override the latter for + specific locales
+
project
The project for which this plugin was intended.
&tab;@name
The name of the project (i.e., &dactyl.appName;)
-
&tab;@minVersion
The minimum version of the project for which this plugin is intended to work.
-
&tab;@maxVersion
The maximum version of the project for which this plugin is intended to work.
+
&tab;@min-version
The minimum version of the project for which this plugin is intended to work.
+
&tab;@max-version
The maximum version of the project for which this plugin is intended to work.
author
The plugin's author. May appear more than once.
&tab;@href
The author's home page.