Commit 58e6a729 by Carsten Brandt

fixes #991 for gridview summary, use ITU message format

parent cfc57c20
...@@ -131,30 +131,32 @@ abstract class BaseListView extends Widget ...@@ -131,30 +131,32 @@ abstract class BaseListView extends Widget
public function renderSummary() public function renderSummary()
{ {
$count = $this->dataProvider->getCount(); $count = $this->dataProvider->getCount();
if (($pagination = $this->dataProvider->getPagination()) !== false && $count > 0) { if (($pagination = $this->dataProvider->getPagination()) !== false) {
$totalCount = $this->dataProvider->getTotalCount(); $totalCount = $this->dataProvider->getTotalCount();
$begin = $pagination->getPage() * $pagination->pageSize + 1; $begin = $pagination->getPage() * $pagination->pageSize + 1;
$end = $begin + $count - 1; $end = $begin + $count - 1;
$page = $pagination->getPage() + 1; $page = $pagination->getPage() + 1;
$pageCount = $pagination->pageCount; $pageCount = $pagination->pageCount;
if (($summaryContent = $this->summary) === null) { if (($summaryContent = $this->summary) === null) {
$summaryContent = '<div class="summary">' . Yii::t('yii', 'Showing <b>{begin}-{end}</b> of <b>{totalCount}</b> {0, plural, =1{item} other{items}}.', $totalCount) . '</div>'; $summaryContent = '<div class="summary">'
. Yii::t('yii', 'Showing <b>{totalCount, plural, =0{0} other{{begin}-{end}}}</b> of <b>{totalCount}</b> {totalCount, plural, one{item} other{items}}.')
. '</div>';
} }
} else { } else {
$begin = $page = $pageCount = 1; $begin = $page = $pageCount = 1;
$end = $totalCount = $count; $end = $totalCount = $count;
if (($summaryContent = $this->summary) === null) { if (($summaryContent = $this->summary) === null) {
$summaryContent = '<div class="summary">' . Yii::t('yii', 'Total <b>{count}</b> {0, plural, =1{item} other{items}}.', $count) . '</div>'; $summaryContent = '<div class="summary">' . Yii::t('yii', 'Total <b>{count}</b> {count, plural, one{item} other{items}}.') . '</div>';
} }
} }
return strtr($summaryContent, [ return Yii::$app->getI18n()->format($summaryContent, [
'{begin}' => $begin, 'begin' => $begin,
'{end}' => $end, 'end' => $end,
'{count}' => $count, 'count' => $count,
'{totalCount}' => $totalCount, 'totalCount' => $totalCount,
'{page}' => $page, 'page' => $page,
'{pageCount}' => $pageCount, 'pageCount' => $pageCount,
]); ], Yii::$app->language);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment