Looking at your workflow, I can identify the exact problem and provide a solution.
The Problem
The issue is in your “Set Language Config” node where you define:
javascript
target_languages: "zh" // Single string, not an array
Even though you later split this with “Split Target Languages” node, you’re only providing ONE language (“zh”). The split operation has nothing to split since it’s a single value.
The Root Cause
Your workflow architecture is actually designed correctly to handle multiple languages – it has the “Split Target Languages” node that should iterate through each target language. However, you’re only feeding it one language.
The Solution
Option 1: Quick Fix – Modify the Set Language Config Node
Change the “Set Language Config” node to use an array:
javascript
{
"fields": {
"values": [
{
"name": "target_languages",
"stringValue": '["zh", "fr", "ja", "de"]' // JSON array as string
},
{
"name": "source_lang",
"stringValue": "en"
}
]
}
}
But wait – n8n’s Set node uses stringValue, so you need to handle this properly.
Option 2: Better Approach – Use Code Node Instead
Replace the “Set Language Config” node with a Code node:
javascript
return [
{
json: {
post_types: $input.first().json.post_types,
target_languages: ["zh", "fr", "ja", "de"], // Array of languages
source_lang: "en"
}
}
];
Option 3: Most Flexible – Use Set Node Correctly
In the “Set Language Config” node, change the field type:
- Click on the node
- For
target_languages, instead of using “String”, choose “Expression” - Enter:
["zh", "fr", "ja", "de"]
This will create a proper array that the “Split Target Languages” node can iterate over.
Updated Workflow Section
Here’s how your updated nodes should look:
Fixed Language Config Node (Code Version)
Code
// Replace “Set Language Config” node with this Code node // This properly sets up multiple target languages const inputData = $input.first().json; return [ { json: { post_types: inputData.post_types, // Add all your target langua
Why This Works
Your workflow has this flow:
- Get All Post Types → Returns post types
- Set Language Config → Should set target_languages as array
- Split Post Types → Iterates each post type
- Split Target Languages → Iterates each target language (THIS was getting only 1 item)
- Get Untranslated Posts → Gets posts for current post_type + target_lang combination
The “Split Target Languages” node was working correctly, but it was only receiving a single string "zh" instead of an array ["zh", "fr", "ja"], so it only processed one language.
const inputData = $input.first().json; return [ { json: { post_types: inputData.post_types, // Add all your target languages here target_languages: [“zh”, “fr”, “ja”, “de”, “es”, “pt”], source_lang: “en” } } ];
WP开发教程 WordPress导师在线教程