Skip to content

Instantly share code, notes, and snippets.

@spaeps
Created May 7, 2012 21:36
Show Gist options
  • Save spaeps/2630624 to your computer and use it in GitHub Desktop.
Save spaeps/2630624 to your computer and use it in GitHub Desktop.
Add translate support to wiki:site_notice for the vector dokuwiki template
diff -aur vector/conf/default.php vector.patched/conf/default.php
--- vector/conf/default.php 2011-12-10 18:15:53.000000000 +0100
+++ vector.patched/conf/default.php 2012-05-07 19:15:39.162547220 +0200
@@ -42,8 +42,9 @@
$conf["vector_discuss_ns"] = ":talk:"; //namespace to use for discussion page storage
//site notice
-$conf["vector_sitenotice"] = true; //TRUE: use/show sitenotice
-$conf["vector_sitenotice_location"] = ":wiki:site_notice"; //page/article used to store the sitenotice
+$conf["vector_sitenotice"] = true; //TRUE: use/show sitenotice
+$conf["vector_sitenotice_location"] = ":wiki:site_notice"; //page/article used to store the sitenotice
+$conf["vector_sitenotice_translate"] = true; //TRUE: load translated site notice if translation plugin is available (see <http://www.dokuwiki.org/plugin:translation>)
//navigation
$conf["vector_navigation"] = true; //TRUE: use/show navigation
diff -aur vector/conf/metadata.php vector.patched/conf/metadata.php
--- vector/conf/metadata.php 2011-12-10 18:15:53.000000000 +0100
+++ vector.patched/conf/metadata.php 2012-05-07 19:16:20.756523901 +0200
@@ -42,8 +42,9 @@
$meta["vector_discuss_ns"] = array("string", "_pattern" => "/^:.{1,}:$/");
//site notice
-$meta["vector_sitenotice"] = array("onoff");
-$meta["vector_sitenotice_location"] = array("string");
+$meta["vector_sitenotice"] = array("onoff");
+$meta["vector_sitenotice_location"] = array("string");
+$meta["vector_sitenotice_translate"] = array("onoff");
//navigation
$meta["vector_navigation"] = array("onoff");
diff -aur vector/lang/en/settings.php vector.patched/lang/en/settings.php
--- vector/lang/en/settings.php 2011-12-10 18:15:53.000000000 +0100
+++ vector.patched/lang/en/settings.php 2012-05-07 19:13:37.730669331 +0200
@@ -40,8 +40,9 @@
$lang["vector_discuss_ns"] = "If yes, use following ':namespace:' as root for discussions:";
//site notice
-$lang["vector_sitenotice"] = "Show site wide notice?";
-$lang["vector_sitenotice_location"] = "If yes, use following wiki page for the site wide notice:";
+$lang["vector_sitenotice"] = "Show site wide notice?";
+$lang["vector_sitenotice_location"] = "If yes, use following wiki page for the site wide notice:";
+$lang["vector_sitenotice_translate"] = "If yes and <a href=\"http://www.dokuwiki.org/plugin:translation\">Translation plugin</a> available: load language specific site notice?<br />The wiki page of the translated site notice is [value of 'vector_sitenotice_location']_[iso lang code] (e.g. ':wiki:site_notice_de').";
//navigation
$lang["vector_navigation"] = "Show navigation?";
diff -aur vector/main.php vector.patched/main.php
--- vector/main.php 2011-12-10 18:15:53.000000000 +0100
+++ vector.patched/main.php 2012-05-07 19:26:29.345935542 +0200
@@ -526,18 +526,40 @@
html_msgarea();
//show site notice
if (tpl_getConf("vector_sitenotice")){
+ //detect wiki page to load as content
+ if (!empty($transplugin) &&
+ is_object($transplugin) &&
+ tpl_getConf("vector_sitenotice_translate")){
+ //translated navigation?
+ $transplugin_langcur = $transplugin->hlp->getLangPart(cleanID(getId())); //current language part
+ $transplugin_langs = explode(" ", trim($transplugin->getConf("translations"))); //available languages
+ if (empty($transplugin_langs) ||
+ empty($transplugin_langcur) ||
+ !is_array($transplugin_langs) ||
+ !in_array($transplugin_langcur, $transplugin_langs)) {
+ //current page is no translation or something is wrong, load default navigation
+ $sit_location = tpl_getConf("vector_sitenotice_location");
+ } else {
+ //load language specific navigation
+ $sit_location = tpl_getConf("vector_sitenotice_location")."_".$transplugin_langcur;
+ }
+ }else{
+ //default navigation, no translation
+ $sit_location = tpl_getConf("vector_sitenotice_location");
+ }
+
//we have to show a custom sitenotice
if (empty($conf["useacl"]) ||
- auth_quickaclcheck(cleanID(tpl_getConf("vector_sitenotice_location"))) >= AUTH_READ){ //current user got access?
+ auth_quickaclcheck(cleanID($sit_location)) >= AUTH_READ){ //current user got access?
echo "\n <div id=\"siteNotice\" class=\"noprint\">\n";
//get the rendered content of the defined wiki article to use as
//custom sitenotice.
- $interim = tpl_include_page(tpl_getConf("vector_sitenotice_location"), false);
+ $interim = tpl_include_page($sit_location, false);
if ($interim === "" ||
$interim === false){
//show creation/edit link if the defined page got no content
echo "[&#160;";
- tpl_pagelink(tpl_getConf("vector_sitenotice_location"), hsc($lang["vector_fillplaceholder"]." (".tpl_getConf("vector_sitenotice_location").")"));
+ tpl_pagelink($sit_location, hsc($lang["vector_fillplaceholder"]." (".$sit_location.")"));
echo "&#160;]<br />";
}else{
//show the rendered page content
@andreashaerter
Copy link

I added a translation feature for the site and copyright notice with commit https://github.com/bitkollektiv/dokuwiki-template-vector/commit/4d8721d7b397e86dd3378afad3de7f8c84ae19d5. The coming template release (today or tomorrow) will be shipped with it. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment