LocalePro
Menu

Docs

WP-CLI

Export, import, and repair the translation memory, and rebuild translated addresses, from the command line.

LocalePro registers two WP-CLI commands: wp localepro memory and wp localepro slugs. They exist for the deploy path, where there is no browser: CI that moves translations between environments, and a database restore that arrives without the plugin’s own tables.

Both run after WordPress has loaded, so the usual --url and --path flags apply on a multisite or from outside the install directory.

wp localepro memory

The translation memory is every translated sentence the site has paid for. These subcommands move it around and check it.

export

Write the memory out as a file.

wp localepro memory export [--locale=<locale>] [--status=<status>] [--format=<format>] [--file=<file>] [--human]
Flag Meaning
--locale=<locale> Only this target language.
--status=<status> Only rows in this status: pending, translated, manual, stale, or failed.
--format=<format> jsonl (default), csv, or xliff.
--file=<file> Write to this path instead of standard output.
--human Only rows a person has touched: manual, locked, or stale.
wp localepro memory export --file=tm.jsonl
wp localepro memory export --locale=es --format=xliff --file=es.xliff

Without --file, the file goes to standard output, so it can be piped. On WordPress VIP the path must be under the temp directory or wp-content/uploads; the rest of the filesystem is read-only there.

import

Read a file back in.

wp localepro memory import <file> [--strategy=<strategy>] [--dry-run]
Argument Meaning
<file> Path to a JSONL, CSV, or XLIFF file. The format is read from the extension (.jsonl, .ndjson, .csv, .xlf, .xliff), or from the start of the file when the extension doesn’t say.
--strategy=<strategy> fill (default) leaves manual and locked rows alone. overwrite replaces them.
--dry-run Count what would happen without writing anything.
wp localepro memory import tm.jsonl
wp localepro memory import review.csv --dry-run

The file is read one record at a time, so a file of any size imports in flat memory. A progress bar runs while it works, then a one-line report:

created: 12  updated: 3  skipped (protected): 1  rehashed: 0  invalid: 0

skipped (protected) is rows left alone under fill. rehashed is rows whose stored hash no longer matched their text, usually after a wp search-replace on the exporting site. invalid is rows that could not be stored, for instance an XLIFF unit whose translation lost its inline markers; each one is printed as a warning.

Weglot’s own XLIFF or CSV export imports directly; see import and export.

doctor

Find drifted hashes, duplicate identities, and rows that will bill again.

wp localepro memory doctor [--fix]

Without --fix, nothing is written; the command reports what it found:

drifted: 0  rehashed: 0  duplicates: 0  merged: 0  failed: 3  pending: 0
  source en: 1284 strings
  • drifted is rows whose stored hash no longer matches their text. With --fix they are rehashed.
  • duplicates is identities that exist twice, the usual leftover of an earlier drift. With --fix they are merged onto the row that already has translations.
  • failed and pending are rows with no usable text. They are not repaired, only counted and warned about: a failed row is sent to a provider again on the next render.
  • source lines list how many strings exist per source language. A language here that is not the site’s configured source means the source setting changed after translations were stored, and those rows will not be found.

Run it after a database copy and before shipping one.

wp localepro slugs

reindex

Rebuild the translated-slug index from each post’s own settings.

wp localepro slugs reindex

Translated addresses are stored twice: on the post, as the source of truth, and in an index table the router reads. A database restored from before that table existed, a staging sync that copied posts and their meta but not the plugin’s tables, or a migration done as a content export can leave the two apart. The symptom is that every translated URL returns 404 while the admin screens still show the slugs that should be serving them.

reindex re-derives the index from the per-post settings. It is safe to run at any time and safe to run twice.

Success: Rebuilt the translated-slug index from 212 objects.
  • Import and export, for the file formats and the staging-to-production playbook.
  • REST API, which exposes the same export and import for a script that has no shell.