
Security News
Django Joins curl in Pushing Back on AI Slop Security Reports
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
react-google-translate
Advanced tools
Useful hook for Google Translate API.
See demo
npm install --save react-google-translate @google-cloud/translate
Generate your credentials and project id in Google Cloud Platform. Read through the documentation for setting a service account.
After you acquired your credentials and project id, add it to your environment variables.
GCP_PRIVATE_KEY=[private_key]
GCP_CLIENT_EMAIL=[client_email]
GCP_PROJECT_ID=[project_id]
In your index.js,
import { setConfig } from 'react-google-translate'
setConfig({
clientEmail: process.env.REACT_APP_GCP_CLIENT_EMAIL ?? '',
privateKey: process.env.REACT_APP_GCP_PRIVATE_KEY ?? '',
projectId: process.env.REACT_APP_GCP_PROJECT_ID ?? ''
})
import React, { useState, useEffect } from 'react'
import { useLazyTranslate } from 'react-google-translate'
const Example = () => {
const [text] = useState('test');
const [language] = useState('zh-CN');
const [translate, { data, loading }] = useLazyTranslate({
language
})
useEffect(() => {
if (text) {
translate(text, language);
}
}, [translate, text])
render() {
return (
<div>{loading ? 'Loading...' : data}</div>
)
}
}
language
: string | string[]Set the default language for the translation.
skip
: booleanSkips the request if true.
translate
: funcCalls the api to translate the given text and language.
loading
: booleanIndicates that loading state.
data
: string | string[]Translated text received from the hook.
called
: booleanIndicates that hook has been triggered.
MIT © geminstall23
FAQs
Useful hook for Google Translate API.
The npm package react-google-translate receives a total of 29 weekly downloads. As such, react-google-translate popularity was classified as not popular.
We found that react-google-translate demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.