Skip to content

Commit

Permalink
Keep custom label's case if lang string not found
Browse files Browse the repository at this point in the history
  • Loading branch information
dregad committed Nov 10, 2024
1 parent 2c27907 commit 09b1853
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions syntax.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,24 +181,26 @@ protected function _parseOptions($optstr, &$options) {
$opts = preg_split('/[,&]/', $optstr);

foreach($opts as $opt) {
$opt = strtolower(trim($opt));
$opt_lower = strtolower(trim($opt));
$val = true;
// booleans can be negated with a no prefix
if(substr($opt, 0, 2) == 'no') {
$opt = substr($opt, 2);
if(substr($opt_lower, 0, 2) == 'no') {
$opt_lower = substr($opt, 2);
$val = false;
}

// not a known option? might be a key=value pair
if(!isset($options[$opt])) {
list($opt, $val) = array_map('trim', sexplode('=', $opt, 2));
if(!isset($options[$opt_lower])) {
$split = array_map('trim', sexplode('=', $opt, 2));
$opt_lower = strtolower($split[0]);
$val = $split[1];
}

// still unknown? skip it
if(!isset($options[$opt])) continue;
if(!isset($options[$opt_lower])) continue;

// overwrite the current value
$options[$opt] = $val;
$options[$opt_lower] = $val;
}
}

Expand Down

0 comments on commit 09b1853

Please sign in to comment.