I would use a php function to put data to the right places and echo out all JS code once done. But i’m not a php pro so there may be better ways of doing it.
This would not put the js code in main.js though so… may not be what you want.
Something along the lines can get you an idea:
function custom_js() {
$templatePath = get_template_directory_uri();
$exampleString = __('Example text', 'my-theme');
echo '<script>
var templatePath = '. $templatePath .';
var exampleString = '. $exampleString .';
</script>';
}