如何使用Polylang Pro for WooCommerce批量翻译1500+产品?
Hey Marco, totally feel your pain—translating 1500 products one by one would be a total nightmare! Since you’re already using Polylang Pro for WooCommerce, let’s break down the most efficient ways to handle bulk translation without burning out:
1. Start with Polylang Pro’s Native Bulk Translation Tool
Polylang Pro has a built-in bulk action that sets up translated product entries in one go:
- Head to Products > All Products in your WordPress dashboard.
- Select all products you want to translate (use the top checkbox to select everything, or filter by category/tag if you want to work in batches).
- Open the Bulk Actions dropdown, pick Translate, then click Apply.
- A modal will pop up where you can choose your target language(s). Polylang will automatically create empty translated product pages linked to their original versions.
This just creates the shells—now let’s fill them with content efficiently.
2. Sync or Auto-Translate Fields with Polylang
Polylang lets you auto-sync or machine-translate common product fields to save time:
- Go to Languages > Settings > WooCommerce and check the boxes for fields you want to sync (like price, stock status) or auto-translate (title, description).
- For machine translation, head to Languages > Translations and connect a service like Google Translate or DeepL (Polylang Pro integrates with both). Once set up, Polylang will auto-fill translated content for the fields you selected.
- Pro tip: Use the Sync option for fields that don’t need translation (like SKU or price) to avoid manual updates altogether.
3. Import/Export via CSV for Full Control
If you want to use professional translators or spreadsheet tools, CSV import/export is your best bet:
- Export: Go to Products > Export, select all fields you need translated (title, short description, long description, attributes, etc.), and make sure to include the
Languagecolumn added by Polylang. Export the CSV. - Translate: Open the CSV in Google Sheets or Excel. For each target language, duplicate the original product rows, update the language code (e.g., from
entoesfor Spanish), and replace the content with translated text. - Import: Go to Products > Import, upload your translated CSV, map the columns correctly (don’t forget to map the
Languagecolumn to Polylang’s language field), and run the import. Polylang will automatically link translated products to their originals.
4. Custom Script for Tech-Savvy Users (One-Time Run)
If you’re comfortable with code, a simple PHP script can automate the entire process. Here’s a basic example that creates translations and triggers machine translation (make sure your Polylang translation service is set up first):
add_action('init', 'bulk_translate_woocommerce_products'); function bulk_translate_woocommerce_products() { // IMPORTANT: Comment this out after running once to avoid duplicates! $target_lang = 'fr'; // Replace with your target language code (e.g., 'es', 'de') $original_lang = 'en'; // Replace with your site's default language code $products = get_posts([ 'post_type' => 'product', 'posts_per_page' => -1, 'post_status' => 'publish', 'lang' => $original_lang ]); foreach ($products as $product) { // Skip if translation already exists if (pll_get_post($product->ID, $target_lang)) continue; // Create empty translation $translated_product_id = pll_copy_post($product->ID, $target_lang); // Trigger auto-translation for the new product pll_translate_post($translated_product_id); } }
- Add this to your child theme’s
functions.phpor use a code snippet plugin. Always test this on a staging site first, and remove/comment the code after it runs once.
Quick Pro Tips to Avoid Headaches
- Staging site first: Never run bulk operations on your live site—test everything in a staging environment to catch errors.
- Batch processing: Split your 1500 products into smaller batches (e.g., 100 at a time) to avoid timeouts or server errors.
- Spot-check translations: Machine translation is fast, but always review key fields like product titles and descriptions to ensure accuracy for your customers.
内容的提问来源于stack exchange,提问作者marco

