WP-CLI commands for WP Provider Translate
WP Provider Translate adds the wp wpprovider-translate command to WP-CLI. With it you can translate pages right away, run the site crawl, check the translation queue, install language packs and switch from WPML or TranslatePress, all from the command line of your server. Everything here also happens by itself in the background; the commands are for when you want it now, or want to see what is going on.
Run the commands in your WordPress folder, as you run any other wp command. wp help wpprovider-translate lists them. For the PHP filters and actions, see Filters and actions.
Before you start
- Connect the site first. Commands that send text or collect translations need a connected site with at least one language. See Install and connect and Choose your languages.
- The sync line. Many commands end with a line like
12 stored, 3 sent and waiting, 0 failed.: how many translations were stored on your site in this run, how many texts are sent and waiting for their translation, and how many failed.
wp wpprovider-translate translate
Translates one or more posts or pages now, in every language they are available in, and waits for the translations.
Synopsis
wp wpprovider-translate translate <id>... [--wait=<seconds>]Options
<id>...: one or more post or page ids. Only published posts are translated.--wait=<seconds>: how long to wait for the translations. Default120.
Example
wp wpprovider-translate translate 12 34 --wait=300What it prints. For each post and language, the result of opening the page, such as Post 12 /de/: 200. Then, every few seconds, the sync line, until every translation is stored (All translations stored.) or the time is up. In that case it warns that some translations are still on their way; run wp wpprovider-translate sync later to collect them.
wp wpprovider-translate crawl
Opens every public page of the site in every language, so its new text is sent for translation, and then sends it. The crawl also follows lists that continue on more pages, such as the blog and shop categories. See How translation runs.
Synopsis
wp wpprovider-translate crawl [--restart] [--background]Options
--restart: start from the beginning. Without it, a crawl that is still running continues where it was; when none is running, a new one starts.--background: hand the crawl to WP-Cron and return at once. Use it on hosts that stop long-running commands.
Example
wp wpprovider-translate crawl --restart --backgroundWhat it prints. Without --background: Rendered 40 of 312 pages as it goes, then the sync line and Crawl finished: 312 pages. With --background: that the crawl is running and how many pages it has, and that you can follow it with wp wpprovider-translate status or on the settings page.
wp wpprovider-translate sync
Sends text that has not been sent yet and collects finished translations, once. It also makes the translated addresses (slugs) of pages whose title translation has just arrived.
Synopsis
wp wpprovider-translate syncNo options.
Example
wp wpprovider-translate syncWhat it prints. The sync line. When something went wrong, for example the site is not connected, the command ends with an error that says why.
wp wpprovider-translate retry
Puts every text that failed back in the queue now, including texts that ran out of automatic retries, and then syncs.
Synopsis
wp wpprovider-translate retryNo options.
Example
wp wpprovider-translate retryWhat it prints. How many failed texts were queued again (5 failed segments queued again.), then the sync line.
wp wpprovider-translate status
Shows how far translation is, without changing anything.
Synopsis
wp wpprovider-translate statusNo options.
Example
wp wpprovider-translate statusWhat it prints.
- One line per language with the number of translations stored on your site, such as
DE: 1840 translations. - The crawl: whether it is running or done, and how many of its pages it has opened.
- The queue: texts not sent yet, texts sent and waiting, texts that failed, and how many of those failed texts will no longer be retried automatically (use
retryfor those).
wp wpprovider-translate stats
Shows sizes and cache details for support and performance checks. It changes nothing.
Synopsis
wp wpprovider-translate statsNo options.
Example
wp wpprovider-translate statsWhat it prints. How many records the plugin keeps in each of its storage areas, when its page records were last written, the 20 most recently cached language pages (language, size, how often the cached copy was missed, and when it was updated), and the current time in UTC. Support may ask you for this output.
wp wpprovider-translate packs
Installs the official WordPress language packs for your languages now, instead of waiting for the background job. Language packs translate the texts of WordPress itself, your theme and your plugins.
Synopsis
wp wpprovider-translate packsNo options.
Example
wp wpprovider-translate packsWhat it prints. One line per WordPress locale with installed, failed, or no-write when WordPress may not write to its languages folder on this host. Then how many plugin and theme translations were updated. American English is skipped, because WordPress has it built in.
wp wpprovider-translate forget
Forgets the machine translations of every text that contains the words you give, so they are translated again the next time a page with that text is built. Translations someone reviewed or corrected are kept. It also clears the plugin’s cache of translated pages, so the change shows on the next visit.
Synopsis
wp wpprovider-translate forget <text>Options
<text>: words in your site’s own language. Every text that contains them is affected, in every language. Put the text in quotes when it has spaces.
Example
wp wpprovider-translate forget "Select options for"What it prints. How many machine translations were forgotten, such as 14 machine translations forgotten.
To fix one translation by hand instead, see Correct and review translations.
wp wpprovider-translate texts
Queues texts that are saved in settings and that no page shows, such as WooCommerce email subjects, headings and footers and payment method texts, and sends them right away. The crawl does this too, at its end.
Synopsis
wp wpprovider-translate textsNo options.
Example
wp wpprovider-translate textsWhat it prints. The sync line.
wp wpprovider-translate email-texts
For WooCommerce shops: lists, per language, the texts in your customer emails that no language pack translates. It changes nothing. Use it to see which email texts are translated as your own content. See WooCommerce.
Synopsis
wp wpprovider-translate email-textsNo options.
Example
wp wpprovider-translate email-textsWhat it prints. Per language, how many such texts there are (fr: 6 text(s) no language pack translates) and the first eight, shortened. When no email could be built it says why. When nothing was checked, it says how many customer emails are turned on.
wp wpprovider-translate wpml-report
Shows what a site that used WPML would bring over when you switch. It reads WPML’s data, also when WPML is deactivated, and changes nothing. See Switch from WPML.
Synopsis
wp wpprovider-translate wpml-reportNo options.
Example
wp wpprovider-translate wpml-reportWhat it prints.
- The default language and the active languages, and a warning for any language WP Provider Translate does not support.
- How WPML made its addresses (and the domain per language, if any).
- The number of published translation groups, by content type, and the number of pages per language.
- Per language, how many pages are missing (they become “not available” in that language) and how many originals were written in another language.
- How many pages exist only in the default language, and the number of translated strings per language.
It ends with an error when the site has no WPML data.
wp wpprovider-translate wpml-import
Brings a WPML site over: the languages, which pages exist in which language, translated page addresses, and WPML’s translations, which are kept on your site as imported translations. WPML’s own data is not changed. Without --apply it only reports what it would do.
When the site is connected, the translation service also pairs texts that the page structure could not pair. That can take up to four minutes; the answers are kept, so a run with --apply after a dry run does not ask again.
Synopsis
wp wpprovider-translate wpml-import [--apply] [--recent=<months>]Options
--apply: do the import. Without it, nothing is changed.--recent=<months>: posts from this many months back that WPML has in only some languages become available in every language and are translated.0keeps them in the languages WPML had them in. Default12.
Example
wp wpprovider-translate wpml-importwp wpprovider-translate wpml-import --apply --recent=24What it prints.
- A warning when WPML is still active: deactivate it before you switch, because both would handle the language addresses.
- The languages, and the domain per language if WPML used domains.
- How many translation groups, pages with their languages set, translated page addresses and paired translated pages it found.
- Per language, how many texts were paired and how many were not (those are left for translation or review).
- How many texts the translation service matched, and whether matching is still running (then run the command again in a few minutes).
- How many string translations and imported texts there are, and how many WPML translation posts can be retired later.
Dry run: nothing changed. Run with --apply to import., or after--apply:Imported. Check the site, then run: wp wpprovider-translate wpml-finish
It stops with an error, without changing anything, when the site has no WPML data or WPML uses a language WP Provider Translate does not support.
wp wpprovider-translate wpml-finish
The last step of the switch from WPML, after you have checked the site: moves WPML’s translated posts to the trash. When your site empties the trash within 30 days, they are set to draft instead, so they are not lost. WPML must be deactivated. To undo, restore the posts and reactivate WPML.
Synopsis
wp wpprovider-translate wpml-finishNo options.
Example
wp wpprovider-translate wpml-finishWhat it prints. How many WPML translation posts were moved, and whether to the trash or to draft. It stops with an error when WPML is still active or when there is nothing to finish because the import has not run yet.
wp wpprovider-translate translatepress-import
Brings a TranslatePress site over while TranslatePress is still active: each page is read in your own language and in its translation, and the texts that pair up are imported, together with translated page addresses. Imported texts are kept on your site like your own corrections. It works in batches; run it again with the next offset until it says it is done. Without --apply it only reports. See Switch from TranslatePress.
Synopsis
wp wpprovider-translate translatepress-import [--apply] [--offset=<n>] [--limit=<n>]Options
--apply: save what pairs. Without it, nothing is changed.--offset=<n>: the first page of this batch. Default0.--limit=<n>: pages per batch. Default30.
Example
wp wpprovider-translate translatepress-importwp wpprovider-translate translatepress-import --apply --offset=30What it prints.
- The languages, and which pages of how many this batch covered (
Pages 31 to 60 of 212.). - Per language, how many translated texts were found and how many could not be paired.
- How many texts were imported and how many translated page addresses were found.
- A warning for each page that could not be read.
Next batch: --offset=60while there are pages left.Dry run: nothing changed. Run with --apply to import.,Batch imported., or after the last batch:Imported. Deactivate TranslatePress, then run: wp wpprovider-translate translatepress-finish
It stops with an error when the site has no TranslatePress settings or TranslatePress is not active.
wp wpprovider-translate translatepress-finish
The last step of the switch from TranslatePress, after the import and with TranslatePress deactivated: WP Provider Translate takes over TranslatePress’s languages and replaces its language switchers in your menus with its own. TranslatePress’s shortcodes and block in your content keep working, and its data stays. A crawl starts, so texts TranslatePress had not translated are translated now.
Synopsis
wp wpprovider-translate translatepress-finishNo options.
Example
wp wpprovider-translate translatepress-finishWhat it prints. The languages, how many menu switchers were replaced, for each TranslatePress shortcode or block in your content in how many pages it keeps working, and Switched. with a note that the remaining texts are now translated page by page. It stops with an error while TranslatePress is still active.
Troubleshooting
translatekeeps waiting. Large pages take a few minutes. Let it time out, then runwp wpprovider-translate statusto see the queue andwp wpprovider-translate syncto collect what has arrived.- The crawl stops halfway on my host. Some hosts end long commands. Run
wp wpprovider-translate crawl --background; it continues through WP-Cron. statusshows failed texts that are no longer retried. Runwp wpprovider-translate retry. If they fail again, use WP Provider Translate → Report a problem in WordPress.packssaysno-write. WordPress may not write to its languages folder on this host. Interface texts are then translated like page text instead.