Skip to content

Repository files navigation

ERPGulf AI Translate

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


What This Plugin Does

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.


Files

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

Requirements

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

Installation

  1. Upload the plugin folder to /wp-content/plugins/
  2. Activate the plugin in WordPress Admin → Plugins
  3. Go to ERPGulf AI Translate in the admin menu
  4. Enter your API key for your chosen AI provider
  5. Select which fields to translate
  6. Save settings

Quick Start

Single product

  1. Open any Arabic product in the WordPress admin
  2. Find the 🤖 ERPGulf AI Translate box in the right sidebar
  3. Click Translate to English
  4. Done — the English product is created or updated automatically

Single product translation

Bulk translate

  1. Go to ERPGulf AI Translate → Bulk Translate
  2. All untranslated Arabic products are listed with checkboxes
  3. Select the products you want (Select All is checked by default)
  4. Click ▶ Start
  5. Watch the live progress — each product shows ✅ or ❌ as it completes
  6. Use ⏸ Pause or ⏹ Stop at any time

Bulk translate page


AI Providers

Select AI provider

Google Gemini (recommended — free)

  • 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

OpenAI ChatGPT

Anthropic Claude


Settings Page

Admin → ERPGulf AI Translate

Active AI Provider

Select which AI handles translations. All credentials are saved — only the selected provider is used.

Gemini and ChatGPT options Anthropic option

Translation Direction

Language selection

Source Language: Arabic    ← language products are written in
Target Language: English   ← must match your WPML language name

Fields to Translate

Field selections 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

Tools & Maintenance

WordPress tools

♻️ 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.


What Gets Translated vs Copied

Translated by AI

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

Copied as-is (first translation only)

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

Auto-synced in real time (no action needed)

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

Not touched

Password              Not applicable
Order data            Not applicable
Customer data         Not applicable

Product Meta Box

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]

Pages & Posts Translation

Admin → ERPGulf AI Translate → Pages & Posts

Translate WordPress pages and blog posts — separate from WooCommerce products.

Translate Pages

Pages tab

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

Posts tab

Translate Blogs

Same layout for blog posts — toggle between Pages and Posts using the tab buttons at the top.

Per-row translate button

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.

Stats bar

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).

Stats bar

┌──────────┐  ┌──────────┐  ┌──────────┐
│   738    │  │    0     │  │    0     │
│Untranslated│ │Translated│  │  Failed  │
└──────────┘  └──────────┘  └──────────┘

Controls

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

Maintenance Tools

Six tools available directly on the bulk page — no need to go to Settings:

Maintenance tools

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

Product list

Each product shows:

  • Checkbox (checked by default)
  • Arabic product name
  • ID and SKU

Status icons update live:

  • 🔄 Currently translating
  • ✅ Successfully translated
  • ❌ Failed

Live log

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

Branch Stock

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.


Categories

Existing WPML categories

If the Arabic product category already has an English translation in WPML, it is assigned automatically.

Missing category translations

If no English version exists, the plugin:

  1. Translates the category name via AI
  2. Creates the English category in WordPress
  3. Links Arabic and English versions in WPML
  4. Assigns the new category to the English product

This happens automatically for both product_cat and offer_category taxonomies.


Developer Hooks

Filters

erpgulf_gt_fields

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 );

erpgulf_gt_prompt

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 );

erpgulf_gt_translated_text

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 );

erpgulf_gt_active_provider

Force a specific provider regardless of settings.

add_filter( 'erpgulf_gt_active_provider', function( $provider ) {
    return 'openai'; // always use OpenAI
} );

Actions

erpgulf_gt_before_translate

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}" );
} );

erpgulf_gt_after_translate

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 );

erpgulf_gt_translation_failed

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 );

Adding a New AI Provider

  1. 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 );
}
  1. Add require_once in the main plugin file alongside other providers.

  2. 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-...',
],
  1. Go to ERPGulf AI Translate → Settings → Active AI Provider → select DeepSeek → Save.

No other code changes needed.


WP-CLI Commands

Find untranslated products

wp post list --post_type=product --post_status=publish --allow-root \
  --fields=ID,post_title --format=table

Check translation status of a product

wp post meta get POST_ID _sku --allow-root

Delete a trashed English product

wp post delete POST_ID --force --allow-root

Check all trashed posts by type

wp post list --post_status=trash --post_type=any \
  --fields=ID,post_type,post_title --allow-root

Permanently delete all trashed posts

wp post delete \
  $(wp post list --post_type=any --post_status=trash --format=ids --allow-root) \
  --force --allow-root

Regenerate WooCommerce lookup table (fixes SKU search)

wp wc tool run regenerate_product_lookup_tables --allow-root --user=1

Fix option if wrong field key was saved

wp option update erpgulf_gt_fields \
  '["title","content","excerpt","meta:manufacturer_brand","repeater:add_compactable_details"]' \
  --allow-root --format=json

Check saved fields setting

wp option get erpgulf_gt_fields --allow-root

Database Tables Used

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)

Troubleshooting

English product not appearing in admin search

Run ♻️ Regenerate Lookup Table from the settings page Tools section, or:

wp wc tool run regenerate_product_lookup_tables --allow-root --user=1

Fields to Translate page shows wrong fields

Run this to reset:

wp option update erpgulf_gt_fields \
  '["title","content","excerpt","meta:manufacturer_brand"]' \
  --allow-root --format=json

English version shows as existing but product was deleted

The deleted product is in Trash. Open the Arabic product — the meta box shows a 🗑️ Restore / Delete option. Delete it permanently and retranslate.

Compatibility data missing on English product

Go to Settings → Tools → 🔄 Sync All Translated Products. This copies compatibility data without needing to retranslate.

Categories not showing on English product

Same — run 🔄 Sync All Translated Products. For future translations, categories are handled automatically.

Translation seems stuck or shows "Translating..."

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.

Branch stock not syncing

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.


Version History

2.1.2

  • 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_title returned in AJAX response for bulk log display

1.0.0

  • 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

Contact us for Support

Email: support@erpgulf.com
Author: Farook K — https://medium.com/nothing-big

About

An AI based translator plugin for woocommerce or wordpress , to save cost. Not credit based, just use free AI subscription

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages