@@ -10,8 +10,10 @@ import {MissingTranslationStrategy} from '@angular/core';
10
10
11
11
import * as i18n from '../../src/i18n/i18n_ast' ;
12
12
import { TranslationBundle } from '../../src/i18n/translation_bundle' ;
13
+ import * as html from '../../src/ml_parser/ast' ;
13
14
import { ParseLocation , ParseSourceFile , ParseSourceSpan } from '../../src/parse_util' ;
14
15
import { serializeNodes } from '../ml_parser/ast_serializer_spec' ;
16
+
15
17
import { _extractMessages } from './i18n_parser_spec' ;
16
18
17
19
{
@@ -22,13 +24,24 @@ import {_extractMessages} from './i18n_parser_spec';
22
24
const span = new ParseSourceSpan ( startLocation , endLocation ) ;
23
25
const srcNode = new i18n . Text ( 'src' , span ) ;
24
26
25
- it ( 'should translate a plain message ' , ( ) => {
27
+ it ( 'should translate a plain text ' , ( ) => {
26
28
const msgMap = { foo : [ new i18n . Text ( 'bar' , null ! ) ] } ;
27
29
const tb = new TranslationBundle ( msgMap , null , ( _ ) => 'foo' ) ;
28
30
const msg = new i18n . Message ( [ srcNode ] , { } , { } , 'm' , 'd' , 'i' ) ;
29
31
expect ( serializeNodes ( tb . get ( msg ) ) ) . toEqual ( [ 'bar' ] ) ;
30
32
} ) ;
31
33
34
+ it ( 'should translate html-like plain text' , ( ) => {
35
+ const msgMap = { foo : [ new i18n . Text ( '<p>bar</p>' , null ! ) ] } ;
36
+ const tb = new TranslationBundle ( msgMap , null , ( _ ) => 'foo' ) ;
37
+ const msg = new i18n . Message ( [ srcNode ] , { } , { } , 'm' , 'd' , 'i' ) ;
38
+ const nodes = tb . get ( msg ) ;
39
+ expect ( nodes . length ) . toEqual ( 1 ) ;
40
+ const textNode : html . Text = nodes [ 0 ] as any ;
41
+ expect ( textNode instanceof html . Text ) . toEqual ( true ) ;
42
+ expect ( textNode . value ) . toBe ( '<p>bar</p>' ) ;
43
+ } ) ;
44
+
32
45
it ( 'should translate a message with placeholder' , ( ) => {
33
46
const msgMap = {
34
47
foo : [
0 commit comments