Version: 2.1.2
Author: Farook K — https://medium.com/nothing-big
Requires: WordPress 6.0+, WooCommerce 7.0+, WPML, PHP 8.1+
Support: support@erpgulf.com
Translates WooCommerce products from Arabic to English using AI — Gemini, ChatGPT, or Claude. Saves translations directly into WPML English product versions. Zero WPML credits used.
erpgulf-woo-ai-translator/
├── erpgulf-woo-ai-translator.php ← main plugin file
├── erpgulf-gt-pages.php ← pages & posts translation page
├── gemini-provider.php ← Google Gemini provider
├── openai-provider.php ← OpenAI ChatGPT provider
└── claude-provider.php ← Anthropic Claude provider
| Requirement | Details |
|---|---|
| WordPress | 6.0 or higher |
| WooCommerce | 7.0 or higher |
| WPML | With WooCommerce Multilingual |
| PHP | 8.1 or higher |
| API Key | Google Gemini (free), OpenAI, or Anthropic |
- Upload the plugin folder to
/wp-content/plugins/ - Activate the plugin in WordPress Admin → Plugins
- Go to ERPGulf AI Translate in the admin menu
- Enter your API key for your chosen AI provider
- Select which fields to translate
- Save settings
- Open any Arabic product in the WordPress admin
- Find the 🤖 ERPGulf AI Translate box in the right sidebar
- Click Translate to English
- Done — the English product is created or updated automatically
- Go to ERPGulf AI Translate → Bulk Translate
- All untranslated Arabic products are listed with checkboxes
- Select the products you want (Select All is checked by default)
- Click ▶ Start
- Watch the live progress — each product shows ✅ or ❌ as it completes
- Use ⏸ Pause or ⏹ Stop at any time
- Free tier available at aistudio.google.com
- No billing required for Flash models
- Get key: https://aistudio.google.com/app/apikey
- Models: Gemini 2.0 Flash, 1.5 Flash, Flash Lite
- Models are fetched live from the API — always up to date
- Requires a paid OpenAI account
- Get key: https://platform.openai.com/api-keys
- Models: GPT-4o Mini (recommended), GPT-4o, GPT-3.5 Turbo
- Requires an Anthropic account
- Get key: https://console.anthropic.com/settings/keys
- Models: Claude Haiku (recommended), Claude Sonnet
Admin → ERPGulf AI Translate
Select which AI handles translations. All credentials are saved — only the selected provider is used.
Source Language: Arabic ← language products are written in
Target Language: English ← must match your WPML language name
Three groups of fields are auto-discovered from your products:
📝 Standard Fields
- Product Title
- Product Description
- Short Description
⚙️ Custom & ACF Fields
- Manufacturer Brand
- Any other custom text fields found in your products
🔁 Repeater Fields
- Compatibility (add_compactable_details) — translates brand, copies model/years as-is
- Any other ACF repeater fields found in your products
♻️ Regenerate Lookup Table
Fixes admin SKU search for all translated products. Run once after bulk translation.
🔄 Sync All Translated Products
For existing translated products, copies any missing fields without using API calls:
- Compatibility data
- Branch stock
- Product images
- Price
- SKU
- Categories
Safe to run anytime. Does not overwrite translated text.
Product title Arabic → English via AI
Product description Arabic → English via AI
Short description Arabic → English via AI
Custom text fields Arabic → English via AI (e.g. Manufacturer Brand)
Repeater brand field Arabic → English via AI
Product categories Translated and created if missing in WPML
Regular price Copied once — WPML syncs changes after
Sale price Copied once — WPML syncs changes after
Stock quantity Copied once — WPML syncs changes after
Stock status Copied once — WPML syncs changes after
Weight / Dimensions Copied once — WPML syncs changes after
SKU Copied — same across languages
Product image Copied — same image shown in both languages
Gallery images Copied — same images shown in both languages
WooSB bundle IDs Copied
Price changes WPML Multilingual for WooCommerce syncs automatically
Stock changes WPML Multilingual for WooCommerce syncs automatically
Branch stock changes Our plugin auto-syncs via WordPress meta hooks
Password Not applicable
Order data Not applicable
Customer data Not applicable
On every Arabic product edit page, the 🤖 ERPGulf AI Translate sidebar box shows:
States:
⚙️ This is the EN version. Open the Arabic product to translate.
(shown on English products — button hidden)
⚠️ No English version yet — will be created.
[🤖 Translate to English]
✅ English version exists · View English →
[🤖 Translate to English]
🗑️ English version is in Trash
[ ♻️ Restore ] [ 🗑️ Delete ]
[🤖 Translate to English]
Admin → ERPGulf AI Translate → Pages & Posts
Translate WordPress pages and blog posts — separate from WooCommerce products.
Shows all published pages with their translation status:
- ✅ Already translated — shows Arabic title, English title, Edit and Edit EN links, ↺ Retranslate button
⚠️ Not translated — shows Arabic title, Edit link, Translate button
Same layout for blog posts — toggle between Pages and Posts using the tab buttons at the top.
Every item has its own Translate or ↺ Retranslate button. Click it to translate that single page or post immediately. The live log on the right shows the result including the English title after translation.
Shows at a glance:
- Total — all published pages/posts
- Translated ✅ — have a live English version
- Not Translated
⚠️ — no English version yet
Admin → ERPGulf AI Translate → Bulk Translate
Shows only untranslated Arabic products (those with no English version in WPML).
┌──────────┐ ┌──────────┐ ┌──────────┐
│ 738 │ │ 0 │ │ 0 │
│Untranslated│ │Translated│ │ Failed │
└──────────┘ └──────────┘ └──────────┘
| Button | Action |
|---|---|
| ▶ Start | Begin translating selected products one by one |
| ⏸ Pause | Pause after current product finishes |
| ▶ Resume | Continue from where paused |
| ⏹ Stop | Stop after current product — already translated items are saved |
Six tools available directly on the bulk page — no need to go to Settings:
| Tool | What it does |
|---|---|
| ♻️ Regenerate Lookup Table | Fixes admin SKU search for all products |
| 🔄 Sync Translated Products | Copies missing fields (compat, stock, images, price, SKU, categories) to English versions without API calls |
| 🗑️ Empty Trash | Permanently deletes all trashed products (requires confirmation) |
| 🔗 Fix WPML Links | Removes stale WPML records pointing to deleted or trashed posts |
| 📊 Translation Status | Shows a live count: translated · untranslated · in trash |
| 🔁 Reload Product List | Refreshes the untranslated products list |
Status check example:
📊 1952 translated · 738 untranslated · 12 in trash
Sync result example:
✅ 1952 synced · Compat: 47 · Stock: 312 · SKU: 89 · Price: 203 · Cats: 156
Each product shows:
- Checkbox (checked by default)
- Arabic product name
- ID and SKU
Status icons update live:
- 🔄 Currently translating
- ✅ Successfully translated
- ❌ Failed
Shows in real time:
🔄 [ID:281054 SKU:B003000001] ذراع التحكم في المسار BMW...
✅ [ID:281054 SKU:B003000001] BMW Track Control Arm Left Rear
❌ [ID:281099 SKU:B003000002] ذراع التحكم — API timeout
⏸ Paused — 450 remaining
▶ Resumed
⏹ Stopped. 43 translated · 2 failed
Products use an ACF repeater field for per-branch inventory:
branch_stock ← row count
branch_stock_0_branch = jeddah-branch
branch_stock_0_stock_qty = 5
On first translation — branch stock is copied to the English product.
Day to day — whenever branch stock changes on the Arabic product, the plugin automatically copies the change to the English version in real time. No manual action needed.
If the Arabic product category already has an English translation in WPML, it is assigned automatically.
If no English version exists, the plugin:
- Translates the category name via AI
- Creates the English category in WordPress
- Links Arabic and English versions in WPML
- Assigns the new category to the English product
This happens automatically for both product_cat and offer_category taxonomies.
Override or add to the fields list for a specific product.
add_filter( 'erpgulf_gt_fields', function( $fields, $post_id ) {
// Add a custom field for a specific product type
if ( get_post_meta( $post_id, 'is_special', true ) ) {
$fields[] = 'meta:special_description';
}
return $fields;
}, 10, 2 );Customise the AI prompt for any field.
add_filter( 'erpgulf_gt_prompt', function( $prompt, $field, $text, $post_id ) {
if ( $field === 'title' ) {
// Keep product codes and numbers intact
$prompt = "Translate this Arabic product title to English. "
. "Keep part numbers, codes, and years exactly as they are. "
. "Return only the translated title.\n\n{$text}";
}
return $prompt;
}, 10, 4 );Post-process any translated text before saving.
add_filter( 'erpgulf_gt_translated_text', function( $translated, $original, $field, $post_id ) {
if ( $field === 'title' ) {
// Capitalise first letter of each word
$translated = ucwords( strtolower( $translated ) );
}
return $translated;
}, 10, 4 );Force a specific provider regardless of settings.
add_filter( 'erpgulf_gt_active_provider', function( $provider ) {
return 'openai'; // always use OpenAI
} );Fires just before translation starts for a product.
add_action( 'erpgulf_gt_before_translate', function( $post_id ) {
// Log translation start
error_log( "Starting translation for product {$post_id}" );
} );Fires after translation is saved successfully.
add_action( 'erpgulf_gt_after_translate', function( $post_id, $translations ) {
// Send notification
wp_mail( 'admin@example.com', 'Product translated', "Product {$post_id} translated." );
}, 10, 2 );Fires when a field fails to translate.
add_action( 'erpgulf_gt_translation_failed', function( $post_id, $field, $error ) {
error_log( "Translation failed: product {$post_id}, field {$field}: {$error}" );
}, 10, 3 );- Create a new file e.g.
deepseek-provider.php:
<?php
/**
* DeepSeek provider for ERPGulf AI Translate
*/
function erpgulf_gt_translate_deepseek( string $prompt, array $settings ): string|WP_Error {
$api_key = $settings['deepseek_api_key'] ?? '';
if ( empty( $api_key ) ) {
return new WP_Error( 'no_key', 'DeepSeek API key not set.' );
}
$response = wp_remote_post( 'https://api.deepseek.com/chat/completions', [
'timeout' => 30,
'headers' => [
'Authorization' => 'Bearer ' . $api_key,
'Content-Type' => 'application/json',
],
'body' => json_encode([
'model' => $settings['deepseek_model'] ?? 'deepseek-chat',
'messages' => [ [ 'role' => 'user', 'content' => $prompt ] ],
]),
] );
if ( is_wp_error( $response ) ) return $response;
$body = json_decode( wp_remote_retrieve_body( $response ), true );
$text = $body['choices'][0]['message']['content'] ?? '';
if ( empty( $text ) ) {
return new WP_Error( 'empty_response', 'DeepSeek returned empty response.' );
}
return trim( $text );
}-
Add
require_oncein the main plugin file alongside other providers. -
Add one entry to
erpgulf_gt_ai_providers():
'deepseek' => [
'label' => 'DeepSeek',
'models' => [ 'deepseek-chat' => 'DeepSeek Chat' ],
'default_model' => 'deepseek-chat',
'key_label' => 'DeepSeek API Key',
'key_option' => 'erpgulf_gt_deepseek_api_key',
'model_option' => 'erpgulf_gt_deepseek_model',
'key_url' => 'https://platform.deepseek.com',
'key_hint' => 'Get your API key from the DeepSeek platform.',
'key_placeholder' => 'sk-...',
],- Go to ERPGulf AI Translate → Settings → Active AI Provider → select DeepSeek → Save.
No other code changes needed.
wp post list --post_type=product --post_status=publish --allow-root \
--fields=ID,post_title --format=tablewp post meta get POST_ID _sku --allow-rootwp post delete POST_ID --force --allow-rootwp post list --post_status=trash --post_type=any \
--fields=ID,post_type,post_title --allow-rootwp post delete \
$(wp post list --post_type=any --post_status=trash --format=ids --allow-root) \
--force --allow-rootwp wc tool run regenerate_product_lookup_tables --allow-root --user=1wp option update erpgulf_gt_fields \
'["title","content","excerpt","meta:manufacturer_brand","repeater:add_compactable_details"]' \
--allow-root --format=jsonwp option get erpgulf_gt_fields --allow-root| Table | Purpose |
|---|---|
wp_posts |
Product posts — Arabic and English versions |
wp_postmeta |
Product meta fields (price, stock, custom fields, repeaters) |
wp_icl_translations |
WPML language links between Arabic and English posts |
wp_term_taxonomy |
Product categories and offer categories |
wp_term_relationships |
Category assignments to products |
wp_wc_product_meta_lookup |
WooCommerce search lookup table (SKU search) |
Run ♻️ Regenerate Lookup Table from the settings page Tools section, or:
wp wc tool run regenerate_product_lookup_tables --allow-root --user=1Run this to reset:
wp option update erpgulf_gt_fields \
'["title","content","excerpt","meta:manufacturer_brand"]' \
--allow-root --format=jsonThe deleted product is in Trash. Open the Arabic product — the meta box shows a 🗑️ Restore / Delete option. Delete it permanently and retranslate.
Go to Settings → Tools → 🔄 Sync All Translated Products. This copies compatibility data without needing to retranslate.
Same — run 🔄 Sync All Translated Products. For future translations, categories are handled automatically.
The page may have been refreshed mid-translation. On the product edit page, simply click Translate to English again. The plugin updates the existing English version — it does not create duplicates.
Check that branch_stock meta key exists on the Arabic product. The auto-sync hook fires on updated_post_meta and added_post_meta — it requires the Arabic product to be saved after the plugin is installed.
- Pages & Posts translation page (
erpgulf-gt-pages.php) - Shows all pages/posts with ✅/
⚠️ translation status per row - Per-row Translate / ↺ Retranslate button
- Edit and Edit EN links inline
- Stats bar: Total · Translated · Not Translated
- Maintenance tools on bulk page: Empty Trash, Fix WPML Links, Translation Status, Reload
- Offer category (
offer_category) synced alongside product categories - Trash detection on product meta box with Restore / Delete buttons
- View English → link always visible when English version exists
en_titlereturned in AJAX response for bulk log display
- Initial release
- Google Gemini, OpenAI, and Claude providers
- Single product translation from product edit page
- Bulk translate page with live progress, pause, stop
- ACF repeater field support (compatibility, branch stock)
- Auto-sync branch stock changes Arabic → English
- Category translation and auto-creation in WPML
- Tools: Regenerate Lookup Table, Sync All Translated Products
- Trash detection with Restore / Delete buttons
- Developer hooks: filters and actions
Email: support@erpgulf.com
Author: Farook K — https://medium.com/nothing-big









