• So I guess the issue is:

    s.write('locale',`
    exports.name = function() {return '${lang}'};
    exports.temp = function(n){return n + '${locale[lang].tr}';};
    exports.translate = function(t){return ${locale[lang].tr}[t];};
    `);
    

    You want something more like:

    s.write('locale',`
    exports.name = function() {return ${JSON.stringify(lang)}};
    exports.temp = function(n){return n + ${JSON.stringify(locale[lang].t)};};
    exports.translate = function(t){return ${JSON.stringify(locale[lang].tr}[t]);};
    `);
    

    Generally it's safer to use JSON.stringify than to try and quote it yourself :)

About

Avatar for Gordon @Gordon started