Magento uses a system for translating text in the template files using:
$this->__(\'text to be translated.\');
or
Mage::helper(\
This is the correct way for translating JavaScript strings withing .phtml file
Translator.add({"To be translated":"_('To be translated'); ?>"});
Update: fixed typo.