Skip to content

Commit

Permalink
fix(i18n): let util-18n.module handle language detection
Browse files Browse the repository at this point in the history
  • Loading branch information
tkohr committed Mar 20, 2023
1 parent e5cce56 commit 6af4504
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 30 deletions.
10 changes: 2 additions & 8 deletions apps/datafeeder/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@ import { AppRoutingModule } from './app-routing.module'
import { AppComponent } from './app.component'
import { UploadDataComponent } from './presentation/components/upload-data/upload-data.component'
import {
getDefaultLang,
getLangFromBrowser,
TRANSLATE_DEFAULT_CONFIG,
UtilI18nModule,
} from '@geonetwork-ui/util/i18n'
import { UiInputsModule } from '@geonetwork-ui/ui/inputs'
import { UploadDataPageComponent } from './presentation/pages/upload-data-page/upload-data.page'
import { UploadDataRulesComponent } from './presentation/components/upload-data-rules/upload-data-rules.component'
import { HttpClientModule } from '@angular/common/http'
import { TranslateModule, TranslateService } from '@ngx-translate/core'
import { TranslateModule } from '@ngx-translate/core'
import { DatasetValidationPageComponent } from './presentation/pages/dataset-validation-page/dataset-validation-page'
import { DataImportValidationMapPanelComponent } from './presentation/components/data-import-validation-map-panel/data-import-validation-map-panel.component'
import { AnalysisProgressPageComponent } from './presentation/pages/analysis-progress-page/analysis-progress.page'
Expand Down Expand Up @@ -84,8 +82,4 @@ export function apiConfigurationFactory() {
],
bootstrap: [AppComponent],
})
export class AppModule {
constructor(translate: TranslateService) {
translate.use(getLangFromBrowser() || getDefaultLang())
}
}
export class AppModule {}
12 changes: 2 additions & 10 deletions apps/datahub/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ import {
getThemeConfig,
} from '@geonetwork-ui/util/app-config'
import {
getDefaultLang,
getLangFromBrowser,
TRANSLATE_DEFAULT_CONFIG,
UtilI18nModule,
} from '@geonetwork-ui/util/i18n'
Expand All @@ -43,7 +41,7 @@ import { LOGIN_URL } from '@geonetwork-ui/feature/auth'
import { EffectsModule } from '@ngrx/effects'
import { MetaReducer, StoreModule } from '@ngrx/store'
import { StoreDevtoolsModule } from '@ngrx/store-devtools'
import { TranslateModule, TranslateService } from '@ngx-translate/core'
import { TranslateModule } from '@ngx-translate/core'
import { filter } from 'rxjs/operators'
import { environment } from '../environments/environment'

Expand Down Expand Up @@ -165,13 +163,7 @@ export const metaReducers: MetaReducer[] = !environment.production ? [] : []
bootstrap: [AppComponent],
})
export class AppModule {
constructor(
translate: TranslateService,
router: Router,
@Inject(DOCUMENT) private document: Document
) {
translate.setDefaultLang(getDefaultLang())
translate.use(getLangFromBrowser() || getDefaultLang())
constructor(router: Router, @Inject(DOCUMENT) private document: Document) {
ThemeService.applyCssVariables(
getThemeConfig().PRIMARY_COLOR,
getThemeConfig().SECONDARY_COLOR,
Expand Down
11 changes: 2 additions & 9 deletions apps/search/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { FeatureMapModule } from '@geonetwork-ui/feature/map'
import { UiLayoutModule } from '@geonetwork-ui/ui/layout'
import { UiMapModule } from '@geonetwork-ui/ui/map'
import {
getDefaultLang,
UtilI18nModule,
TRANSLATE_GEONETWORK_CONFIG,
} from '@geonetwork-ui/util/i18n'
Expand All @@ -16,7 +15,7 @@ import { FeatureSearchModule } from '@geonetwork-ui/feature/search'
import { EffectsModule } from '@ngrx/effects'
import { MetaReducer, StoreModule } from '@ngrx/store'
import { StoreDevtoolsModule } from '@ngrx/store-devtools'
import { TranslateModule, TranslateService } from '@ngx-translate/core'
import { TranslateModule } from '@ngx-translate/core'
import { storeFreeze } from 'ngrx-store-freeze'
import { environment } from '../environments/environment'
import { AppRoutingModule } from './app-routing.module'
Expand Down Expand Up @@ -57,10 +56,4 @@ export const metaReducers: MetaReducer<any>[] = !environment.production
],
bootstrap: [AppComponent],
})
export class AppModule {
constructor(translate: TranslateService) {
const lang = getDefaultLang()
translate.setDefaultLang(lang)
translate.use(lang)
}
}
export class AppModule {}
6 changes: 3 additions & 3 deletions libs/util/i18n/src/lib/util-i18n.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http'
import { NgModule } from '@angular/core'
import { ApiModule } from '@geonetwork-ui/data-access/gn4'
import { TranslateModule, TranslateService } from '@ngx-translate/core'
import { DEFAULT_LANG } from './i18n.constants'
import { getDefaultLang } from './i18n.constants'
import { I18nInterceptor } from './i18n.interceptor'
import { CommonModule } from '@angular/common'

Expand All @@ -20,7 +20,7 @@ import { CommonModule } from '@angular/common'
})
export class UtilI18nModule {
constructor(translate: TranslateService) {
translate.setDefaultLang(DEFAULT_LANG)
translate.use(DEFAULT_LANG)
translate.setDefaultLang(getDefaultLang())
translate.use(translate.getBrowserLang() || getDefaultLang())
}
}

0 comments on commit 6af4504

Please sign in to comment.