angular / angular/angular

Support # placeholder in ICU messages

Open
#62,694 1 comment 3 reactions 0 assignees View on GitHub
area: i18n
Dominant language
TypeScript
Stars
101k
Forks
27.5k
Avg merge
1d 19h
Merged PRs (30d)
288

Description

### Which @angular/* package(s) are relevant/related to the feature request?

localize

### Description

The ICU message format specifies a placeholder for the "current number" that can be used in plural rules. Example:

```html

Updated {currentItem().timeInMinutes(), plural,
one {# minute ago}
other {# minutes ago}
}

```

But when used in Angular, this renders as `Updated # minute ago` with a literal `#` in the output. It looks like Angular currently requires repeating the number expression for each case, separated by spaces to not confuse the nested braces:

```html

Updated {currentItem().timeInMinutes(), plural,
one { {{currentItem().timeInMinutes()}} minute ago}
other { {{currentItem().timeInMinutes()}} minutes ago}
}

```

References:

* https://unicode-org.github.io/icu/userguide/format_parse/messages/#messageformat
* https://unicode-org.github.io/icu-docs/apidoc/dev/icu4c/classicu_1_1PluralFormat.html
* https://www.npmjs.com/package/@messageformat/parser

### Proposed solution

Support the standard `#` placeholder. This would be a breaking change.

### Alternatives considered

n/a, keep as is since it would be breaking.

Contributor guide

Open the contributing guide

Research direction

Start in the @angular/localize package and trace how ICU plural messages are parsed and rendered. Compare the current behavior with the ICU references linked in the issue, then locate relevant existing tests or entry points. Done means # is interpreted as the current plural number in one and other cases without requiring repeated expressions, with the breaking change accounted for.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
localization
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.