Skip to content

interpolating an array's length is not working in v17 anymore #1609

@soletan

Description

@soletan

Current behavior

When using interpolation patterns like {{ matches.length }} the resulting string does not contain the length of array matches, but that pattern's source as string.

Expected behavior

It should be possible to inject an array's size into translations, e.g. given the pattern above used in a translation for a key 'FOO.BAR' should result in that array's length given as number.

How do you think that we should fix this?

Method getValue() in util.ts has changed in v17 and it is limiting support for descending into arrays accepting numeric keys, only. Hence, using .length is not working like before anymore.

Minimal reproduction of the problem with instructions

https://stackblitz.com/edit/github-acm14mj2?file=src%2Fapp%2Fapp.component.ts

Image

Environment


ngx-translate version: 17.0.0
Angular version: 21.0.8


Browser:
- [x] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: 22.20.0  
- Platform:  Windows 

Others:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions