You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

26 lines
884 B

package translate
import "context"
type ISys interface {
Translate(ctx context.Context, from string, to string, text []string) (results []string, err error)
// TranslateDetect 单句翻译并回传检测出的源语种;from 传空串即自动检测。
// 实时文本翻译的「自动检测」用它,省掉一次单独的语种识别调用。
TranslateDetect(ctx context.Context, from, to, text string) (translated, detected string, err error)
}
var defsys ISys
func OnInit(config map[string]interface{}, option ...Option) (err error) {
defsys, err = newSys(newOptions(config, option...))
return
}
func NewSys(option ...Option) (sys ISys, err error) {
sys, err = newSys(newOptionsByOption(option...))
return
}
func Translate(ctx context.Context, from string, to string, text []string) (results []string, err error) {
return defsys.Translate(ctx, from, to, text)
}