You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
512 B
23 lines
512 B
'use strict'; |
|
|
|
const { Pattern } = require('hexo-util'); |
|
const { extname } = require('path'); |
|
|
|
exports.process = file => { |
|
const { path } = file.params; |
|
const ext = extname(path); |
|
const name = path.substring(0, path.length - ext.length); |
|
const { i18n } = file.box; |
|
|
|
if (file.type === 'delete') { |
|
i18n.remove(name); |
|
return; |
|
} |
|
|
|
return file.render().then(data => { |
|
if (typeof data !== 'object') return; |
|
i18n.set(name, data); |
|
}); |
|
}; |
|
|
|
exports.pattern = new Pattern('languages/*path');
|
|
|