// Translate is a main translation method.
// It returns translated result and error value.
Translate is a main translation method.
It returns translated result and error value.
// Translate is a main translation method . // It returns translated result and error value .
func Translate(ctx context.Context, text string) (string, error) {
	var isTr bool
	found := langDirect.FindAllStringIndex(text, 1)
	if len(found) == 0 {
		return "", nil
	}
	direction := strings.Trim(text[found[0][0]:found[0][1]], " ")
	parsed := strings.Trim(text[found[0][1]:], " ")
	if parsed == "" {
		return "", nil
	}
	elements := strings.SplitN(parsed, " ", 2)
	if len(elements) > 1 {
		isTr = true
	}
	if !isDirection(ctx, direction, isTr) {
		loggerInfo.Printf("is not a direction: %v", direction)
		return "", nil
	}
	result, err := getTranslation(ctx, isTr, direction, parsed)
	if err != nil {
		return "", err
	}
	return result, nil
}
func Translate ( ctx context . Context , text string ) ( string , error ) { var isTr bool found := langDirect . FindAllStringIndex ( text , 1 ) if len ( found ) == 0 { return " " , nil } direction := strings . Trim ( text [ found [ 0 ] [ 0 ] : found [ 0 ] [ 1 ] ] , " " ) parsed := strings . Trim ( text [ found [ 0 ] [ 1 ] : ] , " " ) if parsed == " " { return " " , nil } elements := strings . SplitN ( parsed , " " , 2 ) if len ( elements ) > 1 { isTr = true } if ! isDirection ( ctx , direction , isTr ) { loggerInfo . Printf ( " " , direction ) return " " , nil } result , err := getTranslation ( ctx , isTr , direction , parsed ) if err != nil { return " " , err } return result , nil }
Translate is a main translation method.
Translate is a main translation method .
// is it "translate" or "dictionary"