fix(ivy): process property bindings in i18n blocks similar to non-i18n bindings (#28969)
Prior to this change i18n block bindings were converted to Expressions right away (once we first access them), when in non-i18n cases we processed them differently: the actual conversion happens at instructions generation. Because of this discrepancy, the output for bindings in i18n blocks was generated incorrectly (with invalid indicies in pipeBindN fns and invalid references to non-existent local variables). Now the bindings processing is unified and i18nExp instructions should contain right bind expressions. PR Close #28969
This commit is contained in:
@ -23,6 +23,7 @@ class DirectiveWithTplRef {
|
||||
class MyComp {
|
||||
name = 'John';
|
||||
items = ['1', '2', '3'];
|
||||
obj = {a: {b: 'value'}};
|
||||
visible = true;
|
||||
age = 20;
|
||||
count = 2;
|
||||
@ -42,6 +43,7 @@ const TRANSLATIONS: any = {
|
||||
'Item {$interpolation}': 'Article {$interpolation}',
|
||||
'\'Single quotes\' and "Double quotes"': '\'Guillemets simples\' et "Guillemets doubles"',
|
||||
'My logo': 'Mon logo',
|
||||
'{$interpolation} - {$interpolation_1}': '{$interpolation} - {$interpolation_1} (fr)',
|
||||
'{$startTagSpan}My logo{$tagImg}{$closeTagSpan}':
|
||||
'{$startTagSpan}Mon logo{$tagImg}{$closeTagSpan}',
|
||||
'{$startTagNgTemplate} Hello {$closeTagNgTemplate}{$startTagNgContainer} Bye {$closeTagNgContainer}':
|
||||
@ -175,6 +177,13 @@ onlyInIvy('Ivy i18n logic').describe('i18n', function() {
|
||||
expect(element).toHaveText('Bonjour John');
|
||||
});
|
||||
|
||||
it('should support interpolations with complex expressions', () => {
|
||||
const template = `<div i18n>{{ name | uppercase }} - {{ obj?.a?.b }}</div>`;
|
||||
const fixture = getFixtureWithOverrides({template});
|
||||
const element = fixture.nativeElement.firstChild;
|
||||
expect(element).toHaveText('JOHN - value (fr)');
|
||||
});
|
||||
|
||||
it('should properly escape quotes in content', () => {
|
||||
const content = `'Single quotes' and "Double quotes"`;
|
||||
const template = `<div i18n>${content}</div>`;
|
||||
|
Reference in New Issue
Block a user