Skip to content

Translate service returning array with string data only #1531

@startupcode

Description

@startupcode

I have upgraded my Ionic App from Ionic 6 to Ionic 8. Angular version is 19.2

Current behavior

I have below array in en.json file
"ARR_TEST": [{ "num": 1, "prediction": "Loss"}, {"num": 2, "prediction": "Meditation"}];

In my .ts file, I'm using below
import { TranslateModule, TranslateService } from '@ngx-translate/core';
private translate: TranslateService

this.translate.get('ARR_TEST').subscribe((res: Array) => {
console.log(res);
});

Here it is returning me array like.
"ARR_TEST": [{ "prediction": "Loss"}, {"prediction": "Meditation"}];

so num key is missing from my response array. But if I assign num key value as "1" or "2" i.e. as string, it works well and returns correct array.

It was all working fine in Ionic 6. This happened after upgrading to ionic 8.

Expected behavior

console.log(res) should return below array with num key

"ARR_TEST": [{ "num": 1, "prediction": "Loss"}, {"num": 2, "prediction": "Meditation"}];

How do you think that we should fix this?

No Idea, I searched many articles to understand if there is any ground breaking changes related to this, but couldn't find.

Environment


"@ngx-translate/core": "^16.0.4",
 "@ngx-translate/http-loader": "^16.0.1",

"@angular/common": "^19.2.0",
    "@angular/core": "^19.2.0",
    "@angular/fire": "^19.0.0",
    "@angular/forms": "^19.2.0",
    "@angular/platform-browser": "^19.2.0",
    "@angular/platform-browser-dynamic": "^19.2.0",
    "@angular/router": "^19.2.0",

"@ionic/angular": "^8.4.3",
    "@ionic/cli": "^7.2.0",


Please help.

Metadata

Metadata

Assignees

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