fix(ivy): avoid duplicate i18n consts to be present in generated output (#28967)
Prior to this change, the logic that outputs i18n consts (like `const MSG_XXX = goog.getMsg(...)`) didn't have a check whether a given const that represent a certain i18n message was already included into the generated output. This commit adds the logic to mark corresponding i18n contexts after translation was generated, to avoid duplicate consts in the output. PR Close #28967
This commit is contained in:
@ -42,6 +42,7 @@ export class I18nContext {
|
||||
public readonly id: number;
|
||||
public bindings = new Set<o.Expression>();
|
||||
public placeholders = new Map<string, any[]>();
|
||||
public isEmitted: boolean = false;
|
||||
|
||||
private _registry !: any;
|
||||
private _unresolvedCtxCount: number = 0;
|
||||
|
@ -373,8 +373,9 @@ export class TemplateDefinitionBuilder implements t.Visitor<void>, LocalResolver
|
||||
}
|
||||
|
||||
i18nUpdateRef(context: I18nContext): void {
|
||||
const {icus, meta, isRoot, isResolved} = context;
|
||||
if (isRoot && isResolved && !isSingleI18nIcu(meta)) {
|
||||
const {icus, meta, isRoot, isResolved, isEmitted} = context;
|
||||
if (isRoot && isResolved && !isEmitted && !isSingleI18nIcu(meta)) {
|
||||
context.isEmitted = true;
|
||||
const placeholders = context.getSerializedPlaceholders();
|
||||
let icuMapping: {[name: string]: o.Expression} = {};
|
||||
let params: {[name: string]: o.Expression} =
|
||||
|
Reference in New Issue
Block a user