fix(ivy): don't throw on unmatched placeholder replacements in i18nPostprocess
(#30632)
Depending on which placeholders the translation uses, there are some legitimate cases where we might not use all placeholder replacements in `i18nPostprocess`. For example if some of the placeholders of the original messages have been removed in the translation. FW-1312 #resolve PR Close #30632
This commit is contained in:

committed by
Matias Niemelä

parent
9b3af1468d
commit
68cd0cab8c
@ -780,22 +780,10 @@ describe('Runtime i18n', () => {
|
||||
});
|
||||
|
||||
it('should throw in case we have invalid string', () => {
|
||||
const arr = ['<27>*1:1<><31>#2:1<>', '<27>#4:2<>', '<27>6:4<>', '<27>/#2:1<><31>/*1:1<>'];
|
||||
const str = `[${arr.join('|')}]`;
|
||||
|
||||
const cases = [
|
||||
// less placeholders than we have
|
||||
[`Start: ${str}, ${str} and ${str} end.`, {}],
|
||||
|
||||
// more placeholders than we have
|
||||
[`Start: ${str}, ${str} and ${str}, ${str} ${str} end.`, {}],
|
||||
|
||||
// not enough ICU replacements
|
||||
['My ICU #1: <20>I18N_EXP_ICU<43>, My ICU #2: <20>I18N_EXP_ICU<43>', {ICU: ['ICU_VALUE_1']}]
|
||||
];
|
||||
cases.forEach(([input, replacements, output]) => {
|
||||
expect(() => ɵɵi18nPostprocess(input as string, replacements as any)).toThrowError();
|
||||
});
|
||||
expect(
|
||||
() => ɵɵi18nPostprocess(
|
||||
'My ICU #1: <20>I18N_EXP_ICU<43>, My ICU #2: <20>I18N_EXP_ICU<43>', {ICU: ['ICU_VALUE_1']}))
|
||||
.toThrowError();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user