Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added bun.lockb
Binary file not shown.
61 changes: 10 additions & 51 deletions docs/CustomTranslator.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,54 +32,20 @@ MyTranslator;

```ts
class Translator {
/**
* REQUIRED
*
* Method to translate single text
*/
/** * REQUIRED * * Method to translate single text */
public translate(text: string, from: string, to: string) => Promise<string>;

/**
* REQUIRED
*
* Method to translate multiple texts
*/
/** * REQUIRED * * Method to translate multiple texts */
public translateBatch(text: string[], from: string, to: string) => Promise<string>;

/**
* REQUIRED
*
* return maximal length of string for translating
*/
/** * REQUIRED * * return maximal length of string for translating */
public getLengthLimit() => number;

/**
* REQUIRED
*
* return minimal timeout between requests
*/
/** * REQUIRED * * return minimal timeout between requests */
public getRequestsTimeout() => number;

/**
* REQUIRED
*
* return number of extra chars for text over limit
*/
/** * REQUIRED * * return number of extra chars for text over limit */
public checkLimitExceeding(text: string | string[]): number;

/**
* REQUIRED
*
* is translator support value 'auto' as text language
*/
/** * REQUIRED * * is translator support value 'auto' as text language */
static isSupportedAutoFrom(): boolean;
/**
* REQUIRED
*
* return array of supported languages as ISO 639-1 codes
*/
/** * REQUIRED * * return array of supported languages as ISO 639-1 codes */
static getSupportedLanguages(): langCode[];

}
```

Expand All @@ -89,18 +55,11 @@ Example of a dummy translator. In your code, feel free to use HTTP requests to a

```js
class FakeTranslator {
translate = (text, from, to) =>
Promise.resolve(`FakeTranslator["${text}"-${from}-${to}]`);
translateBatch = (texts, from, to) =>
Promise.all(texts.map((text) => this.translate(text, from, to)));

getLengthLimit = () => 4000;
getRequestsTimeout = () => 300;
checkLimitExceeding = () => -10000;

translate = (text, from, to) => Promise.resolve(`FakeTranslator["${text}"-${from}-${to}]`);
translateBatch = (texts, from, to) => Promise.all(texts.map((text) => this.translate(text, from, to)));
getLengthLimit = () => 4000; getRequestsTimeout = () => 300; checkLimitExceeding = () => -10000;
static isSupportedAutoFrom = () => true;
static getSupportedLanguages = () => ['en', 'ru', 'ja', 'de'];
}

FakeTranslator;
```
4 changes: 1 addition & 3 deletions manifests/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"default_locale": "en",
"name": "__MSG_ext_name__",
"description": "__MSG_ext_description__",
"icons": {
"512": "static/logo/logo-icon.png"
},
"icons": { "512": "static/logo/logo-icon.png" },
"permissions": ["storage", "tabs", "contextMenus", "scripting"],
"content_scripts": [
{
Expand Down
Loading