1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Can we use Angular translate different languages for different components/modules

Discussão em 'Angular' iniciado por TheCoderGuy, Setembro 9, 2024.

  1. TheCoderGuy

    TheCoderGuy Guest

    I am using ngx-translate to change the language of my application. My application has different languages only for testing and it is separated in different modules, lazy loading.

    So I have 2 variables of language.

    1. Is for the CV of the person which only there the text will be changed depends on the language it is selected
    2. It is for all other components and modules

    But the actual problem it is that if I use translate.use(cvLanguage) then it is translating all the application.

    Same happens with the Main components which are out of this module.

    I tried to use isolate in Translate Module but it is not working.

    This is my code.

    app.module.ts:

    TranslateModule.forRoot({
    loader: {
    provide: TranslateLoader,
    useFactory: httpTranslateLoader,
    deps: [HttpClient],
    },
    }),

    export function httpTranslateLoader(http: HttpClient) {
    return new TranslateHttpLoader(http);
    }


    And this is the user.module:

    TranslateModule.forChild({
    loader: {
    provide: TranslateLoader,
    useFactory: httpTranslateLoader
    },
    isolate: true
    }),
    export function httpTranslateLoader(http: HttpClient) {
    return new TranslateHttpLoader(http);
    }


    I tried to separate in modules and isolate the translate but it did not work.

    Continue reading...

Compartilhe esta Página