Skip to content
This repository has been archived by the owner on Feb 21, 2024. It is now read-only.

yaaliuzhipeng/react-native-mlkit-translate-text

Repository files navigation

** 📢 ** ** Arhived ! Use New Library (support new arch) instead ** (fast-mlkit-translate-text)

MLKitTranslator

A MachineLearning Language Translator

Build Powerful React Native With Greate Language Identifier And Translator Amazing ⚡️

MIT License

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

ReactNativeMLKitTranslateText was created by @yaaliuzhipeng

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

About

🧑‍🏫 machine learning translator for react native . based on Google MLKit.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published