Most translation plugins for WordPress, such as Translatepress, Polylang, WPML, only use Google's API or another one to translate the websites, which makes the cost of translation extremely expensive.
Open AI with GPT 3.5 turbo enabled translations that are a hundred times cheaper and more consistent. For example, while Google charges 20 USD for every 1,000,000 characters, OpenAI's GPT charges 0.0020 for every 800 words or about 5,000 characters.
Using GPT 3.5, we spend less than 2 USD to translate 1,000,000 characters, making the use of translation API much cheaper and convenient.
Previously it was necessary to bypass Google's API with new accounts or manually translate using a Database and Google Sheet, something that is usually complicated, laborious, and risky to have errors.
In this article, I will share two ways to use GPT to translate your strings from Translatepress. One of the ways can be replicated in any translation plugin such as WPML and Polylang.
1 - Creating an Automation
Tired of waiting for Translatepress Support to natively integrate with GPT, I decided to create a remote integration using automation tools like Zapier or Make myself.
The big problem is that my server only connects to the database via SSH Tunnel, so I couldn't use those two tools, but I resorted to the best option called N8N.
This is an OpenSource that allows you to install your own automation system on your server, perfect for thousands of tasks. Thanks to this tool, I was able to connect to my database and create the automation.
See below how I created this automation that can be further improved and customized to meet your needs, ignore strings, replace words, and make any other advanced changes to translations and databases on your WordPress.
Below I will leave the command that I have been using to translate correctly using GPT. This command was created in English for better effect, we also use PHP brackets for language variables, in the case of applying it in N8N or another automation tool this should be modified.
I want you to act as a translator from $source_language to $language_code. I will speak to you in $source_language you will translate in $language_code. The entries I am going to send may have texts in other languages or untransducible, return words it unmodified. Only include the translation and nothing else, do not write explanations here. If an input cannot be translated, return it unmodified.
2 - Customizing a Plugin
If you're a programmer, you can easily create an integration for Translatepress or another plugin based on the PHP files that handle translation with Google API and Deepl. Just take advantage of their framework and customize it into a custom plugin.
It seems easy to do, but I personally had no programming knowledge until after a lot of work, I managed to create the plugin by insisting on Translatepress support, which has absolutely no obligation, and also with the help of the GPT chat itself.
The plugin works perfectly and today it replaces the previous automation done in N8N, but unfortunately I cannot make this plugin publicly available. Fortunately, I teach and provide this integration to my students. translation course in English.
If you don't speak Portuguese, it's still worth it for you to purchase our course, as in the near future we may translate it, in addition to including the license and the aforementioned extensions. We also provide codes that can help customize your database.
You can also try to get in touch to talk about this Unique Automation that Translatepress didn't have the courage to fix. I am available to help you translate your website!
Video of our translation course
Below we will leave a video lesson from our translation course, publishing, explaining how you can install our plugin and configure the OpenAI API.