Support Log in

27. WP-CLI Commands

Developer Guide
Prefer video? Watch the Lang Forge tutorials 9 short guides covering every feature Watch

All commands are under the wp langforge namespace. These commands are essential for managing translations in bulk, automating deployment workflows, and scripting translation processes.

wp langforge status

Show the active languages with the number of published posts in each, and mark the default language.

bash
$ wp langforge status
+------+---------+-------+---------+
| Code | Language | Posts | Default |
+------+---------+-------+---------+
| ru   | Русский  | 45    | Yes     |
| en   | English  | 38    |         |
| de   | Deutsch  | 12    |         |
+------+---------+-------+---------+

wp langforge languages

List all active languages with their configuration details.

bash
$ wp langforge languages
+------+---------+---------+--------+---------+
| Code | Name    | Native  | Locale | Default |
+------+---------+---------+--------+---------+
| ru   | Russian | Русский | ru_RU  | *       |
| en   | English | English | en_US  |         |
+------+---------+---------+--------+---------+

wp langforge translate <post_id> <language>

Create a draft translation of a post in the specified language: a copy of its title, content, and excerpt, linked to the original. The copy is not machine-translated.

bash
$ wp langforge translate 42 en
Success: Created translation #99 (en) for post #42.
Arguments:
ArgumentDescription
<post_id>Source post ID
<language>Target language code
bash
# Batch translate: create English draft copies for all Russian posts
$ wp post list --meta_key=_langforge_language --meta_value=ru --format=ids | 
  xargs -I{} wp langforge translate {} en

wp langforge set-language <post_id> <language>

Set or change the language of an existing post.

bash
$ wp langforge set-language 42 ru
Success: Set language 'ru' for post #42.

# Bulk set language for all posts without a language
$ wp post list --meta_key=_langforge_language --meta_compare='NOT EXISTS' --format=ids | 
  xargs -I{} wp langforge set-language {} ru

wp langforge link <post_id_1> <post_id_2>

Link two existing posts as translations of each other.

bash
$ wp langforge link 42 99
Success: Linked posts #42 and #99 as translations.

wp langforge unlink <post_id> <language>

Remove a translation link. This does not delete the target post.

bash
$ wp langforge unlink 42 en
Success: Unlinked en translation from post #42.

wp langforge tm-populate

Populate Translation Memory from all existing translations (PRO).

bash
$ wp langforge tm-populate
Populating Translation Memory from existing translations...
Success: Added 342 segments to Translation Memory.

wp langforge export

Export the published posts in your default language to XLIFF or CSV, with the translation into the language you give filled in where there is one (PRO). The file is saved in wp-content/uploads/langforge/.

bash
# Export to XLIFF (default)
$ wp langforge export --lang=en --format=xliff --output=export-en.xliff
Success: Exported to /path/to/wp-content/uploads/langforge/export-en.xliff

# Export to CSV
$ wp langforge export --lang=de --format=csv --output=export-de.csv
Success: Exported to /path/to/wp-content/uploads/langforge/export-de.csv
Flags:
FlagDescriptionDefault
--langTarget language code (required)—
--formatxliff or csvxliff
--outputOutput file name, saved in wp-content/uploads/langforge/ (a folder in the name is ignored)langforge-export-<source>-<target>.<ext>

wp langforge import <file>

Import translations from an XLIFF or CSV file (PRO). 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 goes on after the count with “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.

bash
$ wp langforge import translations.xliff
Success: Imported 156 translations.

wp langforge strings-key

Show the state of the key of the strings table, or rebuild it. The key decides whether names that differ only in letter case or accent, such as “Size” and “size”, are separate strings. Lang Forge changes it by itself when an administrator opens an admin page, except on a site whose strings table has more than 500,000 rows: a web request must not hold such a table for minutes, so that site stays as it was, and works as before, until you run this command. Without --yes the command only shows the number of rows, the key, and the last answer of the admin pages. With --yes it rebuilds the key now, whatever the number of rows; how long that takes depends on the server. When the key is already binary it says so and changes nothing.

bash
$ wp langforge strings-key
Strings table: 640000 rows.
Key: not binary, "Size" and "size" are one string.
Last answer of the admin pages: skipped (The table is too big to be rebuilt in a request.).
To rebuild the key now, run: wp langforge strings-key --yes

$ wp langforge strings-key --yes
Strings table: 640000 rows.
Key: not binary, "Size" and "size" are one string.
Last answer of the admin pages: skipped (The table is too big to be rebuilt in a request.).
Success: The key is rebuilt: the names and domains of the strings now compare byte for byte; 640000 rows kept.

wp langforge flush

Flush WordPress rewrite rules.

bash
$ wp langforge flush
Success: Rewrite rules flushed.

Scripting Examples

bash
# Complete deployment script: set up translations on a new site
#!/bin/bash

# 1. Check status
wp langforge status

# 2. Set language for all unassigned content
wp post list --meta_key=_langforge_language --meta_compare='NOT EXISTS' --format=ids | 
  xargs -I{} wp langforge set-language {} ru

# 3. Create English draft copies of all Russian posts
wp post list --meta_key=_langforge_language --meta_value=ru --post_type=post --format=ids | 
  xargs -I{} wp langforge translate {} en

# 4. Flush rewrite rules
wp langforge flush

# 5. Verify
wp langforge status

—

Forge AI Assistant Online

Hi! I'm the Lang Forge AI assistant. Ask me anything about the plugin — setup, features, troubleshooting, or development.

Just now
Powered by Forge AI · Browse docs