Skip to content

Commit

Permalink
lang(): option 'default': override value when not translated
Browse files Browse the repository at this point in the history
  • Loading branch information
plepe committed Aug 27, 2018
1 parent 3f1bf70 commit f723a9d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion inc/lang.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ function lang_element(str, options) {
}
}

if((l=str.match(/^tag:([^=]+)=(.*)$/))&&(l=lang_str["tag:*="+l[2]])) {
if (options.default) {
return options.default
}
else if((l=str.match(/^tag:([^=]+)=(.*)$/))&&(l=lang_str["tag:*="+l[2]])) {
// Boolean values, see:
// http://wiki.openstreetmap.org/wiki/Proposed_features/boolean_values
return l;
Expand Down
7 changes: 5 additions & 2 deletions inc/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,15 @@ function lang() {
}
}
elseif(!isset($lang_str[$key])) {
if((preg_match("/^tag:([^=]*)=(.*)$/", $key, $m))&&($k=$lang_str["tag:*={$m[2]}"])) {
if (isset($options['default'])) {
$key = $options['default'];
}
elseif((preg_match("/^tag:([^=]*)=(.*)$/", $key, $m))&&($k=$lang_str["tag:*={$m[2]}"])) {
// Boolean values, see:
// http://wiki.openstreetmap.org/wiki/Proposed_features/boolean_values
$key=$k;
}
else if(preg_match("/^tag:(.*)(=|>|<|>=|<=|!=)([^><=!]*)$/", $key, $m)) {
elseif(preg_match("/^tag:(.*)(=|>|<|>=|<=|!=)([^><=!]*)$/", $key, $m)) {
$key=$m[3];
}
elseif(preg_match("/^tag:([^><=!]*)$/", $key, $m)) {
Expand Down

0 comments on commit f723a9d

Please sign in to comment.