Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

does not report parsing failure if a duplicate json key gets inserted when merging two translation json files #1491

Open
folsze opened this issue Sep 18, 2024 · 0 comments

Comments

@folsze
Copy link

folsze commented Sep 18, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant