core icon indicating copy to clipboard operation
core copied to clipboard

Issue with setTranslation

Open ali-idrizi opened this issue 6 years ago • 8 comments

Is there currently any issue with setTranslation or am I doing something wrong?

My translation for en in the i18n directory looks like this:

{
  "home": {
    "title": "Title"
  }
}

I am running the following code in AppComponent

this.languageService.setTranslation('en', {test: 'test'}, true);
this.languageService.getTranslation('en').subscribe(res => console.log(res));

And what I get in the console is nothing different than the initial JSON file.

I am using Angular v5.2.3, ngx-translate v9.1.1 with ngx-translate-messageformat-compiler

ali-idrizi avatar Feb 06 '18 07:02 ali-idrizi

I have the same issue.

martinmicunda avatar Feb 08 '18 22:02 martinmicunda

that's because order, if you emit the change before subscribing you might not see the change, but if you change the calling order you should be able to see the new properties

jlberrocal avatar Feb 10 '18 13:02 jlberrocal

Nope, still nothing. It doesn't even call the .next() after setTranslation, nothing shows in the console. Here is a Plunker demo

ali-idrizi avatar Feb 10 '18 16:02 ali-idrizi

ok, seems that @ocombe set the getTranslation method to be a one time subscription, so you will no be able to see the changes, if you want to know when a change take place you will have to listen for onTranslationChange event instead, however @ocombe there is an issue because translate pipe is never seeing the change please refer to this plunk

jlberrocal avatar Feb 10 '18 16:02 jlberrocal

I'm having the exact same issue, spent a day debugging translation issues, turns out this was the problem. Any plans on fixing this?

gustavshf avatar Aug 24 '20 10:08 gustavshf

It looks like doesn't work with translation pipe as @jlberrocal mentioned.

nguyenbathanh avatar Sep 23 '20 10:09 nguyenbathanh

Any updates on this?

DovakhinMRK avatar Apr 26 '21 08:04 DovakhinMRK

Any updates on this?

qwekelly avatar May 23 '23 05:05 qwekelly