🌐 Unlimited free google translate component & hook

Overview

React Native Translator

npm version npm download License MIT Example

Stars Twitter

Preview


Introduce

Free translate component & hook

Never need api key, This library is Unlimited free


Support translators


Getting started

First, Install package

yarn add react-native-translator react-native-webview

Second, Pod intsall

cd ios && pod install

Third, Add provider

// App.js
...
import {TranslatorProvider} from 'react-native-translator' // here

const App = () => {
  return (
    <TranslatorProvider> // here
        <.../>
    </TranslatorProvider> // here
  );
};

API

Translator ( Real-time translate )

// Usage
import Translator from 'react-native-translator';

const App = () => {
  const [value, setValue] = useState('');
  const [result, setResult] = useState('');

  return (
    <View>
      <Translator
        from="en"
        to="fr"
        value={value}
        onTranslated={(t) => setResult(t)}
      />
      <TextInput value={value} onChangeText={(t) => setValue(t)} />
      <Text>{result}</Text>
    </View>
  );
};
Props Type Default value Required
from LanguageCode
to LanguageCode
value string
type TranslatorType 'google'
onTranslated (result: string) => void

useTranslator

// Usage
import {useTranslator} from 'react-native-translator';

const App = () => {
  const {translate} = useTranslator();

  const [value, setValue] = useState('');
  const [result, setResult] = useState('');

  const onTranslate = async () => {
    const _result = await translate('en', 'fr', value);
    setResult(_result);
  };

  return (
    <View>
      <TextInput value={value} onChangeText={(t) => setValue(t)} />
      <Text>{result}</Text>
      <Button title="translate" onPress={onTranslate} />
    </View>
  );
};

translate

// const {translate} = useTranslator();
type translate: <T extends TranslatorType>(/* check follow param table */) => Promise<string>;
param Type Default value Required
from LanguageCode
to LanguageCode
value string
option {type?: TranslatorType, timeout?: number} {type: 'google', timeout: 5000}

languageCodeConverter

❗️ If conversion is not possible, return undefined.

import {languageCodeConverter} from 'react-native-translator';
// google language code convert to kakao language code
languageCodeConverter('google', 'kakao', 'ko'); // kr

TranslatorType

type TranslatorType = 'google' | 'kakao' | 'papago';

LanguageCode

type LanguageCode<T extends TranslatorType> ...
// Usage
type GoogleLanguageCode = LanguageCode<'google'>;

VALUES

import {LANGUAGE_CODES, TRANSLATOR_TYPES} from 'react-native-translator';
// translator types
TRANSLATOR_TYPES; // ["google", "papago", "kakao", ...]
// language code
LANGUAGE_CODES['google']; // ["af", "ga", "sq", ...]

Support languages

Language Google Papago Kakao
Afrikaans af
Irish ga
Albanian sq
Italian it it it
Arabic ar ar
Japanese ja ja jp
Azerbaijani az
Kannada kn
Basque eu
Korean ko ko kr
Bengali bn bn
Latin la
Belarusian be
Latvian lv
Bulgarian bg
Lithuanian lt
Catalan ca
Macedonian mk
Chinese Simplified zh-CN zh-CN cn
Malay ms
Chinese Traditional zh-TW zh-TW cn
Maltese mt
Croatian hr
Norwegian no
Czech cs
Persian fa
Danish da
Polish pl
Dutch nl nl
Portuguese pt pt
English en en en
Romanian ro
Esperanto eo
Russian ru ru ru
Estonian et
Serbian sr
Filipino tl
Slovak sk
Finnish fi
Slovenian sl
French fr fr fr
Spanish es es es
Galician gl
Swahili sw
Georgian ka
Swedish sv
German de de de
Tamil ta
Greek el
Telugu te
Gujarati gu
Thai th th th
Haitian Creole ht
Turkish tr tr
Hebrew iw
Ukrainian uk
Hindi hi hi
Urdu ur
Hungarian hu
Vietnamese vi vi vi
Icelandic is
Welsh cy
Indonesian id id id
Yiddish yi
Comments
  • Service down?

    Service down?

    Hi there! Awesome package!

    Tried both of the examples (component & hook) but no matter how I set it up, I get "timeout" as the error message and no results are given. Tried different translators and running iOS simulator and on an actual device, iPhone 12.

    React-Native 0.67.3

    So is the service down or is something missing in the examples?

    bug 
    opened by ttlenell 35
  • Problem with useTranslator() hook

    Problem with useTranslator() hook

    When I used this hook in a project it didn't work. I created a new react native project to make sure that the error is not due to the fact that there is something problematic in that project. I ended up getting the same error. There is an error on android (I can’t find out if the module works on ios) изображение_2022-04-27_153042702 изображение_2022-04-27_153138476

    opened by taZik616 1
  • fix: allow auto-detect type for source language

    fix: allow auto-detect type for source language

    Hi, since Google Translate and Papago allow to auto-detect the source language I added a string 'auto' for prop from when the type is google or papago. Please review it. Many thanks.

    opened by doublelam 0
  • Real-time translation crash

    Real-time translation crash

    Whenever I click the button go into screen with your real time translator, my app crashes. Please help. Or maybe can you provide any examples that works with AppNavigator?

    opened by vfa-locltb 0
  • TypeError: undefined is not an object (evaluating '_ref2.type')

    TypeError: undefined is not an object (evaluating '_ref2.type')

    안녕하세요. 한국분 같아서 한국말로 문의드립니다. 제공된 Translator 컴포넌트는 제대로 작동하지만, 훅은 작동을 하지 않습니다. 제공된 테스트 코드를 똑같이 구동해보았습니다. await translate("en", "fr", value) 호출 시 아래와 같은 promise 오류가 발생합니다.

    Possible Unhandled Promise Rejection (id: 0):
    TypeError: undefined is not an object (evaluating '_ref2.type')
    
    opened by beliemun 1
  • Translator stopping the text at new lines and

    Translator stopping the text at new lines and ";"

    Hello, great lib. I'm stuck in an specific point. I'm trying to translate some text and the hook only returns the text until a special character is found.

    Example: Input string: La excursión en kayak es nuestra actividad más popular; una aventura relajante donde puedes recorrer 5km por un río de aguas color azul turquesa, hermosos bancos de arena, árboles centenarios, y un paisaje autentico, agradable, y romántica para las parejas, divertida para amigos y familiares.

    Output : The kayak excursion is our most popular activity;

    As you can see it stops right at the first ";".

    Removing the special characters allows the hook to translate it all but it's dynamic text so I can't really start replacing special characters.

    Any ideas?

    opened by decamps-enmanuel 9
Releases(1.1.3)
  • 1.1.3(Apr 22, 2022)

  • 1.1.2(Mar 25, 2022)

    Kakao translator userAgent omission fixed.

    Full Changelog: https://github.com/KoreanThinker/react-native-translator/compare/1.1.1...1.1.2

    Source code(tar.gz)
    Source code(zip)
  • 1.1.1(Mar 24, 2022)

    What's Changed

    • Bugfix google translate EU cache policy by @KoreanThinker in https://github.com/KoreanThinker/react-native-translator/pull/4

    Full Changelog: https://github.com/KoreanThinker/react-native-translator/compare/1.1.0...1.1.1

    Source code(tar.gz)
    Source code(zip)
  • 1.1.0(Mar 18, 2022)

    What's Changed

    • Add more translators by @KoreanThinker in https://github.com/KoreanThinker/react-native-translator/pull/2

    New Contributors

    • @KoreanThinker made their first contribution in https://github.com/KoreanThinker/react-native-translator/pull/2

    Full Changelog: https://github.com/KoreanThinker/react-native-translator/compare/1.0.0...1.1.0

    Source code(tar.gz)
    Source code(zip)
  • 1.0.0(Mar 17, 2022)

  • 0.0.1(Mar 17, 2022)

Owner
Hyun
They call me Coffee cause I grind so fine. 🤣
Hyun
🔄 Basic project to start studying React and Typescript. With it you can translate text to binary or morse language. This project addresses the creation of routes and components.

max-conversion Projeto criado para iniciar nos estudos de React e Typescript Basic project to gain knowledge in react Na plataforma é possível convert

Igor Neves 3 Feb 12, 2022
ESLint plugin for react-hook-form

eslint-plugin-react-hook-form react-hook-form is an awsome library which provide a neat solution for building forms. However, there are many rules for

Chuan-Tse Kao 37 Nov 22, 2022
An extremely helpful React Hook to trap the focusable elements / Hello Modals! Hello a11y!

react-use-focus-trap Everytime when people implement Modals... ...People forget that pro users as well as users that are permanently or temporarily re

David Lorenz 18 Nov 30, 2022
A hook based project created during 20-Dec week ReactJS workshop

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

Nabendu 1 Dec 25, 2021
React hook library, ready to use, written in Typescript.

usehooks-ts React hook library, ready to use, written in Typescript. npm i usehooks-ts Created by Julien Caron and maintained with ❤️ by an amazing te

Julien 2.8k Jan 5, 2023
react-dialog is a custom react hook to use a dialog easily

react-dialog react-dialog is a custom react hook to use a dialog easily. Documentation To use react-dialog follow the documentation. useDialog Returns

Levy Mateus Macedo 2 Mar 29, 2022
Small (0.5 Kb) react hook for getting media breakpoints state info in runtime

tiny-use-media Small (0.5 Kb) react hook for getting media breakpoints state info in runtime Usage npm i tiny-use-media --save Adn in your react code

Valeriy Komlev 51 Dec 13, 2022
A reusable react hook that preserves a components semantic accessibility to create a visual block link.

useAccessibleBlockLink is a reusable react hook that preserves a components semantic accessibility to create a visual block link. This hook supports multiple links within the same block.

Wayfair Tech – Incubator 4 Nov 28, 2022
Mirrors the functionality of Apollo client's useQuery hook, but with a "query" being any async function rather than GQL statement.

useAsyncQuery Mirrors the functionality of Apollo client's useQuery hook, but with a "query" being any async function rather than GQL statement. Usage

Alasdair McLeay 7 Nov 16, 2022
📋 useClipboardApi() is a React Hook that consumes Web Clipboard API.

?? use-clipboard-api useClipboardApi() is a React Hook that consumes Web Clipboard API. Table of Contents Motivation Usage Contributing Bugs and Suges

Helder B. Berto 22 Dec 15, 2022
A custom react hook to use a dialogs easily.

dialog-hook The dialog-hook is a custom react hook to use a dialog easily. First of all it is necessary to install the package in your project some co

Levy Mateus Macedo 2 Mar 29, 2022
Script to remove unnecessary properties from package.json on prepublish hook

clean-pkg-json Script to remove unnecessary properties from package.json on prepublish hook. Support this project by ⭐️ starring and sharing it. Follo

hiroki osame 37 Oct 16, 2022
An easy hook to use with expo-calendar library!

useCalendar Hook ?? Updated to Expo SDK45 This is an easy hook to use expo-calendar. It allows you: Get access permission to calendar Open settings to

AtilaDev 12 Nov 1, 2022
A set of React components implementing Google's Material Design specification with the power of CSS Modules

React Toolbox is a set of React components that implement Google's Material Design specification. It's powered by CSS Modules and harmoniously integra

React Toolbox 8.7k Dec 30, 2022
A Google Clone which built with ReactJS. You can click the demo and search whatever you want!

Google Clone with ReactJS A small web app that imitate the desktop web version of google site, you can search whatever you want. Google Clone Demo Lin

Özge Coşkun Gürsucu 36 Aug 14, 2022
React Google Analytics 4

React Google Analytics 4 Migrate from old react-ga // Simply replace `react-ga` with `react-ga4` import ReactGA from "react-ga"; import ReactGA from "

PriceRunner 270 Dec 29, 2022
A Facebook Clone which built with reactJS. You can sign in with your Google Account and send realtime posts.

Facebook Clone with ReactJS A Facebook Clone application that you can sign in with your Google Account and send realtime posts. Facebook Clone Demo Li

Mert Çankaya 23 Nov 25, 2022
How to submit HTML forms to Google Sheets. (Updated for 2021 Script Editor)

Submit a HTML form to Google Sheets How to submit a simple HTML form to a Google Sheet using only HTML and JavaScript. Updated for Google Script Edito

Levi Nunnink 314 Jan 6, 2023
Build Google 2.0 with Tailwind CSS & Next.js for Education Purpose..

Paradise of Creativity Parimal Nakrani This is a Next.js project bootstrapped with create-next-app. Getting Started First, run the development server:

Parimal Nakrani 1 Dec 21, 2021