New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

react-native-text-toolkit

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-text-toolkit

Native text utilities (Look Up and Translate) for React Native and Expo apps

latest
Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

react-native-text-toolkit

Native text utilities (Look Up and Translate) for React Native and Expo apps.

This module provides native "Look Up" and "Translate" functionality for selected text in your React Native or Expo app, using platform-specific APIs.

Features

  • Look Up: On iOS, uses UIReferenceLibraryViewController to show dictionary definitions. On Android, uses ACTION_PROCESS_TEXT or falls back to web search.
  • Translate: On iOS 15+, uses the native Translate app. On Android, uses translation apps via ACTION_PROCESS_TEXT. Both platforms fall back to Google Translate in the browser.
  • Availability Checks: Check if features are available before showing UI controls
  • Cross-platform: Works on both iOS and Android with platform-appropriate implementations

Installation

npm install react-native-text-toolkit

Usage

import { lookUp, translate } from 'react-native-text-toolkit';

// Look up a word in the dictionary
lookUp('serendipity');

// Translate text
translate('Hello, world!');

API

lookUp(text: string): void

Look up a word or phrase using the system dictionary (iOS) or text processing actions (Android).

  • iOS: Opens UIReferenceLibraryViewController with the definition if available
  • Android: Uses ACTION_PROCESS_TEXT or falls back to web search

translate(text: string): void

Translate text using the system translation service or Google Translate.

  • iOS 15+: Uses the Translate app if available, otherwise falls back to Google Translate
  • Android: Uses translation apps via ACTION_PROCESS_TEXT or Google Translate

Example

import React, { useState } from 'react';
import { View, Text, TouchableOpacity } from 'react-native';
import { lookUp, translate } from 'react-native-text-toolkit';

export default function TextActionsExample() {
  const [selectedText, setSelectedText] = useState('serendipity');

  return (
    <View style={{ padding: 20 }}>
      <Text>Selected text: {selectedText}</Text>
      <TouchableOpacity onPress={() => lookUp(selectedText)}>
        <Text>Look Up</Text>
      </TouchableOpacity>
      <TouchableOpacity onPress={() => translate(selectedText)}>
        <Text>Translate</Text>
      </TouchableOpacity>
    </View>
  );
}

Platform Notes

iOS

  • Look Up: Uses the native UIKit Look Up feature (Siri Knowledge) via _define: or _lookup: selectors. Falls back to Google search if unavailable.
  • Translate: Uses the native iOS 15+ translate feature via the _translate: selector. Falls back to Google Translate for iOS < 15 or if the feature is unavailable.

Android

  • Look Up: Opens Google search with "define {text}" prefix in the default browser
  • Translate: Opens Google Translate in the default browser with auto-detect source language

License

MIT

Keywords

react-native

FAQs

Package last updated on 06 Oct 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts