updated translate method to intelligently detect html_safe translations, add test for the method