-
• #2
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 :)
-
• #3
Cool - Thanks
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]);}; `);
Working on an app called locale that will handle locales , so we can see eg month, day names and more in our language.
Writing single values work's like expected, but looks like not using the correct way to write a list.
So how should this be written correctly?