File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { TranslateLoader , TranslateModuleConfig } from '@ngx-translate/core' ;
22import { TranslateHttpLoader } from '@ngx-translate/http-loader' ;
33
4+ import { isPlatformServer } from '@angular/common' ;
45import { HttpClient } from '@angular/common/http' ;
6+ import { inject , PLATFORM_ID } from '@angular/core' ;
7+
8+ import { ENVIRONMENT } from '@core/provider/environment.provider' ;
59
610function httpLoaderFactory ( http : HttpClient ) : TranslateHttpLoader {
7- return new TranslateHttpLoader ( http , './assets/i18n/' , '.json' ) ;
11+ const platformId = inject ( PLATFORM_ID ) ;
12+ const environment = inject ( ENVIRONMENT ) ;
13+ const basePrefix = '/assets/i18n/' ;
14+ const webUrl = environment . webUrl ?. replace ( / \/ + $ / , '' ) ?? '' ;
15+ const prefix = isPlatformServer ( platformId ) && webUrl ? `${ webUrl } ${ basePrefix } ` : basePrefix ;
16+
17+ return new TranslateHttpLoader ( http , prefix , '.json' ) ;
818}
919
1020export const provideTranslation = ( ) : TranslateModuleConfig => ( {
You can’t perform that action at this time.
0 commit comments