UNPKG

313 BJavaScriptView Raw
1const matchI18nReg = /this.\$t\('?(.*?)'?\)/g
2
3function 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
13exports.replace = replace
14
15function addQuotes (str) {
16 return `'${str}'`
17}