Skip to content
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

Fix i18n functions #516

Merged
merged 5 commits into from
Apr 19, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions class-tgm-plugin-activation.php
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ public function init() {
'tgmpa'
),
'return' => __( 'Return to Required Plugins Installer', 'tgmpa' ),
'dashboard' => __( 'Return to the dashboard', 'tgmpa' ),
'dashboard' => __( 'Return to the Dashboard', 'tgmpa' ),
'plugin_activated' => __( 'Plugin activated successfully.', 'tgmpa' ),
'activated_successfully' => __( 'The following plugin was activated successfully:', 'tgmpa' ),
'plugin_already_active' => __( 'No action taken. Plugin %1$s was already active.', 'tgmpa' ),
Expand Down Expand Up @@ -1918,7 +1918,13 @@ public function force_deactivation() {
*/
public function show_tgmpa_version() {
echo '<p style="float: right; padding: 0em 1.5em 0.5em 0;"><strong><small>',
esc_html( sprintf( _x( 'TGMPA v%s', '%s = version number', 'tgmpa' ), self::TGMPA_VERSION ) ),
esc_html(
sprintf(
/* translators: %s: version number */
__( 'TGMPA v%s', 'tgmpa' ),
self::TGMPA_VERSION
)
),
'</small></strong></p>';
}

Expand Down Expand Up @@ -2272,7 +2278,8 @@ protected function get_plugin_status_text( $slug ) {
}

return sprintf(
_x( '%1$s, %2$s', '%1$s = install status, %2$s = update status', 'tgmpa' ),
/* translators: %1$s: install status, %2$s: update status */
_x( '%1$s, %2$s', 'Install/Update Status', 'tgmpa' ),
$install_status,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this 'string' is so generic, should it not have a translators comment and a context through _x ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jrfnl,

The context is used to describe the entire string, translators comment are used to describe specific placeholders like %s, %1$s, %2$s and others.

Translators comment location

In this case, translators comment are needed because we have two placeholders in this string.

As for the context, I'm not sure. We can set "Install/Update Status" as a context, but It's not providing more information than the translator comment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, I'd prefer to have both the translators comment and the context. The TGMPA library is included in themes as well as plugins and in the case of wp.org hosted themes, the text-domain is replaced by the theme text-domain.
If, for whatever reason, the theme would have the same generic string in use, things could become very confusing for translators.
For the other strings, I'd think that to be far less likely.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a very good point. I agree with you.

$update_status
);
Expand Down Expand Up @@ -2459,7 +2466,7 @@ public function column_version( $item ) {
* @since 2.2.0
*/
public function no_items() {
printf( wp_kses_post( __( 'No plugins to install, update or activate. <a href="%1$s">Return to the Dashboard</a>', 'tgmpa' ) ), esc_url( self_admin_url() ) );
echo esc_html__( 'No plugins to install, update or activate.', 'tgmpa' ) . ' <a href="' . esc_url( self_admin_url() ) . '"> ' . esc_html__( 'Return to the Dashboard', 'tgmpa' ) . '</a>';
echo '<style type="text/css">#adminmenu .wp-submenu li.current { display: none !important; }</style>';
}

Expand Down Expand Up @@ -2528,16 +2535,19 @@ protected function get_row_actions( $item ) {

// Display the 'Install' action link if the plugin is not yet available.
if ( ! $this->tgmpa->is_plugin_installed( $item['slug'] ) ) {
$actions['install'] = _x( 'Install %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' );
/* translators: %s: plugin name in screen reader markup */
$actions['install'] = __( 'Install %s', 'tgmpa' );
} else {
// Display the 'Update' action link if an update is available and WP complies with plugin minimum.
if ( false !== $this->tgmpa->does_plugin_have_update( $item['slug'] ) && $this->tgmpa->can_plugin_update( $item['slug'] ) ) {
$actions['update'] = _x( 'Update %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' );
/* translators: %s: plugin name in screen reader markup */
$actions['update'] = __( 'Update %s', 'tgmpa' );
}

// Display the 'Activate' action link, but only if the plugin meets the minimum version.
if ( $this->tgmpa->can_plugin_activate( $item['slug'] ) ) {
$actions['activate'] = _x( 'Activate %2$s', '%2$s = plugin name in screen reader markup', 'tgmpa' );
/* translators: %s: plugin name in screen reader markup */
$actions['activate'] = __( 'Activate %s', 'tgmpa' );
}
}

Expand Down