Generate Google Translate API Key – TranslatePress
Mục Lục
Setting up API keys for Google Translate
This step-by-step tutorial will guide you through generating a Google Translate API Key.
Watch this short video for a quick tutorial:
In order to create a Google Translate API Key, you’ll need to sign up for the Google Cloud Console. Keep in mind that while Google does ask for your card information upon sign-up, you can use the translation API for free as long as you stay within the free tier limits (500.000 translated characters/month). This means that your card will not be billed unless you manually upgrade your account to a paid plan.
More information is available at: https://cloud.google.com/translate/.
To create your application’s API key simply follow the steps below:
1. Create a new project in Google Cloud Console
Go to the Cloud Platform Console. From the top bar click the little arrow pointing down, then click the New Project button in the pop-up that opens up.
Now, enter your project name and click Create.
2. Enable Google Cloud Translation API
With the new translation project selected, go to the hamburger menu to the left and visit API & Services.
From here you need to enable Google Translate API by clicking the + Enable APIs and Services button in your dashboard.
This will open the API Library where you will have to search for the Cloud Translation API in the search bar.
Once you’ve identified it, select it and click Enable.
3. Create a new Google Translate API key
Next, go to the Credentials tab in the sidebar. Click the Create Credentials button at the top of the page and select API Key from the dropdown.
Your API key will now be automatically created.
4. Restrict your API Key to a particular website
In the Google Dashboard, use the HTTP Referrer provided in the description of the Google Translate API Key field in Settings → TranslatePress → Automatic Translation tab, as shown in the following screenshot.
5. Restrict usage of translation API
In order to have control over the cost of Google Translate API, it is highly recommended to set quotas to limit usage.
From the same APIs and services screen, go to Enabled APIs and services, scroll down on the page, and find the Cloud Translation API.
Click it and then navigate to the Quotas tab.
From here, you’ll be able to view all your quotas, select the ones you want to modify, and then edit them.
6. Copy your API Key for use in TranslatePress
Go back to the Credentials tab and click the Show key button next to your newly created API key.
A new pop-up will appear to display your API key. Copy it from here.
7. Enable Automatic Translation and add Google Translate API Key in TranslatePress
TranslatePress lets you automatically translate your WordPress site by using Google Translate.
For this, in the WordPress dashboard, navigate to Settings → TranslatePress, and select the Automatic Translation tab. From here make sure to Enable Automatic Translation, by setting it to Yes. Then, under Translation Engine, select Google Translate v2.
This will uncover the Google Translate API key field. Place the API key in this field and Save Changes.
That’s it! You can now simply navigate to the front-end of your WordPress-powered website and browse it in the language of your choice. You’ll notice the content has been automatically translated.