なんかもうめっちゃ変えた
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import rules from './rules';
|
||||
|
||||
export default (lang, locale) => ({
|
||||
rules: rules(lang, locale)
|
||||
export default lang => ({
|
||||
rules: rules(lang)
|
||||
});
|
||||
|
@ -3,16 +3,7 @@
|
||||
*/
|
||||
|
||||
const StringReplacePlugin = require('string-replace-webpack-plugin');
|
||||
|
||||
import * as fontawesome from '@fortawesome/fontawesome';
|
||||
import * as regular from '@fortawesome/fontawesome-free-regular';
|
||||
import * as solid from '@fortawesome/fontawesome-free-solid';
|
||||
import * as brands from '@fortawesome/fontawesome-free-brands';
|
||||
|
||||
// Add icons
|
||||
fontawesome.library.add(regular);
|
||||
fontawesome.library.add(solid);
|
||||
fontawesome.library.add(brands);
|
||||
import { pattern, replacement } from '../../../src/common/build/fa';
|
||||
|
||||
export default () => ({
|
||||
enforce: 'pre',
|
||||
@ -20,41 +11,7 @@ export default () => ({
|
||||
exclude: /node_modules/,
|
||||
loader: StringReplacePlugin.replace({
|
||||
replacements: [{
|
||||
pattern: /%fa:(.+?)%/g, replacement: (_, key) => {
|
||||
const args = key.split(' ');
|
||||
let prefix = 'fas';
|
||||
const classes = [];
|
||||
let transform = '';
|
||||
let name;
|
||||
|
||||
args.forEach(arg => {
|
||||
if (arg == 'R' || arg == 'S' || arg == 'B') {
|
||||
prefix =
|
||||
arg == 'R' ? 'far' :
|
||||
arg == 'S' ? 'fas' :
|
||||
arg == 'B' ? 'fab' :
|
||||
'';
|
||||
} else if (arg[0] == '.') {
|
||||
classes.push('fa-' + arg.substr(1));
|
||||
} else if (arg[0] == '-') {
|
||||
transform = arg.substr(1).split('|').join(' ');
|
||||
} else {
|
||||
name = arg;
|
||||
}
|
||||
});
|
||||
|
||||
const icon = fontawesome.icon({ prefix, iconName: name }, {
|
||||
classes: classes
|
||||
});
|
||||
|
||||
if (icon) {
|
||||
icon.transform = fontawesome.parse.transform(transform);
|
||||
return `<i data-fa class="${name}">${icon.html[0]}</i>`;
|
||||
} else {
|
||||
console.warn(`'${name}' not found in fa`);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
pattern, replacement
|
||||
}]
|
||||
})
|
||||
});
|
||||
|
@ -3,28 +3,10 @@
|
||||
*/
|
||||
|
||||
const StringReplacePlugin = require('string-replace-webpack-plugin');
|
||||
import Replacer from '../../../src/common/build/i18n';
|
||||
|
||||
export default (lang, locale) => {
|
||||
function get(key: string) {
|
||||
let text = locale;
|
||||
|
||||
// Check the key existance
|
||||
const error = key.split('.').some(k => {
|
||||
if (text.hasOwnProperty(k)) {
|
||||
text = text[k];
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
if (error) {
|
||||
console.warn(`key '${key}' not found in '${lang}'`);
|
||||
return key; // Fallback
|
||||
} else {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
export default lang => {
|
||||
const replacer = new Replacer(lang);
|
||||
|
||||
return {
|
||||
enforce: 'pre',
|
||||
@ -32,14 +14,7 @@ export default (lang, locale) => {
|
||||
exclude: /node_modules/,
|
||||
loader: StringReplacePlugin.replace({
|
||||
replacements: [{
|
||||
pattern: /"%i18n:(.+?)%"/g, replacement: (_, key) =>
|
||||
'"' + get(key).replace(/"/g, '\\"') + '"'
|
||||
}, {
|
||||
pattern: /'%i18n:(.+?)%'/g, replacement: (_, key) =>
|
||||
'\'' + get(key).replace(/'/g, '\\\'') + '\''
|
||||
}, {
|
||||
pattern: /%i18n:(.+?)%/g, replacement: (_, key) =>
|
||||
get(key)
|
||||
pattern: replacer.pattern, replacement: replacer.replacement
|
||||
}]
|
||||
})
|
||||
};
|
||||
|
@ -7,8 +7,8 @@ import tag from './tag';
|
||||
import stylus from './stylus';
|
||||
import typescript from './typescript';
|
||||
|
||||
export default (lang, locale) => [
|
||||
i18n(lang, locale),
|
||||
export default lang => [
|
||||
i18n(lang),
|
||||
license(),
|
||||
fa(),
|
||||
base64(),
|
||||
|
Reference in New Issue
Block a user