Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@angular/platform-browser-dynamic": "^6.0.0",
"@ngx-translate/core": ">=10.0.0",
"core-js": "^2.5.4",
"deepmerge": "^2.1.1",
"rxjs": "^6.1.0",
"zone.js": "^0.8.26"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {HttpClient} from "@angular/common/http";
import {TranslateLoader} from "@ngx-translate/core";
import {Observable, forkJoin} from "rxjs";
import {map} from "rxjs/operators";
import merge from 'deepmerge';


export interface ITranslationResource {
Expand All @@ -19,6 +20,6 @@ export class MultiTranslateHttpLoader implements TranslateLoader {
const requests = this.resources.map(resource => {
return this.http.get(resource.prefix + lang + resource.suffix);
});
return forkJoin(requests).pipe(map(response => response.reduce((a, b) => Object.assign(a, b))));
return forkJoin(requests).pipe(map(response => merge.all(response)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,17 @@ describe('MultiTranslateHttpLoader - Multiple Translation Files', () => {
// mock response after the xhr request, otherwise it will be undefined
http.expectOne('/assets/i18n/core/en.json').flush({
"TEST": "This is a test (core)",
"TEST2": "This is another test (core)"
"TEST2": "This is another test (core)",
"DEEP": {
"some": "thing"
}
});
http.expectOne('/assets/i18n/shared/en.json').flush({
"TEST-SHARED": "This is a test (shared)",
"TEST2-SHARED": "This is another test (shared)"
"TEST2-SHARED": "This is another test (shared)",
"DEEP": {
"another": "something"
}
});

// this will request the translation from downloaded translations without making a request to the backend
Expand All @@ -165,5 +171,11 @@ describe('MultiTranslateHttpLoader - Multiple Translation Files', () => {
translate.get('TEST2-SHARED').subscribe((res: string) => {
expect(res).toEqual('This is another test (shared)');
});
translate.get('DEEP').subscribe((res: any) => {
expect(res).toEqual({
"some": "thing",
"another": "something"
});
});
});
});