summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--inc/template.php28
-rw-r--r--lib/exe/js.php19
2 files changed, 47 insertions, 0 deletions
diff --git a/inc/template.php b/inc/template.php
index d03d3561b..ca1c8d9d5 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -1189,6 +1189,34 @@ function tpl_getLang($id) {
}
/**
+ * Retrieve a language dependent file and pass to xhtml renderer for display
+ * template equivalent of p_locale_xhtml()
+ *
+ * @param string $id id of language dependent wiki page
+ * @return string parsed contents of the wiki page in xhtml format
+ */
+function tpl_locale_xhtml($id) {
+ return p_cached_output(tpl_localeFN($id));
+}
+
+/**
+ * Prepends appropriate path for a language dependent filename
+ */
+function tpl_localeFN($id) {
+ $path = tpl_incdir().'lang/';
+ global $conf;
+ $file = DOKU_CONF.'/template_lang/'.$conf['template'].'/'.$conf['lang'].'/'.$id.'.txt';
+ if (!@file_exists($file)){
+ $file = $path.$conf['lang'].'/'.$id.'.txt';
+ if(!@file_exists($file)){
+ //fall back to english
+ $file = $path.'en/'.$id.'.txt';
+ }
+ }
+ return $file;
+}
+
+/**
* prints the "main content" in the mediamanger popup
*
* Depending on the user's actions this may be a list of
diff --git a/lib/exe/js.php b/lib/exe/js.php
index 06769d895..4b4b598de 100644
--- a/lib/exe/js.php
+++ b/lib/exe/js.php
@@ -96,6 +96,10 @@ function js_out(){
// load JS specific translations
$json = new JSON();
$lang['js']['plugins'] = js_pluginstrings();
+ $templatestrings = js_templatestrings();
+ if(!empty($templatestrings)) {
+ $lang['js']['template'] = $templatestrings;
+ }
echo 'LANG = '.$json->encode($lang['js']).";\n";
// load toolbar
@@ -210,6 +214,21 @@ function js_pluginstrings()
return $pluginstrings;
}
+function js_templatestrings() {
+ global $conf;
+ $templatestrings = array();
+ if (@file_exists(tpl_incdir()."lang/en/lang.php")) {
+ include tpl_incdir()."lang/en/lang.php";
+ }
+ if (isset($conf['lang']) && $conf['lang']!='en' && @file_exists(tpl_incdir()."lang/".$conf['lang']."/lang.php")) {
+ include tpl_incdir()."lang/".$conf['lang']."/lang.php";
+ }
+ if (isset($lang['js'])) {
+ $templatestrings[$conf['template']] = $lang['js'];
+ }
+ return $templatestrings;
+}
+
/**
* Escapes a String to be embedded in a JavaScript call, keeps \n
* as newline