Skip to content

Commit 122ed80

Browse files
Add a doc explaining how to force output to a specific locale
1 parent 5fd76a6 commit 122ed80

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

bin/handbook-manifest.json

+6
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@
5353
"markdown_source": "https:\/\/github.com\/wp-cli\/handbook\/blob\/master\/external-resources.md",
5454
"parent": null
5555
},
56+
"force-output-specific-locale": {
57+
"title": "Force output to a specific locale",
58+
"slug": "force-output-specific-locale",
59+
"markdown_source": "https:\/\/github.com\/wp-cli\/handbook\/blob\/master\/force-output-specific-locale.md",
60+
"parent": null
61+
},
5662
"governance": {
5763
"title": "Governance",
5864
"slug": "governance",

force-output-specific-locale.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Force output to a specific locale
2+
3+
WP-CLI always outputs English because it doesn't support localization. But, because WordPress supports localization, you may see non-English output when performing specific commands.
4+
5+
For instance:
6+
7+
$ wp theme update --all
8+
מעבר למצב תחזוקה...
9+
מוריד עדכונים מ-https://downloads.wordpress.org/theme/hueman.3.3.25.zip...
10+
Using cached file '/home/xxx/.wp-cli/cache/theme/hueman-3.3.25.zip'...
11+
פתיחת עדכון...
12+
התקנת גרסה חדשה...
13+
הסרת הגרסה הקודמת של התבנית...
14+
התבנית עודכנה בהצלחה.
15+
ביטול מצב תחזוקה...
16+
+--------+-------------+-------------+---------+
17+
| name | old_version | new_version | status |
18+
+--------+-------------+-------------+---------+
19+
| hueman | 3.3.24 | 3.3.25 | Updated |
20+
+--------+-------------+-------------+---------+
21+
Success: Updated 1 of 1 themes.
22+
23+
To force WordPress to always output English at the command line, you need to filter the active locale.
24+
25+
Given a `force-locale.php` file:
26+
27+
<?php
28+
WP_CLI::add_wp_hook( 'pre_option_WPLANG', function() {
29+
return 'en_US';
30+
});
31+
32+
You can force the locale to `en_US` with:
33+
34+
wp --require=force-locale.php
35+
36+
One nice thing about this approach is that you can easily apply it across multiple WP installs [using a config file](https://make.wordpress.org/cli/handbook/config/#config-files).

0 commit comments

Comments
 (0)