You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was wondering how you should handle an import of TranslateModule.forChild in your module when moving to standalone components? This was used because we only wanted to load the translations when navigating to a route path which lazy loads this module. Currently I have an NX project with multiple libs and each lib has his module and own assets folder with the translation files. The libs are used by one or multiple apps and in my app I have a project. json file which contains this in my target.build.options.assets
import {HttpBackend} from '@angular/common/http';
import {NgModule} from '@angular/core';
import {TranslateLoader, TranslateModule} from '@ngx-translate/core';
function translateLoaderFactory(httpBackend: HttpBackend) {
return new CustomMultiTranslateHttpLoader(httpBackend, ['assets/modules/feat1/i18n/', 'assets/shared/i18n/']);
}
@NgModule({
imports: [
TranslateModule.forChild({
loader: {
provide: TranslateLoader,
useFactory: translateLoaderFactory,
deps: [HttpBackend]
},
isolate: true
})
],
providers: [TranslationLoaderResolver]
})
export default class Feat1Module {}
In the component which has been transformed to a standalone component I added TranslateModule to the imports of the @Component decorator.
The text was updated successfully, but these errors were encountered:
LoganDupont
changed the title
How to handle import TranslateModule.forChild in module when moving to standalone
How to handle import TranslateModule.forChild in module when moving to standalone components
Oct 27, 2023
Hi,
Same problem for me but @LoganDupont explanation did not solve it because each standalone components (previously a module) have to load its own translation from a separate file via lazy-loading. So, it's not possible to do it in main app config.
I tried to do it in routes definition via "providers" parameter and "importProvidersFrom" but translations are not loaded for the targeted component.
Hi,
I was wondering how you should handle an import of
TranslateModule.forChild
in your module when moving to standalone components? This was used because we only wanted to load the translations when navigating to a route path which lazy loads this module. Currently I have an NX project with multiple libs and each lib has his module and own assets folder with the translation files. The libs are used by one or multiple apps and in my app I have aproject. json
file which contains this in mytarget.build.options.assets
example:
In the component which has been transformed to a standalone component I added
TranslateModule
to theimports
of the@Component
decorator.The text was updated successfully, but these errors were encountered: