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;
