@bsky.app/expo-translate-text

中文文档
0.2.9发布于 2026/03/07MITTypeScriptCommonJS零依赖构建来源已验证近 30 天下载 2.9万

Expo module for on-device translation.

原始使用文档
文档目录11 节
  1. Demo 💫
  2. Installation 📦
  3. Platform Support 📱
  4. Usage 🚀
  5. Basic Text Translation
  6. Translation Sheet (iOS Only)
  7. API Reference 📖
  8. onTranslateTask
  9. onTranslateSheet (iOS 17.4+)
  10. Contributing 🙌
  11. License 📜

expo-translate-text 🌍

[!NOTE] This is a fork of TomAtterton/expo-translate-text

expo-translate-text is a React Native module for translating text using platform-specific translation APIs. It leverages Apple's iOS Translation API (with Translation Sheet available in iOS 17.4+) and Google ML Kit on Android for seamless text translation.

npm Downloads GitHub issues GitHub stars GitHub license

Demo 💫

Demo GIF

Installation 📦

expo install expo-translate-text

Platform Support 📱

PlatformTranslation TaskTranslation Sheet
iOS✅ Supported (iOS 18+)✅ Supported (iOS 17.4+)
Android✅ Supported❌ Not Supported

Usage 🚀

Basic Text Translation

import { onTranslateTask } from 'expo-translate-text';

const translateText = async () => {
  try {
    const result = await onTranslateTask({
      input: 'Hello, world!',
      sourceLangCode: 'en',
      targetLangCode: 'es',
    });
    console.log(result.translatedTexts); // "¡Hola, mundo!"
  } catch (error) {
    console.error(error);
  }
};

Translation Sheet (iOS Only)

import { onTranslateSheet } from 'expo-translate-text';
import { Platform } from 'react-native';

const translateSheet = async () => {
  if (Platform.OS === 'android') {
    console.warn('Sheet translation is not supported on Android.');
    return;
  }

  try {
    const translatedText = await onTranslateSheet({
      input: 'Bonjour tout le monde',
    });
    console.log(translatedText);
  } catch (error) {
    console.error(error);
  }
};

API Reference 📖

onTranslateTask

Translates a given text or batch of text.

Request:

ParameterTypeDescription
inputstring | string[] | { [key: string]: string | string[] }Text to be translated.
sourceLangCode?stringSource language code (e.g., 'en').
targetLangCodestringTarget language code (e.g., 'es').
requireCharging?booleanRequires device to be charging.
requiresWifi?booleanRequires WiFi for translation.

Response:

KeyTypeDescription
translatedTextsstring | string[] | { [key: string]: string | string[] }The translated text(s).
sourceLanguagestring | nullThe detected source language, or null if unknown.
targetLanguagestringThe requested target language.

onTranslateSheet (iOS 17.4+)

⚠️ Not supported on Android

Translates text using the Translation Sheet API.

Request:

ParameterTypeDescription
inputstringThe text to be translated.

Response:

KeyTypeDescription
resultstringThe translated text.

Contributing 🙌

See the contributing guide to learn how to contribute.

License 📜

MIT

Enjoy translating with expo-translate-text! 🌎

版本与发布记录

@bsky.app/expo-translate-text 共发布 9 个版本,首次发布于 2026/02/25;过去 12 个月发布了 9 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.2.9latest2026/03/078 个月前
0.2.82026/03/078 个月前
0.2.72026/03/048 个月前
0.2.62026/03/048 个月前
0.2.52026/03/048 个月前
0.2.42026/02/268 个月前

关于 @bsky.app/expo-translate-text 的常见问题

@bsky.app/expo-translate-text 是什么?

Expo module for on-device translation.

如何安装 @bsky.app/expo-translate-text?

在项目目录运行 npm install @bsky.app/expo-translate-text,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:expo(*)、react(*)、react-native(*)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@bsky.app/expo-translate-text 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@bsky.app/expo-translate-text 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@bsky.app/expo-translate-text 可以商用吗?

@bsky.app/expo-translate-text 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@bsky.app/expo-translate-text 的下载量有多少?

根据 npm 官方下载统计,@bsky.app/expo-translate-text 在 2026/10/09 – 2026/11/07 这 30 天内被下载 28,895 次,日均约 963 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bsky.app/expo-translate-text 还在维护吗?

最新版本 0.2.9 发布于 2026/03/07(8 个月前);至今共发布 9 个版本,其中过去 12 个月发布了 9 个;首次发布于 2026/02/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。