1 | const matchI18nReg = /this.\$t\('?(.*?)'?\)/g
|
2 |
|
3 | function replace (code, map = {}, options = {}) {
|
4 | if (!code) {
|
5 | return
|
6 | }
|
7 | code = code.replace(matchI18nReg, function (a, b) {
|
8 | return addQuotes(map[b] || b)
|
9 | })
|
10 | return code
|
11 | }
|
12 |
|
13 | exports.replace = replace
|
14 |
|
15 | function addQuotes (str) {
|
16 | return `'${str}'`
|
17 | }
|