WP-CLI Commands for Multilingual WordPress Management
If you manage WordPress sites at scale — agencies, developers, DevOps — you spend most of your time in a terminal, not in wp-admin. Lang Forge adds a wp langforge command with subcommands for the main steps of a multilingual workflow, so you can script them.
Why WP-CLI matters for multilingual sites
- CI/CD pipelinesexport and import translation files as part of a deploy, and check how many posts each language has
- Bulk operationscreating translation drafts for a thousand posts one at a time in the browser is painful; a shell loop around
wp langforge translatedoes it for a whole list of posts - Automationagency teams set up nightly cron jobs to populate translation memory or export XLIFF
- Scriptingshell scripts that set the language of existing posts and link them to their translations
The commands
Status and inspection
wp langforge status
Prints a table of your active languages with the number of published posts in each, and marks the default language.
wp langforge languages
Lists the active languages with their code, name, native name, and locale.
Translation drafts and links
wp langforge translate 42 en
Creates a draft translation of post 42 in the given language: a copy of its title, content, and excerpt, linked to the original. The copy is not machine-translated, so you translate it in the editor afterwards.
wp langforge set-language 42 ru
Sets the language of an existing post.
wp langforge link 42 99
Links two existing posts as translations of each other.
wp langforge unlink 42 en
Removes the link between post 42 and its translation in that language. Both posts are kept.
Translation memory (Pro)
wp langforge tm-populate
Scans all existing translated posts and populates the translation memory. Useful after migrating from another translation plugin or after importing a large batch of content.
Export and import (Pro)
wp langforge export --lang=en --format=xliff --output=export.xliff
Exports the published posts in your default language as XLIFF 1.2, with the existing translation into the language you give with --lang filled in where there is one. The file is saved in wp-content/uploads/langforge/ and the command prints its path. --format is xliff (the default) or csv.
wp langforge export --lang=de --format=csv --output=export.csv
CSV format for simpler workflows. The file name must end in .csv for CSV, and in .xliff or .xlf for XLIFF.
wp langforge import translations.xliff
Imports translations from an XLIFF or CSV file. The format is picked from the file extension: .xliff, .xlf, or .csv. When the import did not take some rows of the file as they were written, the command also prints, after the count, “Some rows of the file need your attention:” and one line for each of those rows: the title of the page, what happened to the row, and a link to edit the page. These are the notes that the Import screen shows. A Pro add-on that does not send these notes prints only the count.
Maintenance
wp langforge strings-key
Shows the number of rows in the strings table, whether its key tells names that differ only in letter case or accent apart (“Size” and “size”), and the last answer of the admin pages. Add --yes to rebuild the key now. Lang Forge rebuilds it by itself when an administrator opens an admin page, except on a site whose strings table has more than 500,000 rows: that site stays as it was until you run the command with --yes.
wp langforge flush
Flushes the WordPress rewrite rules.
Standard WP-CLI conventions
Every command follows WP-CLI’s conventions:
--helpon any command shows full usage and flag documentation- Exit codes that are safe to check in shell scripts (
0for success, non-zero for failure) - Colorized output when running in a TTY, plain when piped
Use cases
- Agency onboardinga shell script that sets the language of a client’s existing posts and links them to their translations
- Nightly content synca cron job that exports XLIFF for a target language and emails it to a translation vendor
- CI reportinga pipeline step that runs
wp langforge statusso the number of posts in each language shows up in the build log - Data migration
tm-populateafter importing content from another CMS - Disaster recoveryscripted re-import of translations from a backup file
Ready to script your multilingual workflow?
WP-CLI commands are included in every paid plan and in the free version on WordPress.org. Translation memory population, export, and import (tm-populate, export, import) are part of Pro.