refactor(localize): hide merging diagnostics messages behind a method (#36792)
This commit introduces `Diagnostics.merge(other)` which will take the messages from `other` and append them to the messages of `this`. The translation loader is updated to use this new method. PR Close #36792
This commit is contained in:
parent
bf0c520f2e
commit
3cb9b43851
|
@ -31,6 +31,9 @@ export class Diagnostics {
|
|||
error(message: string) {
|
||||
this.messages.push({type: 'error', message});
|
||||
}
|
||||
merge(other: Diagnostics) {
|
||||
this.messages.push(...other.messages);
|
||||
}
|
||||
formatDiagnostics(message: string): string {
|
||||
const errors = this.messages!.filter(d => d.type === 'error').map(d => ' - ' + d.message);
|
||||
const warnings = this.messages!.filter(d => d.type === 'warning').map(d => ' - ' + d.message);
|
||||
|
|
|
@ -64,7 +64,7 @@ export class TranslationLoader {
|
|||
|
||||
// If we were passed a diagnostics object then copy the messages over to it.
|
||||
if (this.diagnostics) {
|
||||
this.diagnostics.messages.push(...diagnostics.messages);
|
||||
this.diagnostics.merge(diagnostics);
|
||||
}
|
||||
|
||||
return {locale, translations, diagnostics};
|
||||
|
|
Loading…
Reference in New Issue