Skip to content

Commit

Permalink
Merge pull request #1 from camptocamp/i18n
Browse files Browse the repository at this point in the history
Finalize i18n setup
  • Loading branch information
tkohr authored Jan 17, 2024
2 parents 1d86867 + 7fa0a9e commit a7e8e46
Show file tree
Hide file tree
Showing 7 changed files with 526 additions and 125 deletions.
4 changes: 2 additions & 2 deletions apps/datahub/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { RouterModule } from '@angular/router'
import { AppComponent } from './app.component'
import {
DefaultRouterModule,
EmbeddedTranslateLoader,
FeatureAuthModule,
FeatureCatalogModule,
FeatureSearchModule,
Expand Down Expand Up @@ -34,6 +33,7 @@ import { HomePageComponent } from './home/home-page/home-page.component'
import { AppRouterService } from './app.router.service'
import { HomeHeaderComponent } from './home/home-header/home-header.component'
import { MatIconModule } from '@angular/material/icon'
import { MelEmbeddedTranslateLoader } from './common/embedded.translate.loader'

@NgModule({
declarations: [
Expand All @@ -60,7 +60,7 @@ import { MatIconModule } from '@angular/material/icon'
...TRANSLATE_DEFAULT_CONFIG,
loader: {
provide: TranslateLoader,
useClass: EmbeddedTranslateLoader,
useClass: MelEmbeddedTranslateLoader,
},
}),
StoreModule.forRoot(
Expand Down
15 changes: 15 additions & 0 deletions apps/datahub/src/app/common/embedded.translate.loader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { TranslateLoader } from '@ngx-translate/core'
import { Observable, map, of } from 'rxjs'
import en_MEL from '../../assets/i18n/en_MEL.json'
import fr_MEL from '../../assets/i18n/fr_MEL.json'
import en from 'node_modules/geonetwork-ui/translations/en.json'
import fr from 'node_modules/geonetwork-ui/translations/fr.json'
import { dropEmptyTranslations } from 'geonetwork-ui'

export class MelEmbeddedTranslateLoader implements TranslateLoader {
getTranslation(lang: string): Observable<any> {
const langs = { en: { ...en, ...en_MEL }, fr: { ...fr, ...fr_MEL } }
const translations = langs[lang.substring(0, 2)]
return of(translations).pipe(map(dropEmptyTranslations))
}
}
5 changes: 5 additions & 0 deletions apps/datahub/src/assets/i18n/en_MEL.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"mel.common.header.title": "",
"mel.datahub.home.title": "",
"mel.datahub.search.title": ""
}
5 changes: 5 additions & 0 deletions apps/datahub/src/assets/i18n/fr_MEL.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"mel.common.header.title": "Data platform",
"mel.datahub.home.title": "Métropole Européenne Lille",
"mel.datahub.search.title": "Catalogue de jeux de données"
}
Loading

0 comments on commit a7e8e46

Please sign in to comment.