From 125cc90e9aa68da47e3df16ffaf9d77bff40fac0 Mon Sep 17 00:00:00 2001 From: Jeremy Herve Date: Mon, 19 Dec 2016 12:51:28 +0100 Subject: [PATCH] Follow Widget: load translation files using wpcom language codes. Related: #2698 The widget previously used the site's language code to populate the `data-lang` parameter. that parameter is used to grab language files from WordPress.com, and should consequently use a language code that's available on WordPress.com. We consequently use the data available in locales.php to use the `slug` language code instead of `wp_locale` for each language. --- modules/widgets/follow-button.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/modules/widgets/follow-button.php b/modules/widgets/follow-button.php index 54cb5f187d55b..82b7a1c74afd2 100644 --- a/modules/widgets/follow-button.php +++ b/modules/widgets/follow-button.php @@ -26,6 +26,21 @@ public function widget( $args, $instance ) { $attributes = array(); $instance = wp_parse_args( (array) $instance, array( 'show_name' => 1, 'show_count' => 0 ) ); + $wpcom_locale = get_locale(); + + if ( ! class_exists( 'GP_Locales' ) ) { + if ( defined( 'JETPACK__GLOTPRESS_LOCALES_PATH' ) && file_exists( JETPACK__GLOTPRESS_LOCALES_PATH ) ) { + require JETPACK__GLOTPRESS_LOCALES_PATH; + } + } + + if ( class_exists( 'GP_Locales' ) ) { + $wpcom_locale_object = GP_Locales::by_field( 'wp_locale', get_locale() ); + if ( $wpcom_locale_object instanceof GP_Locale ) { + $wpcom_locale = $wpcom_locale_object->slug; + } + } + if ( empty( $instance['show_name'] ) ) { $attributes[] = 'data-show-blog-name="false"'; } @@ -41,7 +56,7 @@ public function widget( $args, $instance ) { class="wordpress-follow-button" href="" data-blog="" - data-lang="" + data-lang="" >