Using template tags in external JS file

It doesn’t work because you haven’t enqueued your script properly. If the script isn’t printed, neither are the variables set by wp_localize_script. Please read a WP Codex entry on wp_localize_script function. You have to include a path to the script after the handle.