( value: number, cases: string[], ngLocalization: NgLocalization, locale?: string, )
| 32 | * - the plural category otherwise |
| 33 | */ |
| 34 | export function getPluralCategory( |
| 35 | value: number, |
| 36 | cases: string[], |
| 37 | ngLocalization: NgLocalization, |
| 38 | locale?: string, |
| 39 | ): string { |
| 40 | let key = `=${value}`; |
| 41 | |
| 42 | if (cases.indexOf(key) > -1) { |
| 43 | return key; |
| 44 | } |
| 45 | |
| 46 | key = ngLocalization.getPluralCategory(value, locale); |
| 47 | |
| 48 | if (cases.indexOf(key) > -1) { |
| 49 | return key; |
| 50 | } |
| 51 | |
| 52 | if (cases.indexOf('other') > -1) { |
| 53 | return 'other'; |
| 54 | } |
| 55 | |
| 56 | throw new RuntimeError( |
| 57 | RuntimeErrorCode.NO_PLURAL_MESSAGE_FOUND, |
| 58 | ngDevMode && `No plural message found for value "${value}"`, |
| 59 | ); |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Returns the plural case based on the locale |
no test coverage detected
searching dependent graphs…