Skip to content

Commit

Permalink
Improve using new JSON format
Browse files Browse the repository at this point in the history
  • Loading branch information
plepe committed Sep 11, 2017
1 parent ba76bab commit 1013930
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 15 deletions.
28 changes: 21 additions & 7 deletions inc/lang.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,29 @@ function lang_element(str, count) {
return l;

var i;
if (typeof l === 'object') {
if ('!=1' in l && (count == 0 || count > 1)) {
i = '!=1'
}
else {
i = 'message'
if(l.length && l.length>1) {
if((count===0)||(count>1))
i=1;
else
i=0;

// if a Gender is defined, shift values
if(typeof(l[0])=="number")
i++;

return l[i];
}
else if(l.length && l.length==1) {
return l[0];
}
else if (typeof l === 'object') {
if ('!=1' in l && (count === 0 || count > 1)) {
return l['!=1']
}

return l[i]
if ('message' in l) {
return l['message']
}
}
}

Expand Down
32 changes: 24 additions & 8 deletions inc/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,32 @@ function lang() {
if(!isset($l)) {
return null;
}
elseif(is_array($l)&&(sizeof($l)==1)) {
$l=$l[0];
}
elseif(is_array($l)) {
if(array_key_exists('!=1', $l) && ($count===0)||($count!=1))
$i = '!=1';
else
$i = 'message';
if (array_key_exists('0', $l)) {
if (sizeof($l) === 1) {
$l=$l[0];
}
else {
if ($count===0 || $count!=1)
$i=1;
else
$i=0;

// if a Gender is defined, shift values
if(is_integer($l[0]))
$i++;

$l = $l[$i];
$l=$l[$i];
}
}
else {
if (array_key_exists('!=1', $l) && ($count === 0 || $count > 1)) {
$l = $l['!=1'];
}
elseif (array_key_exists('message', $l)) {
$l = $l['message'];
}
}
}

return vsprintf($l, $params);
Expand Down

0 comments on commit 1013930

Please sign in to comment.