aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor <pashev.igor@gmail.com>2010-11-10 13:54:03 +0300
committerIgor <pashev.igor@gmail.com>2010-11-10 13:54:03 +0300
commit67f72f1a617371b2ea1a235872315120ea1683f5 (patch)
treed866cdd2abad724b078bac6cffc37d2b4470874c
parent8fce6c7d3d5a661b87ed21fe9f3ed6675ba74eb5 (diff)
downloaddokuwiki-plugin-papers-67f72f1a617371b2ea1a235872315120ea1683f5.tar.gz
Support for Translate plugin
-rw-r--r--conf/default.php1
-rw-r--r--syntax.php30
2 files changed, 31 insertions, 0 deletions
diff --git a/conf/default.php b/conf/default.php
index 897b755..e68a413 100644
--- a/conf/default.php
+++ b/conf/default.php
@@ -12,4 +12,5 @@ $conf['filetypes'] = array('PDF', 'DjVu', 'PS', 'TIFF');
$conf['papers'] = 'публикации'; // Wiki page with bibtex data
$conf['grants'] = 'гранты';
$conf['purge-cache'] = true;
+$conf['languages'] = 'ru, en';
diff --git a/syntax.php b/syntax.php
index b608ab1..a9260ee 100644
--- a/syntax.php
+++ b/syntax.php
@@ -24,6 +24,16 @@ require_once (DOKU_PLUGIN . 'papers/bibtex.php');
class syntax_plugin_papers extends DokuWiki_Syntax_Plugin
{
+ protected $langs_rx = '';
+
+ function syntax_plugin_papers()
+ {
+ //print($this->getConf('languages'));
+ $l = preg_replace('/\W+?\s*/u', '|', mb_strtolower($this->getConf('languages')));
+ $this->langs_rx = '(' . $l . ')';
+ //print ($this->langs_rx . "\n");
+ }
+
function getType() { return 'protected'; }
function getPType() { return 'block'; } // http://www.dokuwiki.org/devel:syntax_plugins#ptype
@@ -151,9 +161,27 @@ class syntax_plugin_papers extends DokuWiki_Syntax_Plugin
return p_render('xhtml', p_get_instructions($text), $info);
}
+ function getLangPart($id)
+ {
+ if (preg_match('/^' . $this->langs_rx . '/', $id, $match))
+ {
+ return $match[1];
+ }
+ return '';
+ }
function format_bibtex(&$bibtex, $options = array())
{
+ global $ID;
+ global $conf;
+
+ $save_lang = $this->getLangPart($ID);
+ if (!empty($save_lang))
+ {
+ $save_lang = $conf['lang'];
+ $conf['lang'] = $this->getLangPart($ID);
+ }
+
$res = '';
$year = ''; $year_prev = '';
$type = ''; $type_prev = '';
@@ -247,6 +275,8 @@ class syntax_plugin_papers extends DokuWiki_Syntax_Plugin
$res .= "</ol>\n";
+
+ if (!empty($save_lang)) $conf['lang'] = $save_lang;
return $res;
}
}