|
1 | 1 | import { SFCDescriptor, SFCBlock } from 'vue-template-compiler'
|
2 | 2 | import { Locale, MetaLocaleMessage, SFCI18nBlock, SFCFileInfo } from '../types'
|
3 | 3 |
|
4 |
| -import { escape, reflectSFCDescriptor, parseContent, stringfyContent } from './utils' |
5 |
| -import prettier from 'prettier' |
| 4 | +import { escape, reflectSFCDescriptor, parseContent, stringifyContent } from './utils' |
6 | 5 |
|
7 | 6 | import { debug as Debug } from 'debug'
|
8 | 7 | const debug = Debug('vue-i18n-locale-message:infuser')
|
@@ -30,7 +29,7 @@ function generate (meta: MetaLocaleMessage, descriptor: SFCDescriptor): string {
|
30 | 29 | debug(`build content:\n${content}`)
|
31 | 30 | debug(`content size: raw=${raw.length}, content=${content.length}`)
|
32 | 31 |
|
33 |
| - return format(content, 'vue') |
| 32 | + return content |
34 | 33 | }
|
35 | 34 |
|
36 | 35 | function getBlocks (descriptor: SFCDescriptor): SFCBlock[] {
|
@@ -68,7 +67,7 @@ function buildContent (i18nBlocks: SFCI18nBlock[], raw: string, blocks: SFCBlock
|
68 | 67 | }
|
69 | 68 |
|
70 | 69 | contents = contents.concat(raw.slice(offset, block.start))
|
71 |
| - const serialized = `\n${format(stringfyContent(messages, lang), lang)}` |
| 70 | + const serialized = `\n${stringifyContent(messages, lang), lang}` |
72 | 71 | contents = contents.concat(serialized)
|
73 | 72 | offset = block.end as number
|
74 | 73 | i18nBlockCounter++
|
@@ -103,22 +102,5 @@ function buildI18nTag (i18nBlock: SFCI18nBlock): string {
|
103 | 102 |
|
104 | 103 | return `\n
|
105 | 104 | ${tag}
|
106 |
| -${format(stringfyContent(locale ? messages[locale] : messages, lang), lang)}</i18n>` |
107 |
| -} |
108 |
| - |
109 |
| -function format (source: string, lang: string): string { |
110 |
| - debug(`format: lang=${lang}, source=${source}`) |
111 |
| - |
112 |
| - switch (lang) { |
113 |
| - case 'vue': |
114 |
| - return source |
115 |
| - case 'yaml': |
116 |
| - case 'yml': |
117 |
| - return prettier.format(source, { parser: 'yaml', tabWidth: 2 }) |
118 |
| - case 'json5': |
119 |
| - return prettier.format(source, { parser: 'json5', tabWidth: 2 }) |
120 |
| - case 'json': |
121 |
| - default: |
122 |
| - return prettier.format(source, { parser: 'json-stringify', tabWidth: 2 }) |
123 |
| - } |
| 105 | +${stringifyContent(locale ? messages[locale] : messages, lang), lang}</i18n>` |
124 | 106 | }
|
0 commit comments