Class TranslationClient

Constructors

Properties

apiExtra: unknown
apiKey: undefined | string
apiUrl: undefined | string

If you don't want to use the classic fetch

import { ofetch } from "ofetch";
import TranslationClient from "../dist/client";
import { TranslationService } from "../dist/types/client";

// https://github.com/unjs/ofetch
const client = new TranslationClient({
service: TranslationService.yandexbrowser,
fetchFn: ofetch.native,
});

const phrase = "The quick brown fox jumps over the lazy dog";

const translatedResult = await client.translate(phrase);

console.log(translatedResult);
fetchOpts: Record<string, unknown>

Allows you to set specific values (e.g. proxy). When changing headers/body through this parameter, it is replaced entirely

headers: Record<string, unknown> = {}

Adds headers to the list of headers

origin: undefined | string
provider: BaseProvider

The service through which the translation is carried out

Methods