How to translate a WordPress website using OpenAI and BTE?
In this tutorial, we will explore how to translate a WordPress website using OpenAI and the Bulk Task Editor (BTE).
Our use case involves duplicating posts from an English-language website and translating them into French for another website.
Note: Both websites share the same database but use different table prefixes to manage their content separately.
Table of Contents
Install and configure
The first step is to download the OpenAI Bulk Editor from the Code Market. Next, ensure the required components are installed:
- On the site where duplication will occur, at least the Bulk Task Editor (BTE) must be installed.
- On the translated site, you need to install the OpenAI Bulk Editor, the OpenAI API Wrapper, and the BTE dependencies.
Setup a new task
Now that everything is set up, it’s time to start duplicating your posts. Navigate to the Tasks panel and create a new Post Type Task.
After assigning a title and selecting a post type, click Publish. Once the task is saved, a set of forms will appear, allowing you to Filter your posts, define your Task, and configure the Process.
Use the Filter form to choose the posts you want to duplicate. As you adjust the filters, the “Matching items” count will update to reflect the selected posts.
Click Preview next to the counter to view a sample of the selected items.
Note: We recommend testing the task on a single item first using the Page ID option. This allows you to verify the action before processing a larger batch.
Duplicate Content
We are now ready to duplicate the posts. To begin, select the Duplicate Pages action from the Task form.
The action form will dynamically load with the following settings:
- Database Prefix: Specify the prefix of the destination table if you’re duplicating items to a different site.
- Existing Copy: Determine how to handle items that have already been duplicated (Skip, Overwrite, or Duplicate).
- Page Status: Set the status of the duplicated items (e.g., Draft, Published…).
- Content Filters: Apply shortcodes and filters through the
the_content
hook rendering the final HTML content (recommended). - Include: Choose the data fields to be duplicated (e.g., title, content, meta).
- Exclude Meta: Specify meta fields by name to be skipped during duplication
After setting up the action, navigate to the Process form. Set the Task Status to Start and then click Update to begin processing.
If using AJAX mode, keep the page open in your browser until the process reaches 100% completion. You’ll see the scheduling and processing progress update in real time as the page runs.
Note: To avoid overloading the server, we recommend setting a low Items per Process value (below 10) for this task.
Translate the contents
Now, we can proceed to the site that needs to be translated and start a new task. Before getting started, ensure your API key is properly configured:
- Navigate to Settings > OpenAI and enter your API key.
- If you don’t have an API key yet, you can create one by visiting the official OpenAI API page.
Note: We recommend starting with the translation of duplicated term taxonomies before proceeding to the post titles and content.
In this example, we will focus specifically on translating posts using an OpenAI prompt.
To achieve this, you’ll need to create three separate tasks to translate the Title, Excerpt, and Content.
Start by creating a new Post Type Task for translating the content, and then publish the task.
Next, filter the newly duplicated posts for processing.
Note: We recommend setting the posts to Draft or Pending status to make them easier to manage during the translation process.
Select the “OpenAI – Edit Post Content” action from the Task form. The action form will dynamically load with the following settings:
- Destination specifies where the AI-generated output will be applied (Post Content, Post Title, or Post Excerpt).
- AI Model is the AI model used to process the task, such as GPT-4o-mini.
- Temperature controls the randomness of the output. A value of 0 makes the output fully deterministic, while 2 allows for highly random and creative responses.
- Test Mode lets you log the prompt result to the console without making changes to the post content.
- Backup provides an option to back up the original data by specifying a meta name. Leave this field empty to disable the backup feature.
- System Prompt allows you to define instructions or set behavior for the AI’s output.
- Prompt is where you provide detailed instructions for the AI. You can include shortcodes to dynamically insert content into the prompt.
Prompt example
An example of a configuration that works well for translation tasks is using GPT-4o-mini with a temperature setting of 0.2 and the following system field:
You are a professional translator specialized in TOPIC. Translate the text from English to French, ensuring high-quality translation by incorporating encyclopedic terminology.
With this system prompt in place, you only need to include {{post.content}}
in the Prompt field to dynamically insert the post content for translation.