npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-native-ios-translate-sheet

v1.4.11

Published

SwiftUI Translate Sheet on React Native

Downloads

313

Readme

React Native iOS Translate Sheet

Note: If you need to perform multiple translations and retrieve the translated text to display within your app, consider using react-native-ios-translate-tasks instead. This library is focused on providing the native iOS translation sheet UI experience.

Features

  • 🔄 Seamless integration with iOS native translation capabilities
  • 🌐 Access to all languages supported by iOS translation
  • 📱 Native iOS UI and interactions
  • 🏗️ Supports old & new arch on RN 0.76+
  • ⚙️ Powered by SwiftUI's translationPresentation API under the hood

Platform Compatibility

This library is designed specifically for iOS 17.4 and above. It can be safely installed in your React Native project regardless of your target iOS version or if you're developing for Android. However, please note:

  • On iOS versions below 17.4, the translation sheet will not appear and the translate function will silently do nothing
  • On Android devices, the translation functionality is not available and the translate function will silently do nothing

Installation

yarn add react-native-ios-translate-sheet

or

npm install react-native-ios-translate-sheet

Then, install the native dependencies:

cd ios && pod install

Usage

  1. First, wrap your app (or the part where you want to use the translation sheet) with the IOSTranslateSheetProvider:
import { IOSTranslateSheetProvider } from 'react-native-ios-translate-sheet';

function App() {
  return (
    <IOSTranslateSheetProvider>
      {/* Your app content */}
    </IOSTranslateSheetProvider>
  );
}
  1. Then, use the useIOSTranslateSheet hook in any component where you want to trigger the translation sheet:
import { useIOSTranslateSheet } from 'react-native-ios-translate-sheet';

function MyComponent() {
  const { presentIOSTranslateSheet } = useIOSTranslateSheet();

  const handleTranslate = () => {
    presentIOSTranslateSheet({
      text: 'Text to translate',
    });
  };

  return (
    <Button
      title="Translate"
      onPress={handleTranslate}
    />
  );
}

iPad

On iPad, the translation sheet needs an anchor point to display correctly (it's optional, and by default the sheet will be displayed at the bottom of the screen). You can specify the position where the sheet should appear by providing a gesture event to presentIOSTranslateSheet:

import type { GestureResponderEvent } from "react-native";
import { useIOSTranslateSheet } from 'react-native-ios-translate-sheet';

function MyComponent() {
  const { presentIOSTranslateSheet } = useIOSTranslateSheet();

  const handleTranslate = (event: GestureResponderEvent) => {
    presentIOSTranslateSheet({
      text: 'Text to translate',
      gestureEvent: event,
    });
  };

  return (
    <Button
      title="Translate"
      onPress={handleTranslate}
    />
  );
}

Replacement Action

The Replacement Action feature allows you to capture and handle the translated text after a user completes a translation. This is particularly useful for:

  • Saving translations for later use
  • Updating UI elements with translated content
  • Implementing "translate and replace" functionality
  • Storing translations in your app's state or database

Basic Usage

To handle translated text, provide a callback function as the second parameter to presentIOSTranslateSheet:

const { presentIOSTranslateSheet } = useIOSTranslateSheet();

const handleTranslate = () => {
  presentIOSTranslateSheet({
    text: 'Hello, how are you?',
    replacementAction: (translatedText) => {
      // Handle the translated text here
      setTranslatedContent(translatedText);
    },
  });
};

Checking Platform Support

The useIOSTranslateSheet hook provides an isSupported boolean that you can use to check if the translation functionality is available on the current device:

const { isSupported } = useIOSTranslateSheet();

Note: The translation sheet will only appear on iOS devices running version 17.4 or later. On other platforms or iOS versions below 17.4, the presentIOSTranslateSheet function will do nothing.

Example

Contributing

We welcome contributions! Please see our Contributing Guide for more details.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

If you like this project, please consider supporting it by giving it a ⭐️ on GitHub!