Skip to content

Commit

Permalink
Use labels for user attributes
Browse files Browse the repository at this point in the history
Makes use of the cascading localization mechanism. The most common attributes are defined in lang files.
  • Loading branch information
annda committed Jan 10, 2021
1 parent 0571759 commit 46222f8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
6 changes: 6 additions & 0 deletions lang/de/lang.php
@@ -0,0 +1,6 @@
<?php

$lang['user'] = 'Benutzer';
$lang['name'] = 'Name';
$lang['email'] = 'E-Mail';
$lang['mail'] = 'E-Mail';
6 changes: 6 additions & 0 deletions lang/en/lang.php
@@ -0,0 +1,6 @@
<?php

$lang['user'] = 'User';
$lang['name'] = 'Name';
$lang['email'] = 'Email';
$lang['mail'] = 'Email';
10 changes: 7 additions & 3 deletions syntax/table.php
Expand Up @@ -80,15 +80,19 @@ public function handle($match, $state, $pos, Doku_Handler $handler)
}

$data['attributes'] = $this->trimexplode(',', $cfg['attributes']);

// localize attribute names in table header
$data['attributeHeaders'] = array_map(function ($attr) {
return $this->getLang($attr) ?: $attr;
}, $data['attributes']);

$data['groups'] = $this->trimexplode(',', $cfg['groups']);
$titles = $this->trimexplode(',', $cfg['titles']);
if(empty($data['attributes'])) $data['attributes'] = ['user'];


$groupHeaders = $titles ? array_replace($data['groups'], $titles) : $data['groups'];
$data['headers'] = array_merge($data['attributes'], $groupHeaders);


$data['headers'] = array_merge($data['attributeHeaders'], $groupHeaders);

return $data;
}
Expand Down

0 comments on commit 46222f8

Please sign in to comment.