Add a localized label on generated menu items
This commit is contained in:
parent
eefa64ecb4
commit
b1725f934c
3 changed files with 19 additions and 9 deletions
|
@ -9,9 +9,11 @@ class MenuItem extends AbstractItem {
|
||||||
* Generate a menu item from a passed string
|
* Generate a menu item from a passed string
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
|
* @param string $label
|
||||||
*/
|
*/
|
||||||
public function __construct(string $type) {
|
public function __construct(string $type, string $label) {
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
|
$this->label = $label;
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
trigger_error("generating a menu item for type \"$this->type\" not implemented in ".get_class($this), E_USER_WARNING);
|
trigger_error("generating a menu item for type \"$this->type\" not implemented in ".get_class($this), E_USER_WARNING);
|
||||||
}
|
}
|
||||||
|
|
18
action.php
18
action.php
|
@ -46,9 +46,10 @@ class action_plugin_childrenpages extends DokuWiki_Action_Plugin {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Get the list of children pages
|
// Get the list of children pages
|
||||||
$children = [ 'animation', 'gameplay', 'dev', 'talk' ];
|
$children_types = [ 'animation', 'gameplay', 'dev', 'talk' ];
|
||||||
foreach ( $children as $child ) {
|
foreach ( $children_types as $child_type ) {
|
||||||
$this->addMenuItem($event, $child);
|
$child_label = $this->getLang("btn_$child_type");
|
||||||
|
$this->addMenuItem($event, $child_type, $child_label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,10 +57,11 @@ class action_plugin_childrenpages extends DokuWiki_Action_Plugin {
|
||||||
* Add a new item to the page menu
|
* Add a new item to the page menu
|
||||||
*
|
*
|
||||||
* @param Doku_Event $event
|
* @param Doku_Event $event
|
||||||
* @param string $child
|
* @param string $type
|
||||||
|
* @param string $name
|
||||||
*/
|
*/
|
||||||
protected function addMenuItem(Doku_Event $event, string $child) {
|
protected function addMenuItem(Doku_Event $event, string $type, string $name) {
|
||||||
$item = $this->generateMenuItem($child);
|
$item = $this->generateMenuItem($type, $name);
|
||||||
$event->data['items'][] = $item;
|
$event->data['items'][] = $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +70,7 @@ class action_plugin_childrenpages extends DokuWiki_Action_Plugin {
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
*/
|
*/
|
||||||
protected function generateMenuItem(string $type) {
|
protected function generateMenuItem(string $type, string $name) {
|
||||||
return new MenuItem($type);
|
return new MenuItem($type, $name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
6
lang/en/lang.php
Normal file
6
lang/en/lang.php
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$lang['btn_animation'] = 'Animation';
|
||||||
|
$lang['btn_dev'] = 'Dev';
|
||||||
|
$lang['btn_gameplay'] = 'Gameplay';
|
||||||
|
$lang['btn_talk'] = 'Talk';
|
Loading…
Reference in a new issue