Fix translating in python code called by javascript refs #4990