UNPKG

generator-begcode

Version:

Spring Boot + Angular/React/Vue in one handy generator

17 lines (16 loc) 711 B
import { passthrough } from '@yeoman/transform'; import { Minimatch } from 'minimatch'; export function convertVueTranslations(body) { return body.replace(/\{\{\s*(\w+)\s*\}\}/g, '{ $1 }').replace(/([@|||$])/g, "{'$1'}"); } const convertTranslationsSupport = ({ clientSrcDir }) => { const minimatch = new Minimatch(`**/${clientSrcDir}i18n/**/*.json`); const isTranslationFile = (file) => minimatch.match(file.path); const transform = passthrough(file => { if (isTranslationFile(file)) { file.contents = Buffer.from(convertVueTranslations(file.contents.toString())); } }); return { transform, isTranslationFile }; }; export default convertTranslationsSupport;