comment-translate-manager
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

Used for translate source management. Multiple I translate objects are registered together, and the proxy API realizes the switching of different translation sources.

Installation

Koa requires higher for ES2020 and async function support.

$ npm install translate-manager

How to use it

let translateManager = new TranslateManager(context.workspaceState);
translateManager.onTranslate(e => {
    console.log(e);
});

Registry translate

Register translate source to manager.

export interface ITranslate {
    translate(content: string, options: ITranslateOptions): Promise<string>;
    link(content: string, options: ITranslateOptions): string;
    isSupported?: (src: string) => boolean;
    maxLen: number;
}

/**
 * @param key Registered key
 * @param translate Constructor of ITranslate
 */
translateManager.registry(key, translate);

Switch translate

Switch active translate source

if (translateManager.hasSource(key)) {
    return translateManager.setSource(key);
}

Use

Consistent with ITranslate

translateManager.translate(...);
translateManager.link(...);
translateManager.isSupport(...);
translateManager.maxLen;

Readme

Keywords

none

Package Sidebar

Install

npm i comment-translate-manager

Weekly Downloads

4

Version

0.0.5

License

none

Unpacked Size

31.9 kB

Total Files

8

Last publish

Collaborators

  • intellsmi