📢 Arhived ! Use New Library (support new arch) instead (fast-mlkit-translate-text)
Build Powerful React Native With Greate Language Identifier And Translator Amazing ⚡️
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 |
Key capabilities
yarn add react-native-mlkit-entity-extraction
or
npm i --save react-native-mlkit-entity-extraction
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
ReactNativeMLKitTranslateText was created by @yaaliuzhipeng
react-native-mlkit-translate-text is available under the MIT license. See the LICENSE file for more info.