@@ -3,23 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
const utils_1 = require ( "./utils" ) ;
4
4
const debug_1 = require ( "debug" ) ;
5
5
const debug = debug_1 . debug ( 'vue-i18n-locale-message:infuser' ) ;
6
- function infuse ( basePath , sources , meta ) {
6
+ function infuse ( basePath , sources , meta , options ) {
7
7
const descriptors = utils_1 . reflectSFCDescriptor ( basePath , sources ) ;
8
8
return descriptors . map ( descriptor => {
9
9
return {
10
- content : generate ( meta , descriptor ) ,
10
+ content : generate ( meta , descriptor , options ) ,
11
11
path : descriptor . contentPath
12
12
} ;
13
13
} ) ;
14
14
}
15
15
exports . default = infuse ;
16
- function generate ( meta , descriptor ) {
16
+ function generate ( meta , descriptor , options ) {
17
17
const i18nBlocks = meta . components [ descriptor . contentPath ] ;
18
18
debug ( 'target i18n blocks\n' , i18nBlocks ) ;
19
19
const blocks = getBlocks ( descriptor ) ;
20
20
blocks . forEach ( b => debug ( `block: type=${ b . type } , start=${ b . start } , end=${ b . end } ` ) ) ;
21
21
const { raw } = descriptor ;
22
- const content = buildContent ( i18nBlocks , raw , blocks ) ;
22
+ const content = buildContent ( i18nBlocks , raw , blocks , options ) ;
23
23
debug ( `build content:\n${ content } ` ) ;
24
24
debug ( `content size: raw=${ raw . length } , content=${ content . length } ` ) ;
25
25
return content ;
@@ -32,7 +32,7 @@ function getBlocks(descriptor) {
32
32
blocks . sort ( ( a , b ) => { return a . start - b . start ; } ) ;
33
33
return blocks ;
34
34
}
35
- function buildContent ( i18nBlocks , raw , blocks ) {
35
+ function buildContent ( i18nBlocks , raw , blocks , options ) {
36
36
let offset = 0 ;
37
37
let i18nBlockCounter = 0 ;
38
38
let contents = [ ] ;
@@ -57,7 +57,7 @@ function buildContent(i18nBlocks, raw, blocks) {
57
57
messages = utils_1 . parseContent ( block . content , lang ) ;
58
58
}
59
59
contents = contents . concat ( raw . slice ( offset , block . start ) ) ;
60
- const serialized = `\n${ utils_1 . stringifyContent ( messages , lang ) } ` ;
60
+ const serialized = `\n${ utils_1 . stringifyContent ( messages , lang , options ) } ` ;
61
61
contents = contents . concat ( serialized ) ;
62
62
offset = block . end ;
63
63
i18nBlockCounter ++ ;
@@ -71,13 +71,13 @@ function buildContent(i18nBlocks, raw, blocks) {
71
71
contents = contents . concat ( raw . slice ( offset , raw . length ) ) ;
72
72
if ( i18nBlocks . length > i18nBlockCounter ) {
73
73
i18nBlocks . slice ( i18nBlockCounter ) . reduce ( ( contents , i18nBlock ) => {
74
- contents . push ( buildI18nTag ( i18nBlock ) ) ;
74
+ contents . push ( buildI18nTag ( i18nBlock , options ) ) ;
75
75
return contents ;
76
76
} , contents ) ;
77
77
}
78
78
return contents . join ( '' ) ;
79
79
}
80
- function buildI18nTag ( i18nBlock ) {
80
+ function buildI18nTag ( i18nBlock , options ) {
81
81
const { locale, lang, messages } = i18nBlock ;
82
82
let tag = '<i18n' ;
83
83
if ( locale ) {
@@ -89,5 +89,5 @@ function buildI18nTag(i18nBlock) {
89
89
tag += '>' ;
90
90
return `\n
91
91
${ tag }
92
- ${ utils_1 . stringifyContent ( locale ? messages [ locale ] : messages , lang ) } </i18n>`;
92
+ ${ utils_1 . stringifyContent ( locale ? messages [ locale ] : messages , lang , options ) } </i18n>`;
93
93
}
0 commit comments