回答

1

$localerather tiny public API。但是,there is a $locale.pluralCat method,所以你可以使用它。

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>

当然,如果你使用different locales的结果是不同的。

+0

美丽!谢谢。 – bearfriend

相关问题