-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
01cbc00
commit 1b23626
Showing
8 changed files
with
186 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,6 @@ | ||
{ | ||
"demo": { | ||
"greeting": "Hallo {name}!", | ||
"text": "Dies ist eine einfache Applikation um die Funktionen von ngx-transalte zu demonstrieren.", | ||
"title": "Übersetzungs-Demo" | ||
}, | ||
"icu": { | ||
"pluralization": "Da {count, plural, =0{ist kein Apfel} one{ist ein Apfel} other{sind mehrere Äpfel}}.", | ||
"select": "{gender, select, male{Er verwendet} female{Sie verwendet} other{Sie verwenden }} {product}." | ||
}, | ||
"messagebox": { | ||
"warning": { | ||
"text": "Warnung!" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,6 @@ | ||
{ | ||
"demo": { | ||
"greeting": "Hello {name}!", | ||
"text": "This is a simple demonstration app for ngx-translate", | ||
"title": "Translation demo" | ||
}, | ||
"icu": { | ||
"pluralization": "There {count, plural, =0{is no apple} one{is one apple} other{there are several apples}}.", | ||
"select": "{gender, select, male{He uses} female{She uses} other{They use }} {product}" | ||
}, | ||
"messagebox": { | ||
"warning": { | ||
"text": "Warning!" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
ngx-translate-demo-standalone-icu/src/app/app.component.i18n.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
import { AppComponent } from './app.component'; | ||
import {} from 'jasmine'; | ||
import {TranslateCompiler, TranslateLoader, TranslateModule, TranslateService} from "@ngx-translate/core"; | ||
import {StaticTranslationLoader} from "./static-translations-loader"; | ||
import {TranslateMessageFormatCompiler} from "ngx-translate-messageformat-compiler"; | ||
|
||
|
||
describe('AppComponent Localized', () => { | ||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [ | ||
AppComponent, | ||
TranslateModule.forRoot({ | ||
loader: { | ||
provide: TranslateLoader, | ||
useClass: StaticTranslationLoader, | ||
}, | ||
compiler: { | ||
provide: TranslateCompiler, | ||
useClass: TranslateMessageFormatCompiler | ||
} | ||
})], | ||
providers: [] | ||
}).compileComponents(); | ||
|
||
const translateService = TestBed.inject(TranslateService); | ||
translateService.addLangs(["de", "en"]); | ||
translateService.setDefaultLang('en'); | ||
}); | ||
|
||
|
||
it('should create the app', () => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
const app = fixture.componentInstance; | ||
expect(app).toBeTruthy(); | ||
}); | ||
|
||
|
||
it('should render pluralization for 0 in english (default)', () => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
fixture.detectChanges(); | ||
const compiled = fixture.nativeElement as HTMLElement; | ||
expect(compiled.querySelector('#icuPluralization')?.textContent).toContain('There is no apple.'); | ||
}); | ||
|
||
|
||
it('should render pluralization for 0 in german', () => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
fixture.detectChanges(); | ||
|
||
const translateService = TestBed.inject(TranslateService); | ||
translateService.use('de'); | ||
|
||
fixture.detectChanges(); | ||
const compiled = fixture.nativeElement as HTMLElement; | ||
expect(compiled.querySelector('#icuPluralization')?.textContent).toContain('Da ist kein Apfel.'); | ||
}); | ||
|
||
|
||
it('should render pluralization for 1 in English (default) after selecting from combo box', () => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
fixture.detectChanges(); | ||
|
||
const compiled = fixture.nativeElement as HTMLElement; | ||
|
||
const selectElement = compiled.querySelector('#count-select') as HTMLSelectElement; | ||
selectElement.value = '1'; | ||
selectElement.dispatchEvent(new Event('change')); | ||
fixture.detectChanges(); | ||
|
||
expect(compiled.querySelector('#icuPluralization')?.textContent).toContain('There is one apple.'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 4 additions & 55 deletions
59
ngx-translate-demo-standalone-icu/src/app/app.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,23 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
import { AppComponent } from './app.component'; | ||
import {} from 'jasmine'; | ||
import {TranslateCompiler, TranslateLoader, TranslateModule, TranslateService} from "@ngx-translate/core"; | ||
import {StaticTranslationLoader} from "./static-translations-loader"; | ||
import {TranslateMessageFormatCompiler} from "ngx-translate-messageformat-compiler"; | ||
import {TranslateModule} from "@ngx-translate/core"; | ||
|
||
|
||
describe('AppComponent Localized', () => { | ||
describe('AppComponent', () => { | ||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [ | ||
AppComponent, | ||
TranslateModule.forRoot({ | ||
loader: { | ||
provide: TranslateLoader, | ||
useClass: StaticTranslationLoader, | ||
}, | ||
compiler: { | ||
provide: TranslateCompiler, | ||
useClass: TranslateMessageFormatCompiler | ||
} | ||
})], | ||
providers: [] | ||
TranslateModule.forRoot({}) | ||
], | ||
}).compileComponents(); | ||
|
||
const translateService = TestBed.inject(TranslateService); | ||
translateService.addLangs(["de", "en"]); | ||
translateService.setDefaultLang('en'); | ||
}); | ||
|
||
|
||
it('should create the app', () => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
const app = fixture.componentInstance; | ||
expect(app).toBeTruthy(); | ||
}); | ||
|
||
|
||
it('should render pluralization for 0 in english (default)', () => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
fixture.detectChanges(); | ||
const compiled = fixture.nativeElement as HTMLElement; | ||
expect(compiled.querySelector('#icuPluralization')?.textContent).toContain('There is no apple.'); | ||
}); | ||
|
||
|
||
it('should render pluralization for 0 in german', () => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
fixture.detectChanges(); | ||
|
||
const translateService = TestBed.inject(TranslateService); | ||
translateService.use('de'); | ||
|
||
fixture.detectChanges(); | ||
const compiled = fixture.nativeElement as HTMLElement; | ||
expect(compiled.querySelector('#icuPluralization')?.textContent).toContain('Da ist kein Apfel.'); | ||
}); | ||
|
||
|
||
it('should render pluralization for 1 in English (default) after selecting from combo box', () => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
fixture.detectChanges(); | ||
|
||
const compiled = fixture.nativeElement as HTMLElement; | ||
|
||
const selectElement = compiled.querySelector('#count-select') as HTMLSelectElement; | ||
selectElement.value = '1'; | ||
selectElement.dispatchEvent(new Event('change')); | ||
fixture.detectChanges(); | ||
|
||
expect(compiled.querySelector('#icuPluralization')?.textContent).toContain('There is one apple.'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.