From 986780a39a1ae83cdcae1874ae0d29e7d2cd0cdc Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 15 Apr 2018 02:51:29 +0900 Subject: [PATCH] wip --- src/build/fa.ts | 2 +- webpack.config.ts | 6 ++++-- webpack/loaders/replace.js | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/build/fa.ts b/src/build/fa.ts index 0c21be950..f6f2427d0 100644 --- a/src/build/fa.ts +++ b/src/build/fa.ts @@ -14,7 +14,7 @@ fontawesome.library.add(brands); export const pattern = /%fa:(.+?)%/g; -export const replacement = (_, key) => { +export const replacement = (match, key) => { const args = key.split(' '); let prefix = 'fas'; const classes = []; diff --git a/webpack.config.ts b/webpack.config.ts index 60dbfd2ff..b0b06c739 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -143,7 +143,8 @@ module.exports = entries.map(x => { loader: 'replace', query: { search: i18nReplacer.pattern.toString(), - replace: 'i18nReplacement' + replace: 'i18nReplacement', + i18n: true } }, { loader: 'replace', @@ -214,7 +215,8 @@ module.exports = entries.map(x => { loader: 'replace', query: { search: i18nReplacer.pattern.toString(), - replace: 'i18nReplacement' + replace: 'i18nReplacement', + i18n: true } }, { loader: 'replace', diff --git a/webpack/loaders/replace.js b/webpack/loaders/replace.js index 8018e9cec..9897fe37d 100644 --- a/webpack/loaders/replace.js +++ b/webpack/loaders/replace.js @@ -10,9 +10,9 @@ module.exports = function(src) { const search = options.search; const g = search[search.length - 1] == 'g'; const file = this.resourcePath.replace(/\\/g, '/'); - const replace = global[options.replace].bind(null, { + const replace = options.i18n ? global[options.replace].bind(null, { src: file - }); + }) : global[options.replace]; if (typeof search != 'string' || search.length == 0) console.error('invalid search'); if (typeof replace != 'function') console.error('invalid replacer:', replace, this.request); src = src.replace(new RegExp(trim(search, g), g ? 'g' : ''), replace);