Connect the Google Cloud Translation API to your Bubble app using the API Connector plugin. This tutorial walks through creating a Google Cloud project, obtaining an API key, configuring the API Connector with the correct endpoint and parameters, translating text on demand via a workflow, and caching translations in the database to reduce API costs.
Overview: Integrating Google Translate API in Bubble
This tutorial shows you how to integrate the Google Cloud Translation API into your Bubble app using the API Connector plugin. You will create a Google Cloud project, generate an API key, configure the translation endpoint in Bubble, build a workflow that translates user-entered text, and store translations so repeat requests do not cost additional API calls. This is ideal for apps that need on-demand translation for user content, support messages, or multilingual listings.
Prerequisites
- A Bubble account with an existing app
- A Google Cloud account with billing enabled
- Basic familiarity with the API Connector plugin in Bubble
- Understanding of Bubble workflows and data types
Step-by-step guide
Create a Google Cloud project and enable the Translation API
Create a Google Cloud project and enable the Translation API
Go to console.cloud.google.com and create a new project (or select an existing one). In the left sidebar, click APIs & Services then Library. Search for Cloud Translation API and click Enable. Next, go to APIs & Services then Credentials, click Create Credentials, and select API key. Copy the generated key. For security, click Restrict key and limit it to the Cloud Translation API only.
Pro tip: Set a quota limit on the API key in Google Cloud Console to prevent unexpected charges if your app sends too many requests.
Expected result: You have a Google Cloud API key with the Translation API enabled and restricted.
Configure the API Connector in Bubble
Configure the API Connector in Bubble
In your Bubble editor, go to the Plugins tab and install the API Connector plugin if not already installed. Click Add another API and name it GoogleTranslate. Set Authentication to None (we will pass the key as a parameter). Click Add another call and name it TranslateText. Set Use as to Action. Set the method to POST and the URL to: https://translation.googleapis.com/language/translate/v2?key=[api_key]. Add a URL parameter called api_key, paste your Google API key, and check the Private checkbox so it stays server-side.
Expected result: The API Connector shows a GoogleTranslate API with a TranslateText call configured with the correct URL and API key.
Add the request body parameters
Add the request body parameters
In the TranslateText call, set the Content-Type header to application/json. In the Body section, enter the following JSON structure. Add body parameters for q (the text to translate), target (the target language code like es, fr, de), and source (optional source language code). Mark q and target as dynamic (uncheck Private) so they can be set from workflows. The JSON body should look like: {"q": "<q>", "target": "<target>", "source": "<source>"}.
1{2 "q": "<q>",3 "target": "<target>",4 "source": "<source>"5}Pro tip: Leave the source parameter empty to let Google auto-detect the source language — this works well for user-generated content in unknown languages.
Expected result: The request body is configured with dynamic parameters for text, target language, and optional source language.
Initialize the API call
Initialize the API call
Click Initialize call in the API Connector. In the parameter fields, enter a test value for q (e.g., Hello world), target (e.g., es for Spanish), and source (e.g., en for English). Click Initialize. Bubble will make the API call and show the response structure. You should see data.translations as an array with translatedText. Click Save to lock in the response mapping. If you get an error, double-check your API key and that the Translation API is enabled in Google Cloud.
Expected result: The API call initializes successfully and Bubble maps the response structure including translatedText.
Build the translation workflow
Build the translation workflow
Go to the Design tab and add an input field for the source text, a Dropdown for target language (populate with language codes like en, es, fr, de, ja), and a Translate button. Go to the Workflow tab and create: When Button Translate is clicked. Add the action Plugins then GoogleTranslate - TranslateText. Set q = Input Source Text's value, target = Dropdown Language's value. Then add a second action to display the result: set a Text element or custom state to Result of step 1's body data translations first item translatedText.
Expected result: Clicking Translate sends the text to Google, and the translated result appears on the page.
Cache translations to reduce API costs
Cache translations to reduce API costs
Create a new data type called Translation with fields: source_text (text), target_language (text), translated_text (text), and created_date (date). Before calling the API, add a search at the beginning of the workflow: Do a search for Translations where source_text = Input's value and target_language = Dropdown's value. Add an Only when condition to the API call action: Only when the search count is 0. After the API call, create a new Translation record to store the result. On the display step, show either the cached result or the fresh API result depending on which path executed.
Pro tip: Add a date check to expire cached translations after 30 days if your content changes frequently.
Expected result: Repeated translation requests for the same text and language are served from the database cache instead of calling the API again.
Complete working example
1{2 "API Name": "GoogleTranslate",3 "Authentication": "None",4 "Call Name": "TranslateText",5 "Use as": "Action",6 "Method": "POST",7 "URL": "https://translation.googleapis.com/language/translate/v2?key=[api_key]",8 "Headers": {9 "Content-Type": "application/json"10 },11 "URL Parameters": {12 "api_key": {13 "value": "YOUR_GOOGLE_API_KEY",14 "private": true15 }16 },17 "Body": {18 "q": "<q>",19 "target": "<target>",20 "source": "<source>"21 },22 "Response Structure": {23 "data": {24 "translations": [25 {26 "translatedText": "Hola mundo",27 "detectedSourceLanguage": "en"28 }29 ]30 }31 },32 "Data Type for Caching": {33 "Translation": {34 "source_text": "text",35 "target_language": "text",36 "translated_text": "text",37 "created_date": "date"38 }39 },40 "Workflow Summary": {41 "Event": "Button Translate is clicked",42 "Step 1": "Search for cached Translation",43 "Step 2": "Call GoogleTranslate - TranslateText (Only when Step 1 count is 0)",44 "Step 3": "Create new Translation cache record (Only when Step 1 count is 0)",45 "Step 4": "Display translated text from Step 2 or Step 1"46 }47}Common mistakes when using Bubble.io's API Connector to integrate with Google Translate: Step-by
Why it's a problem: Leaving the API key without the Private checkbox checked
How to avoid: Always check the Private checkbox on the api_key parameter in the API Connector so it stays server-side.
Why it's a problem: Not initializing the API call before using it in workflows
How to avoid: Click Initialize call with test values and verify the response structure before saving and using the call in workflows.
Why it's a problem: Calling the API for every translation without caching
How to avoid: Store translations in a Translation data type and check for existing cached results before making a new API call.
Best practices
- Always mark API keys as Private in the API Connector to keep them server-side
- Cache translations in a database table to reduce API costs and improve response times
- Set quota limits on your Google Cloud API key to prevent unexpected billing spikes
- Restrict the API key to only the Cloud Translation API in Google Cloud Console
- Use auto-detect for source language when translating user-generated content
- Add error handling for API failures by checking the response status before displaying results
- Consider using an Option Set for supported languages to keep the language dropdown consistent
- Test with multiple language pairs to verify the response mapping handles all character sets
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
I am building a Bubble.io app and need to integrate the Google Cloud Translation API. I want users to enter text, select a target language, and see the translation. How do I set up the API Connector call, handle the response, and cache translations to save money?
Integrate the Google Cloud Translation API into my app. Set up the API Connector with authentication, create a translate button workflow, and cache results in a Translation data type to avoid duplicate API calls.
Frequently asked questions
How much does the Google Translation API cost?
Google charges $20 per million characters for the basic Translation API (v2). The first 500,000 characters per month are free. Caching translations in your database significantly reduces ongoing costs.
Can I translate to multiple languages at once?
The API supports one target language per call. To translate to multiple languages, create a backend workflow that loops through a list of target languages and makes separate API calls for each.
What language codes does Google Translate support?
Google supports 100+ languages using ISO 639-1 codes. Common codes include en (English), es (Spanish), fr (French), de (German), ja (Japanese), and zh (Chinese). See the full list in Google's documentation.
Will this work with Bubble's free plan?
Yes. The API Connector plugin is free and works on all Bubble plans. You will need a Google Cloud account with billing enabled for the Translation API.
How do I handle translation errors?
Check the API response status in your workflow. If the response contains an error object, display a user-friendly message like Translation failed, please try again instead of the raw error.
Can RapidDev help with multilingual app development?
Yes. RapidDev specializes in Bubble development and can help build fully multilingual apps with automatic content translation, language detection, and localized user interfaces.
Should I use the v2 or v3 Translation API?
The v2 (Basic) API is simpler and sufficient for most Bubble apps. The v3 (Advanced) API offers batch translation and glossaries but requires more complex authentication setup.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation