When using the Nutrition Facts Calculation or Unit Conversion feature we integrate with the Spoonacular API to calculate the values for specific ingredients.
For non-English sites this requires an extra translation step, as the API only recognizes English names for the ingredients. With the Nutrition Facts Calculation you can manually search for the English translation when it doesn’t find a match, but an even better way is to make use of the Google Translation API to automatically translate and find a match for you.
How the Translation API can help
In this short video, you can see an example of how the translation can help speed up the nutrition facts calculation process by automatically finding matches, even if you’re not writing your recipes in English:
Enabling the Translation API
To get started, enable the Translation API on the WP Recipe Maker > Settings > Translation API page. Before this feature works, you’ll also need to add a “Google Translate API Key”. Follow these steps to get one for your site:
1. Go to https://cloud.google.com/translate/docs/basic/setup-basic
2. Click on the blue “Go to project selector” button and select or create a new project. You can name it “Your Site Name”, for example.
3. Make sure to set up billing for your account. Google will give you credit to cover a monthly usage of up to 500,000 characters. Without billing set up, the API will not work.
4. Back on the initial page (see step 1), click on “Enable the API” and select the correct project:
5. The next step is to create an API key. If you don’t see the “Go to credentials” button, navigate to that page yourself through the menu by going to APIs & Services > Credentials. There you’ll have the option to “Create Credentials”:
6. Create an API key and optionally set restrictions on where that API can be used (make sure to try without restrictions if the feature isn’t working as expected for you):
7. On the next screen, click on the icon to copy the key and add it on the WP Recipe Maker > Settings > Translation API page:
Specify a source language for the Translation API
On the WP Recipe Maker > Settings > Translation API page you can optionally set a “Source Language” as well. If you leave this setting blank, Google will try to automatically determine the language the ingredient is in originally. If you always write your recipes in the same language it’s recommended to fill in this setting. Google’s Documentation shows you the available language codes.