示例#1
0
func MsTrans(clientID, clientSecret, in string) (out string) {
	t := microsoft.NewTranslator(clientID, clientSecret)
	from, err := MsDetect(clientID, clientSecret, in)
	if err != nil {
		return "警报!弹药系统过载!请放宽后重试"
	}
	switch from {
	case "zh-CHS", "zh-CHT":
		out, err = t.Translate(in, from, "en")
	default:
		out, err = t.Translate(in, from, "zh-CHS")
	}
	if err != nil {
		return "可怜的群组娘被母舰放逐了X﹏X"
	}
	return out
}
示例#2
0
func (m *MsTrans) New() {
	m.t = microsoft.NewTranslator(
		conf.GetItem("msTransId"),
		conf.GetItem("msTransSecret"))
}
示例#3
0
func MsDetect(clientID, clientSecret, in string) (string, error) {
	t := microsoft.NewTranslator(clientID, clientSecret)
	return t.Detect(in)
}
示例#4
0
func (m *MsTrans) New() {
	m.t = microsoft.NewTranslator(msID, msSecret)
}