1.0.3 • Published 2 years ago

react-native-mlkit-translate-text v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago
MLKitTranslator
⚡️Identify Language Immediately over 50 languages supported (full list)
😎Lazy loaded. download models when needed
🔄Offline-first. no network required for using
📱Multiplatform. iOS, Android
Fast. About TO Migrating to RN New Arch(JSI)
🔗Relational. Built on MLKit Translation foundation
⚠️Static typing Full-Support TypeScript

Why MLKitTranslator?

Key capabilities

  • Broad language support Translate between more than 50 different languages. See the complete list.
  • Proven translation models Powered by the same models used by the Google Translate app's offline mode.
  • Dynamic model management Keep on-device storage requirements low by dynamically downloading and managing language packs.
  • Runs on the device Translations are performed quickly, and don't require you to send users' text to a remote server.

Installation

yarn add react-native-mlkit-entity-extraction

or

npm i --save react-native-mlkit-entity-extraction

Usage

Quick example: identify language type

import MLKitTranslator, { LANG_TAGS } from './MLKitTranslator';

const Lang = "Bonjour, c’est en français";

MLKitTranslator.identifyLanguage(text)
.then((result:string) => {
	setLanguageType(getHumanLang(result));
})

Translate text example: identify 、download model and translate

etc: you'd like to translate french to english

1️⃣ download model firstly

import MLKitTranslator, { LANG_TAGS } from './MLKitTranslator';
//better do this in async function
await MLKitTranslator.downloadModel(LANG_TAGS.FRENCH);
await MLKitTranslator.downloadModel(LANG_TAGS.ENGLISH);

Remember !✨ Always check model firstly ; Do not translate text if the model is not downloaded

use NativeMLKitTranslateText.isModelDownloaded to check

2️⃣ translate text

await MLKitTranslator.translateText(text,LANG_TAGS.FRENCH, LANG_TAGS.ENGLISH);

// 🎉 got it, dude

Author and license

WatermelonDB was created by @yaaliuzhipeng

react-native-mlkit-translate-text is available under the MIT license. See the LICENSE file for more info.