fix translation bug for likers

This commit is contained in:
rabuzarus 2015-10-14 19:48:57 +02:00
parent c855c9ba67
commit 642f3fca1a

View file

@ -1025,26 +1025,9 @@ function format_like($cnt,$arr,$type,$id) {
$o = ''; $o = '';
$expanded = ''; $expanded = '';
if($cnt == 1) if($cnt == 1) {
$likers = $arr[0]; $likers = $arr[0];
else {
$total = count($arr);
if($total >= MAX_LIKERS)
$arr = array_slice($arr, 0, MAX_LIKERS - 1);
if($total < MAX_LIKERS) {
$last = t('and') . ' ' . $arr[count($arr)-1];
$arr2 = array_slice($arr, 0, -1);
$str = implode(', ', $arr2) . ' ' . $last;
}
if($total >= MAX_LIKERS) {
$str = implode(', ', $arr);
$str .= sprintf( t(', and %d other people'), $total - MAX_LIKERS );
}
$likers = $str;
}
// Phrase if there is only one liker. In other cases it will be uses for the expanded // Phrase if there is only one liker. In other cases it will be uses for the expanded
// list which show all likers // list which show all likers
switch($type) { switch($type) {
@ -1064,34 +1047,50 @@ function format_like($cnt,$arr,$type,$id) {
$phrase = sprintf( t('%s attends maybe.'), $likers); $phrase = sprintf( t('%s attends maybe.'), $likers);
break; break;
} }
}
if($cnt > 1) { if($cnt > 1) {
$total = count($arr);
if($total >= MAX_LIKERS)
$arr = array_slice($arr, 0, MAX_LIKERS - 1);
if($total < MAX_LIKERS) {
$last = t('and') . ' ' . $arr[count($arr)-1];
$arr2 = array_slice($arr, 0, -1);
$str = implode(', ', $arr2) . ' ' . $last;
}
if($total >= MAX_LIKERS) {
$str = implode(', ', $arr);
$str .= sprintf( t(', and %d other people'), $total - MAX_LIKERS );
}
$likers = $str;
$spanatts = "class=\"fakelink\" onclick=\"openClose('{$type}list-$id');\""; $spanatts = "class=\"fakelink\" onclick=\"openClose('{$type}list-$id');\"";
$expanded .= "\t" . '<div class="wall-item-' . $type . '-expanded" id="' . $type . 'list-' . $id . '" style="display: none;" >' . $phrase . EOL . '</div>';
switch($type) { switch($type) {
case 'like': case 'like':
$phrase = sprintf( t('<span %1$s>%2$d people</span> like this'), $spanatts, $cnt); $phrase = sprintf( t('<span %1$s>%2$d people</span> like this'), $spanatts, $cnt);
$explikers = sprintf( t('%s like this.'), $likers);
break; break;
case 'dislike': case 'dislike':
$phrase = sprintf( t('<span %1$s>%2$d people</span> don\'t like this'), $spanatts, $cnt); $phrase = sprintf( t('<span %1$s>%2$d people</span> don\'t like this'), $spanatts, $cnt);
$explikers = sprintf( t('%s don\'t like this.'), $likers);
break; break;
case 'attendyes': case 'attendyes':
$phrase = sprintf( t('<span %1$s>%2$d people</span> attend'), $spanatts, $cnt); $phrase = sprintf( t('<span %1$s>%2$d people</span> attend'), $spanatts, $cnt);
$explikers = sprintf( t('%s attend.'), $likers);
break; break;
case 'attendno': case 'attendno':
$phrase = sprintf( t('<span %1$s>%2$d people</span> don\'t attend'), $spanatts, $cnt); $phrase = sprintf( t('<span %1$s>%2$d people</span> don\'t attend'), $spanatts, $cnt);
$explikers = sprintf( t('%s don\'t attend.'), $likers);
break; break;
case 'attendmaybe': case 'attendmaybe':
$phrase = sprintf( t('<span %1$s>%2$d people</span> anttend maybe'), $spanatts, $cnt); $phrase = sprintf( t('<span %1$s>%2$d people</span> anttend maybe'), $spanatts, $cnt);
case 'agree': $explikers = sprintf( t('%s anttend maybe.'), $likers);
$phrase = sprintf( t('<span %1$s>%2$d people</span> agree'), $spanatts, $cnt);
break; break;
case 'disagree':
$phrase = sprintf( t('<span %1$s>%2$d people</span> don\'t agree'), $spanatts, $cnt);
break;
case 'abstain':
$phrase = sprintf( t('<span %1$s>%2$d people</span> abstains'), $spanatts, $cnt);
} }
$expanded .= "\t" . '<div class="wall-item-' . $type . '-expanded" id="' . $type . 'list-' . $id . '" style="display: none;" >' . $explikers . EOL . '</div>';
} }
$phrase .= EOL ; $phrase .= EOL ;