New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install/update functionality taken from Core should not be localized #68

Closed
schlessera opened this Issue Nov 29, 2017 · 7 comments

Comments

3 participants
@schlessera
Member

schlessera commented Nov 29, 2017

WP-CLI output is not localized because it is meant to be easily parsable.

However, for some commands, like plugin update, WordPress functionality is being used that then produces localized output. We should force this WordPress functionality to produce English output that matches the rest of WP-CLI.

Example output (see Slack discussion):

$ wp theme update --all

מעבר למצב תחזוקה...
מוריד עדכונים מ-https://downloads.wordpress.org/theme/hueman.3.3.25.zip...
Using cached file '/home/xxx/.wp-cli/cache/theme/hueman-3.3.25.zip'...
פתיחת עדכון...
התקנת גרסה חדשה...
הסרת הגרסה הקודמת של התבנית...
התבנית עודכנה בהצלחה.
ביטול מצב תחזוקה...
+--------+-------------+-------------+---------+
| name   | old_version | new_version | status  |
+--------+-------------+-------------+---------+
| hueman | 3.3.24      | 3.3.25      | Updated |
+--------+-------------+-------------+---------+
Success: Updated 1 of 1 themes.
@schlessera

This comment has been minimized.

Show comment
Hide comment
@schlessera
Member

schlessera commented Nov 29, 2017

@danielbachhuber

This comment has been minimized.

Show comment
Hide comment
@danielbachhuber

danielbachhuber Nov 29, 2017

Member

We should force this WordPress functionality to produce English output that matches the rest of WP-CLI.

I'm not convinced forcing English output is the best approach because I'm concerned it may have unintended consequences. If it did have unintended consequences, it probably wouldn't be worth the change.

As an alternative, we could have some documentation that included a code snippet for the user to force this behavior.

Member

danielbachhuber commented Nov 29, 2017

We should force this WordPress functionality to produce English output that matches the rest of WP-CLI.

I'm not convinced forcing English output is the best approach because I'm concerned it may have unintended consequences. If it did have unintended consequences, it probably wouldn't be worth the change.

As an alternative, we could have some documentation that included a code snippet for the user to force this behavior.

@schlessera

This comment has been minimized.

Show comment
Hide comment
@schlessera

schlessera Nov 29, 2017

Member

Maybe keep the current behavior for BC, but add an optional switch to force English?

Member

schlessera commented Nov 29, 2017

Maybe keep the current behavior for BC, but add an optional switch to force English?

@danielbachhuber

This comment has been minimized.

Show comment
Hide comment
@danielbachhuber

danielbachhuber Nov 29, 2017

Member

add an optional switch to force English?

Decisions not options?

Member

danielbachhuber commented Nov 29, 2017

add an optional switch to force English?

Decisions not options?

@danielbachhuber

This comment has been minimized.

Show comment
Hide comment
@danielbachhuber

danielbachhuber Nov 29, 2017

Member

@rabin-io This code snippet works for me:

Given a force-locale.php file:

<?php
WP_CLI::add_wp_hook( 'pre_option_WPLANG', function() {
	return 'en_US';
});

You can force the locale to en_US with:

wp --require=force-locale.php

The nice thing about this approach is that you can easily apply it across multiple WP installs.

I don't think setting the WPLANG constant works if you have the option stored in the database. I haven't tested fully though.

Member

danielbachhuber commented Nov 29, 2017

@rabin-io This code snippet works for me:

Given a force-locale.php file:

<?php
WP_CLI::add_wp_hook( 'pre_option_WPLANG', function() {
	return 'en_US';
});

You can force the locale to en_US with:

wp --require=force-locale.php

The nice thing about this approach is that you can easily apply it across multiple WP installs.

I don't think setting the WPLANG constant works if you have the option stored in the database. I haven't tested fully though.

@rabin-io

This comment has been minimized.

Show comment
Hide comment
@rabin-io

rabin-io Nov 30, 2017

Thanks @danielbachhuber , I did try it, and it seems to work for me.
added globally by entering it to the global wp-cli config file ~/.wp-cli/config.yml

but still I think that for terminal operations the default should be in English, and not using the WP translation strings.

rabin-io commented Nov 30, 2017

Thanks @danielbachhuber , I did try it, and it seems to work for me.
added globally by entering it to the global wp-cli config file ~/.wp-cli/config.yml

but still I think that for terminal operations the default should be in English, and not using the WP translation strings.

@danielbachhuber

This comment has been minimized.

Show comment
Hide comment
@danielbachhuber

danielbachhuber Dec 14, 2017

Member

Handling this with documentation wp-cli/handbook#181

Member

danielbachhuber commented Dec 14, 2017

Handling this with documentation wp-cli/handbook#181

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment