Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
google-translate-api-browser
Advanced tools
Changelog
5.0.0
Readme
npm install google-translate-api-browser
For cross origin requests it uses cors-anywhere. You can use public cors-anywhere server https://cors-anywhere.herokuapp.com/
or set up your own. By default it does not use proxying.
import { translate } from "google-translate-api-browser";
translate("Je ne mangé pas six jours", { to: "en", corsUrl: "http://cors-anywhere.herokuapp.com/" })
.then(res => {
// I do not eat six days
console.log(res.text)
})
.catch(err => {
console.error(err);
});
You don't need to use CORS for node
const { translate } = require('google-translate-api-browser');
translate("Je ne mangé pas six jours", { to: "en" })
.then(res => {
// I do not eat six days
console.log(res.text)
})
.catch(err => {
console.error(err);
});
Link to codesandbox Link to codesandbox with custom fetch function
Verifies if the selected language is supported by Google Translate.
The text to be translated
type TranslateOptions = {
rpcids: string;
from: LangKey;
to: LangKey;
hl: LangKey;
tld: string;
raw: boolean;
}
const options = {
rpcids: 'MkEWBc',
from: 'ua',
to: 'en',
hl: 'en',
tld: 'com',
raw: true,
}
type TranslationResult = {
text: string; // The translated text.
pronunciation: string;
from: {
language: {
didYouMean: boolean; // `true` if the API suggest a correction in the source language
iso: string; // The code of the language that the API has recognized in the `text`
};
text: {
autoCorrected: boolean;
value: string;
didYouMean: string;
}
};
raw?: any;
}
Formats the google translate response.
Generates a url to google translate api.
FAQs
A free and unlimited API for Google Translate that works in browser
The npm package google-translate-api-browser receives a total of 5,975 weekly downloads. As such, google-translate-api-browser popularity was classified as popular.
We found that google-translate-api-browser demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.