Open
Description
Current behavior
In our application we provide our localization with the following format
{
"my-component-selector.key1": "value1",
"my-component-selector.key2": "value2"
}
If I call TranslateService.set('my-component-selector.key1', 'new value')
.
It updates correctly my-component-selector.key1
but I lost the localization of my-component-selector.key2
.
From what I understood it is because now localization keys are handled with hierarchy.
So after the update we should have something like:
{
"my-component-selector": {
"key1": "new value"
},
"my-component-selector.key2": "value2"
}
and now the translate service for my-component-selector.key2
returns undefined
.
Expected behavior
I would expect my-component-selector.key2
to still be translated correctly as it works before the call to TranslateService.set
How do you think that we should fix this?
I think 2 options are possible here:
- The resolution of keys should first check the hierarchy as for now, and if
undefined
then check for the key as is. TranslateService.set
could take an extra parameter to keep the format, in the examplemy-component-selector.key1
instead of{my-component-selector: {key1: 'new value'}}
Minimal reproduction of the problem with instructions
- Define differents localization keys with the same prefix and
.
as separator. - Call
TranslateService.set
Environment
ngx-translate version: 16.0.0
Angular version: 19.0.0
Browser:
- [x] Chrome (desktop) version XX
- [x] Chrome (Android) version XX
- [x] Chrome (iOS) version XX
- [x] Firefox version XX
- [x] Safari (desktop) version XX
- [x] Safari (iOS) version XX
- [x] IE version XX
- [x] Edge version XX
For Tooling issues:
- Node version: 20 || 22
- Platform: Mac, Linux, Windows
Others:
N/A
Metadata
Metadata
Assignees
Labels
No labels