* Returns the index of the current case of an ICU expression depending on the main binding value * * @param icuExpression * @param bindingValue The value of the main binding used by this ICU expression
(icuExpression: TIcu, bindingValue: string)
| 580 | * @param bindingValue The value of the main binding used by this ICU expression |
| 581 | */ |
| 582 | function getCaseIndex(icuExpression: TIcu, bindingValue: string): number | null { |
| 583 | let index = icuExpression.cases.indexOf(bindingValue); |
| 584 | if (index === -1) { |
| 585 | switch (icuExpression.type) { |
| 586 | case IcuType.plural: { |
| 587 | const resolvedCase = getPluralCase(bindingValue, getLocaleId()); |
| 588 | index = icuExpression.cases.indexOf(resolvedCase); |
| 589 | if (index === -1 && resolvedCase !== 'other') { |
| 590 | index = icuExpression.cases.indexOf('other'); |
| 591 | } |
| 592 | break; |
| 593 | } |
| 594 | case IcuType.select: { |
| 595 | index = icuExpression.cases.indexOf('other'); |
| 596 | break; |
| 597 | } |
| 598 | } |
| 599 | } |
| 600 | return index === -1 ? null : index; |
| 601 | } |
no test coverage detected
searching dependent graphs…