Fix and improvements for api.translate()