core icon indicating copy to clipboard operation
core copied to clipboard

ngx-translate with nrwl

Open BVSureshBabu opened this issue 6 years ago • 3 comments

Hi,

I am using ngx-translate with nrwl. It is working fine if I keep all translation file in app and loading all once. But I want to load translation files per lib lazily i.e whenever module loads that time I want to load translation files loaded in that lib. libs are lazyloaded. I am using below versions

"@nrwl/nx": "1.0.0",
"@ngx-translate/core": "9.1.1",
"@ngx-translate/http-loader": "2.0.1",
"@angular/compiler-cli": "5.2.7",

Please help me to achieve this. Thanks in advance.

Thanks & Regards, Suresh

BVSureshBabu avatar May 27 '19 14:05 BVSureshBabu

I'm trying to achieve the same, I suggest you open a question on stackoverflow to discuss there as I don't think this is an issue with the ngx-translate platform

chrismclarke avatar Jun 06 '19 20:06 chrismclarke

Hi,

I am using ngx-translate with nrwl. It is working fine if I keep all translation file in app and loading all once. But I want to load translation files per lib lazily i.e whenever module loads that time I want to load translation files loaded in that lib. libs are lazyloaded. I am using below versions

"@nrwl/nx": "1.0.0",
"@ngx-translate/core": "9.1.1",
"@ngx-translate/http-loader": "2.0.1",
"@angular/compiler-cli": "5.2.7",

Please help me to achieve this. Thanks in advance.

Thanks & Regards, Suresh

Did you find a solution for the same? I am also looking for a way to achieve the same...can you help?

Salahudeen avatar May 10 '20 21:05 Salahudeen

Same. I am using nx. Here's the further I have got. Still can't have the behaviour to really extend but I think I got pretty close, evolving from other people's StackBlitz.

For lazy-loaded modules with different translation loaders (loading .json from different files) it seems to be either (in the case of the lazy-loaded):

  • (LazyModule isolate: false, extend: true) React to parent module translation events automatically without having to connect anything, just as they say, but cannot load the lazy loaded specific files.
  • (LazyModule isolate: true, extend: true) We have to propagate changes to parent's translation event changes to the lazy child ourselves, and we can have our specific translations working! But the parent's translation won't work.

It's like I can't blend the two.

https://stackblitz.com/edit/translations-and-lazy-loading?file=README.md

eulersson avatar Jul 15 '21 11:07 eulersson

@docwhite any updates of this?

vmagalhaes avatar Dec 01 '22 17:12 vmagalhaes

Sadly not @vmagalhaes. I ended up learning another tool called transloco.

eulersson avatar Dec 01 '22 18:12 eulersson

Sadly not @vmagalhaes. I ended up learning another tool called transloco.

And did you have a better result with lib <> app interaction?

vmagalhaes avatar Dec 01 '22 19:12 vmagalhaes

@vmagalhaes yes you can craft it using what they call "scopes" https://ngneat.github.io/transloco/docs/lazy-load/scope-configuration/

eulersson avatar Dec 01 '22 20:12 eulersson