How to Set Up Google Translation API for Magento?

Although Magento doesn't provide nearly as much translation power as the Magento 2 Translation tool, you still need to put in some work. You need to do most of the translations yourself. But right until now.

Today, you'll learn how to set up Google Translation API for Magento to start doing translations automatically. It's easier than it sounds. We promise.

What is Google Translation API?

Google Translation API or Cloud Translation API is a machine translation technology that allows you to translate texts in a website or application dynamically, through the API. It uses the same machine learning it uses in search results and Gmail when it encounters a language different from yours.

In other words, it allows you to do translations automatically.

Google Translation API Pricing

Google offers you two editions — Basic and Advanced —  with a different set of features. Both are paid. However, the first 500,000 characters sent for Translation API to process per month are free.

That's about 71428 - 125000 words per month. Then the pricing for the Basic edition starts from $20 for a million characters per month. So you shouldn't worry about the enormous charges.

  • Basic — operates on the pre-trained Neural Machine Translation (NMT) model. It's more simple and optimized for handling user-generated content like social media, comments and chat.
  • Advanced — more optimized for long-form content and customizations. It includes custom features like glossaries, and batch requests and allows you to choose a custom model.

How to Set Up Google Translation API for Magento?

It might seem overwhelming at first. But the Magefan Translation extension handles the technical part. All you need to do is create a Google Cloud project, if you haven't already, and enable the Translation API. 

If you've already created a Google Cloud project, just skip the first two steps.

Step 1: Create a Google Cloud project

Since Translation API is a part of Google Cloud architecture, you need to have a project to work with the API. 

Navigate to the Google Cloud Console, click on Select a project and hit the New Project button. 

create new project in google cloud

Specify the Project name and Location, and click Create. Choosing an organization is not required when creating a project.

google cloud new project

Once you finish, move to the Select a project dropdown and select your project to continue.

Step 2: Enable billing

Although there are a lot of free Google Cloud resources, some of them are still paid. So when you create a project Google requires you to add the billing account and specify who pays for the used resources, if any. 

This usually includes providing your tax information (VAT and organization) and card details.

Find the flyout menu on the top left corner, choose Billing and continue with the required steps.

google cloud billing

Important: you need to create a billing account even if you start a trial. Once it ends you won't be charged automatically, until you manually activate your full account.

Step 3: Enable Translation API

Navigate to the same flyout menu on the top left corner and find the APIs & Services > Library option. Find the Cloud Translation API there and click Enable.

google cloud api and services

Note: you will be asked to create a billing account to enable the API if you've missed this step before.

Once the API is enabled, you land on the API page with all the metrics, quotas and other details. 

cloud translation api

Step 4: Get API keys

To connect the Google Translation API with Magento you need to generate the API key. For that switch to the Credentials tab, hit + Create Credentials and choose the API Key option.

cloud translation api keys

It will take a moment for the system to generate the API key. Just copy it once done. 

google translation api key

Step 5: Paste Translation API keys in Magento

The final step in setting up Google Translation API for Magento is adding your API. 

Just navigate to Stores > Configuration > Magefan Extensions > Translation > Google Translation API and paste it there. Additionally, set the Default Locale where you want to make translations from. 

google translation api magento

Don't forget to Save the settings and start your auto-translation journey. You can now translate Magento automatically through Google. Just go to any product or category and hit the Translate > Auto Translate button under any product attribute. 

Magento localization can be easy. You just need to utilize the right tools to make it so.