Browse Source

made intl messages more compatible with various ICU versions

issue #1072
tags/2.0.0-beta
Carsten Brandt 11 years ago
parent
commit
6559b06ead
  1. 2
      framework/yii/i18n/MessageFormatter.php
  2. 7
      framework/yii/widgets/BaseListView.php

2
framework/yii/i18n/MessageFormatter.php

@ -92,7 +92,7 @@ class MessageFormatter extends Component
return $this->fallbackFormat($pattern, $params, $language);
}
if (version_compare(PHP_VERSION, '5.5.0', '<')) {
if (version_compare(PHP_VERSION, '5.5.0', '<') || version_compare(INTL_ICU_VERSION, '4.8', '<')) {
$pattern = $this->replaceNamedArguments($pattern, $params);
$params = array_values($params);
}

7
framework/yii/widgets/BaseListView.php

@ -135,18 +135,21 @@ abstract class BaseListView extends Widget
$totalCount = $this->dataProvider->getTotalCount();
$begin = $pagination->getPage() * $pagination->pageSize + 1;
$end = $begin + $count - 1;
if ($begin > $end) {
$begin = $end;
}
$page = $pagination->getPage() + 1;
$pageCount = $pagination->pageCount;
if (($summaryContent = $this->summary) === null) {
$summaryContent = '<div class="summary">'
. Yii::t('yii', 'Showing <b>{totalCount, plural, zero{0} other{{begin, number, integer}-{end, number, integer}}}</b> of <b>{totalCount, number, integer}</b> {totalCount, plural, one{item} other{items}}.')
. Yii::t('yii', 'Showing <b>{begin, number}-{end, number}</b> of <b>{totalCount, number}</b> {totalCount, plural, one{item} other{items}}.')
. '</div>';
}
} else {
$begin = $page = $pageCount = 1;
$end = $totalCount = $count;
if (($summaryContent = $this->summary) === null) {
$summaryContent = '<div class="summary">' . Yii::t('yii', 'Total <b>{count, number, integer}</b> {count, plural, one{item} other{items}}.') . '</div>';
$summaryContent = '<div class="summary">' . Yii::t('yii', 'Total <b>{count, number}</b> {count, plural, one{item} other{items}}.') . '</div>';
}
}
return Yii::$app->getI18n()->format($summaryContent, [

Loading…
Cancel
Save