summaryrefslogtreecommitdiff
path: root/lib/exe
diff options
context:
space:
mode:
Diffstat (limited to 'lib/exe')
-rw-r--r--lib/exe/js.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/exe/js.php b/lib/exe/js.php
index 17f9c5ae1..c4fd81616 100644
--- a/lib/exe/js.php
+++ b/lib/exe/js.php
@@ -85,6 +85,9 @@ function js_out(){
print "var notSavedYet = '".js_escape($lang['notsavedyet'])."';";
print "var reallyDel = '".js_escape($lang['del_confirm'])."';";
+ // load JS strings form plugins
+ $lang['js']['plugins'] = js_pluginstrings();
+
// load JS specific translations
$json = new JSON();
echo 'LANG = '.$json->encode($lang['js']).";\n";
@@ -237,6 +240,34 @@ function js_pluginscripts(){
}
/**
+ * Return an two-dimensional array with strings from the language file of each plugin.
+ *
+ * - $lang['js'] must be an array.
+ * - Nothing is returned for plugins without an entry for $lang['js']
+ *
+ * @author Gabriel Birke <birke@d-scribe.de>
+ */
+function js_pluginstrings()
+{
+ global $conf;
+ $pluginstrings = array();
+ $plugins = plugin_list();
+ foreach ($plugins as $p){
+ if (isset($lang)) unset($lang);
+ if (@file_exists(DOKU_PLUGIN."$p/lang/en/lang.php")) {
+ include DOKU_PLUGIN."$p/lang/en/lang.php";
+ }
+ if (isset($conf['lang']) && $conf['lang']!='en' && @file_exists(DOKU_PLUGIN."$p/lang/".$conf['lang']."/lang.php")) {
+ include DOKU_PLUGIN."$p/lang/".$conf['lang']."/lang.php";
+ }
+ if (isset($lang['js'])) {
+ $pluginstrings[$p] = $lang['js'];
+ }
+ }
+ return $pluginstrings;
+}
+
+/**
* Escapes a String to be embedded in a JavaScript call, keeps \n
* as newline
*