Die $locale
hat rather tiny public API. Jedoch, there is a $locale.pluralCat
method, so können Sie es verwenden.
angular.module('app', [])
.controller('LocaleCtrl', function($scope, $locale) {
$scope.locale = $locale.id;
$scope.getCategory = function(count) {
return $locale.pluralCat(count);
};
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular-i18n/1.5.5/angular-locale_pl-pl.js"></script>
<div ng-app="app">
<div ng-controller="LocaleCtrl">
<h1>ng-pluralize category for locale {{ locale }}</h1>
<ul>
<li ng-repeat="count in [0, 1, 2, 3, 4, 5, 6]">
category for {{count}} is {{ getCategory(count) }}
</li>
</ul>
</div>
</div>
Natürlich sind die Ergebnisse unterschiedlich, wenn Sie different locales verwenden.
Schön! Vielen Dank. – bearfriend