Core: Issue with setTranslation

Created on 6 Feb 2018  路  6Comments  路  Source: ngx-translate/core

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

Most helpful comment

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

All 6 comments

I have the same issue.

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

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

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

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

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

Was this page helpful?
0 / 5 - 0 ratings