initial i18n messages for loading and error components

This commit is contained in:
William Welling
2017-10-05 08:24:19 -05:00
parent 5b45871bff
commit cb72e4db07
13 changed files with 101 additions and 26 deletions

View File

@@ -8,7 +8,8 @@ span {
}
span[class*="l-"] {
height: 4px; width: 4px;
height: 4px;
width: 4px;
background: #000;
display: inline-block;
margin: 12px 2px;

View File

@@ -2,6 +2,10 @@ import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { TranslateModule, TranslateLoader, TranslateService } from '@ngx-translate/core';
import { MockTranslateLoader } from '../testing/mock-translate-loader';
import { LoadingComponent } from './loading.component';
describe('LoadingComponent (inline template)', () => {
@@ -13,7 +17,16 @@ describe('LoadingComponent (inline template)', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useClass: MockTranslateLoader
}
}),
],
declarations: [ LoadingComponent ], // declare the test component
providers: [ TranslateService ]
}).compileComponents(); // compile template and css
}));

View File

@@ -1,12 +1,36 @@
import { Component, Input } from '@angular/core';
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Subscription } from 'rxjs/Subscription';
@Component({
selector: 'ds-loading',
styleUrls: ['./loading.component.scss'],
templateUrl: './loading.component.html'
})
export class LoadingComponent {
export class LoadingComponent implements OnDestroy, OnInit {
@Input() message = 'Loading...';
@Input() message: string;
private subscription: Subscription;
constructor(private translate: TranslateService) {
}
ngOnInit() {
if (this.message === undefined) {
this.subscription = this.translate.get('loading.default').subscribe((message: string) => {
this.message = message;
});
}
}
ngOnDestroy() {
if (this.subscription !== undefined) {
this.subscription.unsubscribe();
}
}
}