diff --git a/MenuItem.php b/MenuItem.php index 4a1011b..5b14b6c 100644 --- a/MenuItem.php +++ b/MenuItem.php @@ -20,7 +20,22 @@ class MenuItem extends AbstractItem { $this->label = $label; parent::__construct(); // Edit the item to show a link to the requested children page - $this->id = $this->type.':'.$INFO['id']; + if ( ! plugin_isdisabled('translate') ) { + // If the "translate" plugin is activated, the language code should stay the top-level namespace + $translate_plugin =& plugin_load('helper', 'translate'); + $language = $translate_plugin->getPageLanguage(); + if ( $language !== null && preg_match("/^$language:/", $INFO['id']) ) { + $this->id = preg_replace( + "/^$language:/", + "$language:".$this->type.':', + $INFO['id'] + ); + } else { + $this->id = $this->type.':'.$INFO['id']; + } + } else { + $this->id = $this->type.':'.$INFO['id']; + } $this->params = []; } } diff --git a/action.php b/action.php index 69d5190..23ae1ee 100644 --- a/action.php +++ b/action.php @@ -41,10 +41,20 @@ class action_plugin_childrenpages extends DokuWiki_Action_Plugin { if ( $event->data['view'] !== 'page' ) { return; } - // Get the list of children pages - $children_types = $this->getConf('children_list'); // Only add links if the current page is not included in a reserved namespace - $top_namespace = explode(':', $INFO['namespace'])[0]; + $children_types = $this->getConf('children_list'); + if ( ! plugin_isdisabled('translate') ) { + // Skip top-level namespace added by "translate" plugin + $translate_plugin =& plugin_load('helper', 'translate'); + $language = $translate_plugin->getPageLanguage(); + if ( $language !== null && preg_match("/^$language:/", $INFO['id']) ) { + $top_namespace = explode(':', $INFO['namespace'])[1]; + } else { + $top_namespace = explode(':', $INFO['namespace'])[0]; + } + } else { + $top_namespace = explode(':', $INFO['namespace'])[0]; + } if ( in_array($top_namespace, $children_types) ) { return; }