Skip to content

Commit 46ec820

Browse files
Hewdereksmart
Hew
authored andcommitted
Likes: fix broken localization of strings Localization has been broken
Merge commit '95dc9cd'
2 parents a540533 + 95dc9cd commit 46ec820

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

modules/likes.php

+21-3
Original file line numberDiff line numberDiff line change
@@ -823,13 +823,31 @@ function likes_master() {
823823
if ( is_ssl() )
824824
$protocol = 'https';
825825

826-
$locale = ( '' == get_locale() || 'en' == get_locale() ) ? '' : '&lang=' . strtolower( substr( get_locale(), 0, 2 ) );
826+
if ( version_compare( $GLOBALS['wp_version'], '3.8-alpha', '>=' ) ) {
827+
add_filter( 'mp6_enabled', '__return_true', 97 );
828+
}
829+
830+
$_locale = get_locale();
831+
832+
// We have to account for WP.org vs WP.com locale divergence
833+
if ( $this->in_jetpack ) {
834+
if ( ! defined( 'JETPACK__GLOTPRESS_LOCALES_PATH' ) || ! file_exists( JETPACK__GLOTPRESS_LOCALES_PATH ) ) {
835+
return false;
836+
}
837+
838+
require_once JETPACK__GLOTPRESS_LOCALES_PATH;
839+
840+
$gp_locale = GP_Locales::by_field( 'wp_locale', $_locale );
841+
$_locale = isset( $gp_locale->slug ) ? $gp_locale->slug : '';
842+
}
843+
844+
$likes_locale = ( '' == $_locale || 'en' == $_locale ) ? '' : '&lang=' . strtolower( $_locale );
827845

828846
// @todo: Remove this opt-out filter in the future
829847
if ( apply_filters( 'wpl_sharing_2014_1', true ) ) {
830-
$src = sprintf( '%1$s://widgets.wp.com/likes/master.html?ver=%2$s#ver=%2$s%3$s&mp6=%4$d', $protocol, $this->version, $locale, apply_filters( 'mp6_enabled', 0 ) );
848+
$src = sprintf( '%1$s://widgets.wp.com/likes/master.html?ver=%2$s#ver=%2$s%3$s&mp6=%4$d', $protocol, $this->version, $likes_locale, apply_filters( 'mp6_enabled', 0 ) );
831849
} else {
832-
$src = sprintf( '%1$s://widgets.wp.com/likes/master-legacy.html?ver=%2$s#ver=%2$s%3$s&mp6=%4$d', $protocol, $this->version, $locale, apply_filters( 'mp6_enabled', 0 ) );
850+
$src = sprintf( '%1$s://widgets.wp.com/likes/master-legacy.html?ver=%2$s#ver=%2$s%3$s&mp6=%4$d', $protocol, $this->version, $likes_locale, apply_filters( 'mp6_enabled', 0 ) );
833851
}
834852

835853
$likersText = wp_kses( __( '<span>%d</span> bloggers like this:', 'jetpack' ), array( 'span' => array() ) );

0 commit comments

Comments
 (0)