Video tutorial: https://youtu.be/loOJxuwgn2g
Translations can be difficult to manage at scale in your database, especially for social generated content that consistently gets added and changed. Here’s how you can add AI translation right into your Supabase dashboard.
We assume you have the following:
Create a table where you want the content to be stored and translated, or you can use an existing table in your database.
Example table we’ll be using:

The description will be a required field containing content created by the user. The description_zh field will store the AI-generated translation.
Create a PostgreSQL function to handle the translation task. This function will interact with the JigsawStack’s AI translation API to retrieve translated text and update the relevant column in your table.
To set up the function:
The SQL code does three things:
description_zh column we created previously.This is a great starting point, but you might want to edit the code for the specific languages you want and your table schema definition.
Here’s the full list of supported languagesHere is how your function should look like:

Next, set up PostgreSQL triggers to automatically carry out the translation whenever text is added or updated in the description column.
Head over to the trigger section, create a new trigger, and give it a name.
social_posts tableinsert & update operations, which will only activate this trigger for that operation on the social_posts tableAfter the event, allowing for async operationsRow, allowing the trigger to run per row rather than a single statement, which could affect multiple tables
Head back to your table editor and update or create a new row with a description. You’ll see the description_zh column automatically getting updated.

Now you a have built in AI translation right in your Supabase database! In the famous words of Supabase, “It’s just Postgres”, you can apply the same techniques in any Postgres database.
Some improvements that can be made for a production database is separating your translation into another table, allowing you to easily add support for more translations. You could also update the SQL function we created above to dynamically translate to any language rather than being fixed to one language.
No errors were shown, and translation isn’t working
You might have forgotten to add a valid JigsawStack API key. You can also view all logs of each request made in the JigsawStack dashboard.
Function throwing errors
Make sure the return type of the Postgres function is set to trigger and you’re mapping to the right columns.
Have questions or want to show off what you’ve built? Join the JigsawStack developer community on Discord and Twitter. Let’s build something amazing together!