Socket
Book a DemoInstallSign in
Socket

react-google-cloud-translate

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-google-cloud-translate

A translation package built using Google Translation API for React.

1.0.2
latest
Source
npmnpm
Version published
Weekly downloads
21
-89.34%
Maintainers
1
Weekly downloads
 
Created
Source

Google Translation Package for React

A translation package built using Google Translation API for React.

Installation

npm install react-google-cloud-translate

or

yarn add react-google-cloud-translate

Usage

Wrap your application with the GoogleTranslateProvider component.

import { GoogleTranslateProvider } from 'react-google-cloud-translate';

const App = () => {
  return (
    <GoogleTranslateProvider language="rw" google_api_key="your_api_key">
      {/* rest of your application */}
    </GoogleTranslateProvider>
  );
};

export default App;

Translating Text

Use the useGoogleTranslate hook to access the googleTranslate function and translate text in your components.

import { useGoogleTranslate } from 'react-google-cloud-translate';

const App = () => {
  const { googleTranslate } = useGoogleTranslate();
  
  return (
    <h1>{googleTranslate('hello')}</h1>
  );
};

export default App;

or use gt function as a short alias:

const App = () => {
  const { gt } = useGoogleTranslate();
  
  return (
    <h1>{gt('hello')}</h1>
  );
};

export default App;

Bulk Text Translation

  • Import the GoogleTranslateClient class and instantiate it with your credentials
  • Call the bulkGoogleTranslate function to translate multiple texts at once by passing an array of strings.
import { GoogleTranslateClient } from 'react-google-cloud-translate';

const App = () => {
  const googleTranslateClient = new GoogleTranslateClient({
    google_api_key: "your_api_key",
    language_target: "rw"
  });

  const translateTexts = async () => {
    const translations = await googleTranslateClient.bulkGoogleTranslate(['hello', 'world']);
    console.log({ translations });
  };

  useEffect(() => {
    translateTexts();
  }, []);
  
  return (
    <h1>hello</h1>
  );
};

export default App;

FAQs

Package last updated on 26 Aug 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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.