def trans_c(text, lang='zh-CN', detect=1): translated_cleaned = output(trans(text, lang)) if STAT: try: stathat = StatHat() stathat.ez_post_count(STAT_ACCOUNT, STAT_INSTANCE, 1) except Exception as e: cprint('Request susceed but stat failed!' + e, 'white', 'on_red') return translated_cleaned
def translate_text(text, lang='zh-CN', detect=1, type=0): if type == 0: # Specific language translated_cleaned = output(trans(text, lang)) elif type == 1: # Auto Translation translated_cleaned = output(trans_auto(text)) else: # To Chinese translated_cleaned = output(trans(text, lang)) if STAT: try: stathat = StatHat() stathat.ez_post_count(STAT_ACCOUNT, STAT_INSTANCE, 1) except Exception as e: cprint('Request susceed but stat failed!' + str(e), 'white', 'on_red') capture_message('Request susceed but stat failed!') return translated_cleaned
def stathat_count(stat, count=1): if hasattr(settings, 'STATHAT_EMAIL'): stathat = StatHat() try: result = stathat.ez_post_count(settings.STATHAT_EMAIL, stat, count) except HTTPError as e: mail_admins("StatHat API Error", e.message) return False else: return result
def stathat_count(stat, count=1): if hasattr(settings, 'STATHAT_EMAIL'): stathat = StatHat() return stathat.ez_post_count(settings.STATHAT_EMAIL, stat, count)