React Native On-Device Text Translation w/ Google ML Kit
⚠ WARNING: Don't use this in production.
This package is still in alpha release, so it's not recommended to use it in production until it's fully stable, however using it for testing purposes is helpful.
npm install @react-native-ml-kit/translate-text --save
CLI autolink feature links the module while building the app.
react-native link @react-native-ml-kit/translate-text
On iOS, use CocoaPods to add the native RNMLKitTranslateText to your project:
npx pod-install
import TranslateText, {
TranslateLanguage,
} from '@react-native-ml-kit/translate-text';
const translatedText = await TranslateText.translate({
text: 'مرحبا بالعالم',
sourceLanguage: TranslateLanguage.ARABIC,
targetLanguage: TranslateLanguage.ENGLISH,
downloadModelIfNeeded: true,
});