-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.ts
39 lines (36 loc) · 1.1 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { NativeModules } from "react-native";
const { RNMlKitTranslateModule } = NativeModules;
interface IMLKitTranslateModule {
translate(
text: string,
sourceLanguage: string,
targetLanguage: string,
requireWifiToDownloadModel?: boolean
): Promise<string>;
getDownloadedModels(): Promise<string[]>;
deleteDownloadedModel(languageCode: string): Promise<void>;
downloadModel(languageCode: string, requireWifi?: boolean): Promise<void>;
}
export default {
translate(
text: string,
sourceLanguage: string,
targetLanguage: string,
requireWifiToDownloadModel = true
): Promise<string> {
return RNMlKitTranslateModule.translate(
text,
sourceLanguage,
targetLanguage,
requireWifiToDownloadModel
);
},
getDownloadedModels: RNMlKitTranslateModule.getDownloadedModels,
deleteDownloadedModel: RNMlKitTranslateModule.deleteDownloadedModel,
downloadModel(
languageCode: string,
requireWifi: boolean = true
): Promise<void> {
return RNMlKitTranslateModule.downloadModel(languageCode, requireWifi);
},
} as IMLKitTranslateModule;