Skip to content

Commit

Permalink
Merged in DSC-1281 (pull request DSpace#929)
Browse files Browse the repository at this point in the history
[DSC-1281] Get repository name from API and include it in i18n title label

Approved-by: Andrea Barbasso
  • Loading branch information
Davide Negretti authored and Andrea Barbasso committed Oct 17, 2023
2 parents 13c6d28 + 32c920c commit 259abd0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
21 changes: 10 additions & 11 deletions src/app/core/metadata/metadata.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,18 @@ export class MetadataService {
}

if (routeInfo.data.value.title) {
const pageName$ = this.rootService.findRoot(true).pipe(
getFirstCompletedRemoteData(),
map((rootRD: RemoteData<Root>) => rootRD.payload.dspaceName),
const repositoryName$ = this.rootService.findRoot(true).pipe(
getFirstSucceededRemoteDataPayload(),
map((payload: Root) => payload.dspaceName),
);
const titlePrefix = repositoryName$.pipe(
switchMap((repositoryName) => this.translate.get('repository.title.prefix', { repositoryName })),
);

const title = this.translate.get(routeInfo.data.value.title, routeInfo.data.value);
combineLatest([ pageName$, title ])
.pipe(take(1))
.subscribe(([ translatedTitlePrefix, translatedTitle ]: [ string, string ]) => {
let finalTitle = translatedTitlePrefix + ' :: ' + translatedTitle;
this.addMetaTag('title', finalTitle);
this.title.setTitle(finalTitle);
});
combineLatest([titlePrefix, title]).pipe(take(1)).subscribe(([translatedTitlePrefix, translatedTitle]: [string, string]) => {
this.addMetaTag('title', translatedTitlePrefix + translatedTitle);
this.title.setTitle(translatedTitlePrefix + translatedTitle);
});
}
if (routeInfo.data.value.description) {
this.translate.get(routeInfo.data.value.description).pipe(take(1)).subscribe((translatedDescription: string) => {
Expand Down
6 changes: 2 additions & 4 deletions src/assets/i18n/en.json5
Original file line number Diff line number Diff line change
Expand Up @@ -4908,11 +4908,9 @@

"repository.image.logo": "Repository logo",

"repository.title.prefix": "DSpace Cris Angular :: ",


"repository.title.prefixDSpace": "DSpace Angular ::",
"repository.title": "{{ repositoryName }}",

"repository.title.prefix": "{{ repositoryName }} Angular :: ",

"resource-policies.add.button": "Add",

Expand Down

0 comments on commit 259abd0

Please sign in to comment.