Skip to content

Commit

Permalink
feat: init translate for solution
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Apr 15, 2020
1 parent aca4714 commit 1987946
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 13 deletions.
23 changes: 12 additions & 11 deletions src/app/presentation/solution/solution.component.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<mat-drawer-container class="solution">
<mat-drawer mode="side" opened class="left-drawer">
<h2>解决方案 <mat-icon class="help-icon"
[matTooltipPosition]="'right'"
matTooltip="为了 Ledge 平台的发展,当前仅免费提供给将 Ledge 列为合作伙伴的 DevOps 厂商。">help</mat-icon></h2>
<h2>{{ 'solution' | translate}}
<mat-icon class="help-icon"
[matTooltipPosition]="'right'"
matTooltip="为了 Ledge 平台的发展,当前仅免费提供给将 Ledge 列为合作伙伴的 DevOps 厂商。">help
</mat-icon>
</h2>
<ul>
<ul>
<li *ngFor="let solution of solutions"
(click)="getCase(solution.source)"
[routerLink]="['/solution', solution.source]"
[ngClass]="solution.source === currentSource ? 'active' : '' ">
<span>{{solution.displayName}}</span>
</li>
</ul>
<li *ngFor="let solution of solutions"
(click)="getCase(solution.source)"
[routerLink]="['/solution', solution.source]"
[ngClass]="solution.source === currentSource ? 'active' : '' ">
<span>{{solution.displayName}}</span>
</li>
</ul>
</mat-drawer>
<mat-drawer-content #drawerContent>
Expand Down
16 changes: 15 additions & 1 deletion src/app/presentation/solution/solution.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,28 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { SolutionComponent } from './solution.component';
import { SharedModule } from '../../shared/shared.module';
import { RouterTestingModule } from '@angular/router/testing';
import {
TranslateFakeLoader,
TranslateLoader,
TranslateModule,
} from '@ngx-translate/core';

describe('SolutionComponent', () => {
let component: SolutionComponent;
let fixture: ComponentFixture<SolutionComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [SharedModule, RouterTestingModule],
imports: [
SharedModule,
RouterTestingModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useClass: TranslateFakeLoader,
},
}),
],
declarations: [SolutionComponent],
}).compileComponents();
}));
Expand Down
4 changes: 3 additions & 1 deletion src/app/presentation/solution/solution.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ActivatedRoute } from '@angular/router';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { MatDrawerContent } from '@angular/material/sidenav';
import { Solution, solutions } from './solutions';
import { TranslateService } from '@ngx-translate/core';

@Component({
selector: 'app-solution',
Expand All @@ -21,7 +22,8 @@ export class SolutionComponent implements OnInit {
constructor(
private title: Title,
private activatedRoute: ActivatedRoute,
private http: HttpClient
private http: HttpClient,
translate: TranslateService
) {}

ngOnInit(): void {
Expand Down
4 changes: 4 additions & 0 deletions src/app/presentation/solution/solution.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { SolutionRoutingModule } from './solution-routing.module';
import { CustomMaterialModule } from 'src/app/shared/custom-material.module';
import { SharedModule } from 'src/app/shared/shared.module';
import { SolutionComponent } from './solution.component';
import { TranslateModule } from '@ngx-translate/core';

@NgModule({
declarations: [SolutionComponent],
Expand All @@ -13,6 +14,9 @@ import { SolutionComponent } from './solution.component';
SolutionRoutingModule,
CustomMaterialModule,
SharedModule,
TranslateModule.forChild({
isolate: false,
}),
],
})
export class SolutionModule {}

0 comments on commit 1987946

Please sign in to comment.