core
core copied to clipboard
does not report parsing failure if a duplicate json key gets inserted when merging two translation json files
very easy to reproduce: (german example)
de.json: "World Countries": "Länder der Welt"
locations/de.json: "World Countries": { "Germany": "Deutschland" }
Then when I merge with this, it will either take the first or second key, never both:
await this.appTranslate.loadAdditionalTranslations("de");
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { TranslateService } from '@ngx-translate/core';
import { firstValueFrom } from 'rxjs';
@Injectable({providedIn: 'root'})
export class AppTranslationService {
constructor(
private http: HttpClient,
private translate: TranslateService,
) { }
public loadAdditionalTranslations(lang: string) {
const url = `assets/i18n/location-collections/${lang}.json`;
return firstValueFrom(this.http.get(url)).then((data: any) => {
this.translate.setTranslation(lang, data, true);
});
}
}
I don't know how such an important used library has such a bug of this not being reported as an error.