darioegb / ngx-translate-routes

MIT License
4 stars 1 forks source link

Angular 18 Standalone mode #14

Closed gizbo closed 5 months ago

gizbo commented 5 months ago

Hello, I'm looking for a configuration example in the case of Angular 18 in Standalone mode.

export const appConfig: ApplicationConfig = {
  providers: [provideZoneChangeDetection({ eventCoalescing: true }), 
  provideRouter(routes),
  importProvidersFrom(TranslateModule.forRoot({
      defaultLanguage: 'en',
      loader: {
        provide: TranslateLoader,
        useFactory: HttpLoaderFactory,
        deps: [HttpClient],
      },
})
  ), 
importProvidersFrom(NgxTranslateRoutesModule.forRoot()),
...

Does this make sense?

Also how can I get the language in the url like /en/about/ <--> /fr/apropos/

Thanks

darioegb commented 5 months ago

Hi @gizbo, The configuration seems to be fine, let me check it, I haven't tried the lib in a standalone project. In relation to the second point at the moment, routes with the language in the path are not supported, but it could be an interesting improvement.

darioegb commented 5 months ago

@gizbo You can try with something like this pretty similar than you configuration:

providers: [
    provideHttpClient(withInterceptorsFromDi()),
    provideZoneChangeDetection({ eventCoalescing: true }),
    provideRouter(routes),
    importProvidersFrom(
      TranslateModule.forRoot({
        defaultLanguage: 'en',
        useDefaultLang: true,
        loader: {
          provide: TranslateLoader,
          useFactory: HttpLoaderFactory,
          deps: [HttpClient],
        },
      }),
      NgxTranslateRoutesModule.forRoot()
    ),
  ],
darioegb commented 5 months ago

Hi @gizbo Did the library work with the configuration I provided, or do you need it to work with the routes using the language as a prefix? If so, please create an issue on that topic so I can address that improvement in the future.

darioegb commented 5 months ago

I will close this issue because the lib works with standalone