diff --git a/lib/exe/js.php b/lib/exe/js.php index 17f9c5ae15a96f5c4ee330856fe82ff68a911eb3..c4fd81616b4e8e131d3b91bc92e22f0cd05b94a4 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"; @@ -236,6 +239,34 @@ function js_pluginscripts(){ return $list; } +/** + * 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