Core: Ionic 3.01 Lazy Module : The pipe 'translate' could not be found

Created on 10 Apr 2017  路  13Comments  路  Source: ngx-translate/core

**I'm submitting a issue because since the updated Ionic 3.0.0 the ngx-translate cannot be used with ionic lazy loading system.

Current behavior
When i load the page lazy loaded i get :
Uncaught (in promise): Error: Template parse errors: The pipe 'translate' could not be found (" <ion-header> <ion-navbar color="primary" hideBackButton="true"> <ion-title>{{[ERROR ->]"login.title"|translate}}</ion-title> </ion-navbar> </ion-header> "): ng:///LoginModule/LoginPage.html@8:17

Expected/desired behavior

Reproduction of the problem
Load the webapp using : ionic serve

What is the expected behavior?

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

  • ngx-translate version: 6.0.1

  • Angular version: 4.0.0

  • Browser: [all ]

Most helpful comment

Make sure to import TranslateModule in your lazy loaded module as well. Or better, add TranslateModule to a SharedModule and import that SharedModule to every feature module.

All 13 comments

Make sure to import TranslateModule in your lazy loaded module as well. Or better, add TranslateModule to a SharedModule and import that SharedModule to every feature module.

Hi, @SamVerschueren thanks for your reply. i have done your idea + idea based inside issue 209 and it work in dev mode (ionic serve) but when i build for android it dosn't work. Have you tested with ionic run android ?

https://github.com/ngx-translate/core/issues/209

Have you looked at the AoT section? If yes, provide me with a minimal reproduction case (GitHub repository for instance) and I'll see what I can do. Not much time now to dive into it myself.

Finally i have solved my problem by adding :

// AoT requires an exported function for factories
export function HttpLoaderFactory(http: Http) {
 return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}

And drawing inspiration from : https://github.com/ngx-translate/core/issues/209

Thanks @SamVerschueren

Glad it worked out :)

I have experienced new problem with lazy loading using ion-tabs component.
Have you experienced this component with lazy loading ?

Thanks

No sorry, haven't used ionic that much. This is an ionic issue so please file an issue over there.

Ok i will do this, have a good day!

Finally is ok for the tabs but you must use lazy for all tab inside pager

@pegaltier Do i have the same question that will let me see your code? please

I thought the IonicPageModule.forChild() function should resolve this ?

If it's loaded in app.module.ts, why should we add it to each page lazy loaded too ?

@pegaltier I got that error but I use lazy loading for all my pages

how do you load the json file in lazyloaded module? i don't see in the network tab the translation

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rbaumi picture rbaumi  路  4Comments

webprofusion-chrisc picture webprofusion-chrisc  路  4Comments

gmquiroga picture gmquiroga  路  3Comments

IterationCorp picture IterationCorp  路  3Comments

crebuh picture crebuh  路  3Comments