Texts changed to I18n

pull/6929/head
Inga Mai 6 years ago committed by Wieland Lindenthal
parent 84738727d0
commit 4e643d3efd
  1. 4
      config/locales/js-en.yml
  2. 4
      frontend/src/app/components/global-search/global-search-title.component.html
  3. 26
      frontend/src/app/components/global-search/global-search-title.component.ts

@ -838,4 +838,6 @@ en:
search: "Search"
this_project: "In this project"
this_project_and_all_descendants: "In this project + subprojects"
title:
all_projects: "all projects"
project_and_subprojects: "and all subprojects"

@ -1,12 +1,12 @@
<div class="toolbar-container">
<div class="toolbar">
<div class="title-container">
<h2 [attr.title]="searchTerm">
<h2 [attr.title]="searchTitle">
Search for
<i>"{{ searchTerm }}"</i>
{{ project !== '' ? 'in' : ''}}
<i>{{ project }}</i>
{{ projectScope === '' ? 'and all Subprojects' : ''}} </h2>
</h2>
<ul class="toolbar-items"></ul>
</div>
</div>

@ -36,6 +36,7 @@ import {DynamicBootstrapper} from "core-app/globals/dynamic-bootstrapper";
import {distinctUntilChanged} from 'rxjs/operators';
import {untilComponentDestroyed} from 'ng2-rx-componentdestroyed';
import {combineLatest} from 'rxjs';
import {I18nService} from 'core-app/modules/common/i18n/i18n.service';
import {GlobalSearchService} from "core-components/global-search/global-search.service";
import {CurrentProjectService} from "core-components/projects/current-project.service";
import {Injector} from "@angular/core";
@ -51,12 +52,19 @@ export class GlobalSearchTitleComponent implements OnDestroy {
@Input() public searchTerm:string;
@Input() public project:string;
@Input() public projectScope:string;
@Input() public searchTitle:string;
private currentProjectService:CurrentProjectService = this.injector.get(CurrentProjectService);
public text:{ [key:string]:string } = {
all_projects: this.I18n.t('js.global_search.title.all_projects'),
project_and_subprojects: this.I18n.t('js.global_search.title.project_and_subprojects')
};
constructor(readonly elementRef:ElementRef,
readonly cdRef:ChangeDetectorRef,
readonly globalSearchService:GlobalSearchService,
readonly I18n:I18nService,
protected injector:Injector) {
}
@ -72,8 +80,8 @@ export class GlobalSearchTitleComponent implements OnDestroy {
)
.subscribe(([newSearchTerm, newProjectScope]) => {
this.searchTerm = newSearchTerm;
this.projectScope = newProjectScope;
this.project = this.projectText(newProjectScope);
this.searchTitle = 'Search for ' + this.searchTerm + ' in ' + this.project;
this.cdRef.detectChanges();
});
@ -86,10 +94,18 @@ export class GlobalSearchTitleComponent implements OnDestroy {
private projectText(scope:string):string {
let currentProjectName = this.currentProjectService.name ? this.currentProjectService.name : '';
if(scope === 'all') {
return 'all projects';
} else {
return currentProjectName;
switch(scope){
case 'all':
return this.text.all_projects;
break;
case 'current_project':
return currentProjectName;
break;
case '':
return currentProjectName + ' ' + this.text.project_and_subprojects;
break;
default:
return '';
}
}
}

Loading…
Cancel
Save