TranslatePress – Translate Multilingual sites - Version 1.8.9

Version Description

  • Fixing search in xStore theme ajax search
  • Fix edge cases of translation misalignment that caused some strings not to be translated and generated some notices
  • Fix some cases of displaying uppercase trp-gettext wrappers
  • Better handling of unsupported languages by automatic translation engine
Download this release

Release Info

Developer madalin.ungureanu
Plugin Icon 128x128 TranslatePress – Translate Multilingual sites
Version 1.8.9
Comparing to
See all releases

Code changes from version 1.8.8 to 1.8.9

assets/css/trp-back-end-style.css CHANGED
@@ -38,6 +38,10 @@ span.select2-container{
38
  box-shadow: none;
39
  }
40
 
 
 
 
 
41
 
42
  /**************************************************/
43
  /* Extra styling for admin notices
38
  box-shadow: none;
39
  }
40
 
41
+ ul.trp-unsupported-languages{
42
+ list-style: inside;
43
+ }
44
+
45
 
46
  /**************************************************/
47
  /* Extra styling for admin notices
class-translate-press.php CHANGED
@@ -57,7 +57,7 @@ class TRP_Translate_Press{
57
  define( 'TRP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
58
  define( 'TRP_PLUGIN_BASE', plugin_basename( __DIR__ . '/index.php' ) );
59
  define( 'TRP_PLUGIN_SLUG', 'translatepress-multilingual' );
60
- define( 'TRP_PLUGIN_VERSION', '1.8.8' );
61
 
62
  wp_cache_add_non_persistent_groups(array('trp'));
63
 
@@ -204,6 +204,7 @@ class TRP_Translate_Press{
204
  $this->loader->add_action( 'admin_menu', $this->machine_translation_tab, 'add_submenu_page' );
205
  $this->loader->add_action( 'admin_init', $this->machine_translation_tab, 'register_setting' );
206
  $this->loader->add_action( 'admin_notices', $this->machine_translation_tab, 'admin_notices' );
 
207
 
208
  //Machine Translation Logger defaults
209
  $this->loader->add_action( 'trp_machine_translation_sanitize_settings', $this->machine_translator_logger, 'sanitize_settings', 10, 1 );
57
  define( 'TRP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
58
  define( 'TRP_PLUGIN_BASE', plugin_basename( __DIR__ . '/index.php' ) );
59
  define( 'TRP_PLUGIN_SLUG', 'translatepress-multilingual' );
60
+ define( 'TRP_PLUGIN_VERSION', '1.8.9' );
61
 
62
  wp_cache_add_non_persistent_groups(array('trp'));
63
 
204
  $this->loader->add_action( 'admin_menu', $this->machine_translation_tab, 'add_submenu_page' );
205
  $this->loader->add_action( 'admin_init', $this->machine_translation_tab, 'register_setting' );
206
  $this->loader->add_action( 'admin_notices', $this->machine_translation_tab, 'admin_notices' );
207
+ $this->loader->add_action( 'trp_machine_translation_extra_settings_bottom', $this->machine_translation_tab, 'display_unsupported_languages' );
208
 
209
  //Machine Translation Logger defaults
210
  $this->loader->add_action( 'trp_machine_translation_sanitize_settings', $this->machine_translator_logger, 'sanitize_settings', 10, 1 );
includes/class-machine-translation-tab.php CHANGED
@@ -130,4 +130,39 @@ class TRP_Machine_Translation_Tab {
130
 
131
  return $engines;
132
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  }
130
 
131
  return $engines;
132
  }
133
+
134
+ public function display_unsupported_languages(){
135
+ $trp = TRP_Translate_Press::get_trp_instance();
136
+ $machine_translator = $trp->get_component( 'machine_translator' );
137
+ $trp_languages = $trp->get_component( 'languages' );
138
+
139
+ if ( 'yes' === $this->settings['trp_machine_translation_settings']['machine-translation'] &&
140
+ !$machine_translator->check_languages_availability($this->settings['translation-languages'])
141
+ ){
142
+
143
+ $language_names = $trp_languages->get_language_names( $this->settings['translation-languages'], 'english_name' );
144
+
145
+ ?>
146
+ <tr id="trp_unsupported_languages">
147
+ <th scope=row><?php esc_html_e( 'Unsupported languages', 'translatepress-multilingual' ); ?></th>
148
+ <td>
149
+ <ul class="trp-unsupported-languages">
150
+ <?php
151
+ foreach ( $this->settings['translation-languages'] as $language_code ) {
152
+ if ( !$machine_translator->check_languages_availability( array( $language_code ) ) ) {
153
+ echo '<li>' . $language_names[$language_code] . '</li>';
154
+ }
155
+ }
156
+ ?>
157
+ </ul>
158
+ <a href="<?php echo esc_url( admin_url( 'admin.php?page=trp_machine_translation&trp_recheck_supported_languages=1&trp_recheck_supported_languages_nonce=' . wp_create_nonce('trp_recheck_supported_languages') ) ); ?>" class="button-secondary"><?php _e( 'Recheck supported languages', 'translatepress-multilingual' ); ?></a>
159
+ <p><i><?php echo sprintf( __( '(last checked on %s)', 'translatepress-multilingual' ), esc_html( $machine_translator->get_last_checked_supported_languages() ) ); ?> </i></p>
160
+ <p class="description">
161
+ <?php echo wp_kses( __( 'The selected automatic translation engine does not provide support for these languages.<br>You can still manually translate pages in these languages using the Translation Editor.', 'translatepress-multilingual' ), array( 'br' => array() ) ); ?>
162
+ </p>
163
+ </td>
164
+ </tr>
165
+ <?php
166
+ }
167
+ }
168
  }
includes/class-machine-translator.php CHANGED
@@ -33,13 +33,61 @@ class TRP_Machine_Translator {
33
  /**
34
  * Whether automatic translation is available.
35
  *
 
36
  * @return bool
37
  */
38
- public function is_available(){
39
- if( !empty( $this->settings['trp_machine_translation_settings']['machine-translation'] ) && $this->settings['trp_machine_translation_settings']['machine-translation'] == 'yes' )
40
- return true;
41
- else
 
 
 
 
 
 
 
 
42
  return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  }
44
 
45
  /**
33
  /**
34
  * Whether automatic translation is available.
35
  *
36
+ * @param array $languages
37
  * @return bool
38
  */
39
+ public function is_available( $languages = array() ){
40
+ if( !empty( $this->settings['trp_machine_translation_settings']['machine-translation'] ) &&
41
+ $this->settings['trp_machine_translation_settings']['machine-translation'] == 'yes'
42
+ ) {
43
+ if ( empty( $languages ) ){
44
+ // can be used to simply know if machine translation is available
45
+ return true;
46
+ }
47
+
48
+ return $this->check_languages_availability($languages);
49
+
50
+ }else {
51
  return false;
52
+ }
53
+ }
54
+
55
+ public function check_languages_availability( $languages, $force_recheck = false ){
56
+ if ( !method_exists( $this, 'get_supported_languages' ) || !method_exists( $this, 'get_engine_specific_language_codes' )){
57
+ return true;
58
+ }
59
+ $force_recheck = ( current_user_can('manage_options') &&
60
+ !empty( $_GET['trp_recheck_supported_languages']) && $_GET['trp_recheck_supported_languages'] === '1' &&
61
+ wp_verify_nonce( $_GET['trp_recheck_supported_languages_nonce'], 'trp_recheck_supported_languages' ) ) ? true : $force_recheck;
62
+ $data = get_option('trp_db_stored_data', array() );
63
+
64
+ // if supported languages are not stored, fetch them and update option
65
+ if ( empty( $data['trp_mt_supported_languages'][$this->settings['trp_machine_translation_settings']['translation-engine']]['languages'] ) || $force_recheck ){
66
+ if ( empty( $data['trp_mt_supported_languages'] ) ) {
67
+ $data['trp_mt_supported_languages'] = array();
68
+ }
69
+ if ( empty( $data['trp_mt_supported_languages'][ $this->settings['trp_machine_translation_settings']['translation-engine'] ] ) ) {
70
+ $data['trp_mt_supported_languages'][ $this->settings['trp_machine_translation_settings']['translation-engine'] ] = array( 'languages' => array() );
71
+ }
72
+
73
+ $data['trp_mt_supported_languages'][$this->settings['trp_machine_translation_settings']['translation-engine']]['languages'] = $this->get_supported_languages();
74
+ $data['trp_mt_supported_languages'][$this->settings['trp_machine_translation_settings']['translation-engine']]['last-checked'] = date("Y-m-d H:i:s" );
75
+ update_option('trp_db_stored_data', $data );
76
+ }
77
+
78
+ $languages_iso_to_check = $this->get_engine_specific_language_codes( $languages );
79
+
80
+ $all_are_available = !array_diff($languages_iso_to_check, $data['trp_mt_supported_languages'][$this->settings['trp_machine_translation_settings']['translation-engine']]['languages']);
81
+
82
+ return apply_filters('trp_mt_available_supported_languages', $all_are_available, $languages, $this->settings );
83
+ }
84
+
85
+ public function get_last_checked_supported_languages(){
86
+ $data = get_option('trp_db_stored_data', array() );
87
+ if ( empty( $data['trp_mt_supported_languages'][$this->settings['trp_machine_translation_settings']['translation-engine']]['last-checked'] ) ){
88
+ $this->check_languages_availability( $this->settings['translation-languages'], true);
89
+ }
90
+ return $data['trp_mt_supported_languages'][$this->settings['trp_machine_translation_settings']['translation-engine']]['last-checked'];
91
  }
92
 
93
  /**
includes/class-plugin-notices.php CHANGED
@@ -432,6 +432,29 @@ class TRP_Trigger_Plugin_Notifications{
432
  $notifications->add_notification($notification_id, $message, 'trp-notice trp-narrow notice notice-info', true, array('translate-press'));
433
  }
434
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
435
  }
436
 
437
  }
432
  $notifications->add_notification($notification_id, $message, 'trp-notice trp-narrow notice notice-info', true, array('translate-press'));
433
  }
434
 
435
+
436
+ /*
437
+ * One or more languages are unsupported by automatic translation.
438
+ */
439
+ $trp = TRP_Translate_Press::get_trp_instance();
440
+ $machine_translator = $trp->get_component( 'machine_translator' );
441
+
442
+ if( apply_filters('trp_mt_available_supported_languages_show_notice', true, $this->settings['translation-languages'], $this->settings ) &&
443
+ 'yes' === $this->settings['trp_machine_translation_settings']['machine-translation'] &&
444
+ !$machine_translator->check_languages_availability($this->settings['translation-languages'])
445
+ ) {
446
+ /* this must be unique */
447
+ $notification_id = 'trp_mt_unsupported_languages';
448
+
449
+ $message = '<p style="margin-top: 16px;padding-right:30px;">';
450
+ $message .= sprintf( __( 'One or more languages are unsupported by the automatic translation provider. Please check the <strong>TranslatePress -> <a href="%s">Automatic Translation</a></strong> page for more information.', 'translatepress-multilingual' ), admin_url( 'admin.php?page=trp_machine_translation#trp_unsupported_languages' ) );
451
+ $message .= '</p>';
452
+ //make sure to use the trp_dismiss_admin_notification arg
453
+ $message .= '<a href="' . add_query_arg(array('trp_dismiss_admin_notification' => $notification_id)) . '" type="button" class="notice-dismiss"><span class="screen-reader-text">' . __('Dismiss this notice.', 'translatepress-multilingual') . '</span></a>';
454
+
455
+ $notifications->add_notification($notification_id, $message, 'trp-notice trp-narrow notice notice-info', true, array('translate-press'));
456
+ }
457
+
458
  }
459
 
460
  }
includes/class-search.php CHANGED
@@ -36,10 +36,13 @@ class TRP_Search extends WP_Query{
36
  global $TRP_LANGUAGE;
37
 
38
  if ( $TRP_LANGUAGE !== $this->settings['default-language'] ) {
39
- if (!is_admin() && $query->is_main_query() && $query->is_search()) {
40
 
41
  // Get the "s" query arg from the initial search
42
  $search_query = get_query_var('s');
 
 
 
43
 
44
  $search_result_ids = $this->get_post_ids_containing_search_term($search_query, $query);
45
 
36
  global $TRP_LANGUAGE;
37
 
38
  if ( $TRP_LANGUAGE !== $this->settings['default-language'] ) {
39
+ if ( ( !is_admin() && $query->is_main_query() && $query->is_search() ) || apply_filters( 'trp_force_search', false ) ) {
40
 
41
  // Get the "s" query arg from the initial search
42
  $search_query = get_query_var('s');
43
+ //in some cases for instance some ajax searches we might need to get it from the query
44
+ if( empty($search_query) && !empty( $query->query['s'] ) )
45
+ $search_query = $query->query['s'];
46
 
47
  $search_result_ids = $this->get_post_ids_containing_search_term($search_query, $query);
48
 
includes/class-translation-manager.php CHANGED
@@ -816,7 +816,7 @@ class TRP_Translation_Manager
816
  }
817
  $machine_translation_codes = $this->trp_languages->get_iso_codes($this->settings['translation-languages']);
818
  /* We assume Gettext strings are in English so don't automatically translate into English */
819
- if ($machine_translation_codes[$TRP_LANGUAGE] != 'en' && $this->machine_translator->is_available()) {
820
  global $trp_gettext_strings_for_machine_translation;
821
  if ($text == $translation) {
822
  foreach ($trp_translated_gettext_texts as $trp_translated_gettext_text) {
@@ -1000,8 +1000,10 @@ class TRP_Translation_Manager
1000
  $this->machine_translator = $trp->get_component('machine_translator');
1001
  }
1002
 
 
 
1003
  // machine translate new strings
1004
- if ($this->machine_translator->is_available()) {
1005
 
1006
  /* Transform associative array into ordered numeric array. We need to keep keys numeric and ordered because $new_strings and $machine_strings depend on it.
1007
  * Array was constructed as associative with db ids as keys to avoid duplication.
@@ -1013,8 +1015,6 @@ class TRP_Translation_Manager
1013
  $new_strings[] = $trp_gettext_string_for_machine_translation['original'];
1014
  }
1015
 
1016
- // Gettext strings are considered by default to be in the English language
1017
- $source_language = apply_filters('trp_gettext_source_language', 'en_US', $TRP_LANGUAGE, $new_strings, $trp_gettext_strings_for_machine_translation);
1018
  if (apply_filters('trp_gettext_allow_machine_translation', true, $source_language, $TRP_LANGUAGE, $new_strings, $trp_gettext_strings_for_machine_translation)) {
1019
  $machine_strings = $this->machine_translator->translate($new_strings, $TRP_LANGUAGE, $source_language);
1020
  } else {
@@ -1048,8 +1048,8 @@ class TRP_Translation_Manager
1048
  {
1049
 
1050
  /* remove trp-gettext wrap */
1051
- $dateformatstring = preg_replace('/#!trpst#trp-gettext (.*?)#!trpen#/', '', $dateformatstring);
1052
- $dateformatstring = preg_replace('/#!trpst#(.?)\/trp-gettext#!trpen#/', '', $dateformatstring);
1053
 
1054
 
1055
  global $wp_locale;
@@ -1159,14 +1159,16 @@ class TRP_Translation_Manager
1159
  static function strip_gettext_tags($string)
1160
  {
1161
  if (is_string($string) && strpos($string, 'data-trpgettextoriginal=') !== false) {
1162
- $string = preg_replace('/ data-trpgettextoriginal=\d+#!trpen#/', '', $string);
1163
- $string = preg_replace('/data-trpgettextoriginal=\d+#!trpen#/', '', $string);//sometimes it can be without space
1164
- $string = str_replace('#!trpst#trp-gettext', '', $string);
1165
- $string = str_replace('#!trpst#/trp-gettext', '', $string);
1166
- $string = str_replace('#!trpst#\/trp-gettext', '', $string);
1167
- $string = str_replace('#!trpen#', '', $string);
 
1168
  }
1169
 
 
1170
  return $string;
1171
  }
1172
 
816
  }
817
  $machine_translation_codes = $this->trp_languages->get_iso_codes($this->settings['translation-languages']);
818
  /* We assume Gettext strings are in English so don't automatically translate into English */
819
+ if ($machine_translation_codes[$TRP_LANGUAGE] != 'en' && $this->machine_translator->is_available(array($TRP_LANGUAGE))) {
820
  global $trp_gettext_strings_for_machine_translation;
821
  if ($text == $translation) {
822
  foreach ($trp_translated_gettext_texts as $trp_translated_gettext_text) {
1000
  $this->machine_translator = $trp->get_component('machine_translator');
1001
  }
1002
 
1003
+ // Gettext strings are considered by default to be in the English language
1004
+ $source_language = apply_filters('trp_gettext_source_language', 'en_US', $TRP_LANGUAGE, array(), $trp_gettext_strings_for_machine_translation);
1005
  // machine translate new strings
1006
+ if ($this->machine_translator->is_available(array($source_language, $TRP_LANGUAGE))) {
1007
 
1008
  /* Transform associative array into ordered numeric array. We need to keep keys numeric and ordered because $new_strings and $machine_strings depend on it.
1009
  * Array was constructed as associative with db ids as keys to avoid duplication.
1015
  $new_strings[] = $trp_gettext_string_for_machine_translation['original'];
1016
  }
1017
 
 
 
1018
  if (apply_filters('trp_gettext_allow_machine_translation', true, $source_language, $TRP_LANGUAGE, $new_strings, $trp_gettext_strings_for_machine_translation)) {
1019
  $machine_strings = $this->machine_translator->translate($new_strings, $TRP_LANGUAGE, $source_language);
1020
  } else {
1048
  {
1049
 
1050
  /* remove trp-gettext wrap */
1051
+ $dateformatstring = preg_replace('/#!trpst#trp-gettext (.*?)#!trpen#/i', '', $dateformatstring);
1052
+ $dateformatstring = preg_replace('/#!trpst#(.?)\/trp-gettext#!trpen#/i', '', $dateformatstring);
1053
 
1054
 
1055
  global $wp_locale;
1159
  static function strip_gettext_tags($string)
1160
  {
1161
  if (is_string($string) && strpos($string, 'data-trpgettextoriginal=') !== false) {
1162
+ // final 'i' is for case insensitive. same for the 'i' in str_ireplace
1163
+ $string = preg_replace('/ data-trpgettextoriginal=\d+#!trpen#/i', '', $string);
1164
+ $string = preg_replace('/data-trpgettextoriginal=\d+#!trpen#/i', '', $string);//sometimes it can be without space
1165
+ $string = str_ireplace('#!trpst#trp-gettext', '', $string);
1166
+ $string = str_ireplace('#!trpst#/trp-gettext', '', $string);
1167
+ $string = str_ireplace('#!trpst#\/trp-gettext', '', $string);
1168
+ $string = str_ireplace('#!trpen#', '', $string);
1169
  }
1170
 
1171
+
1172
  return $string;
1173
  }
1174
 
includes/class-translation-render.php CHANGED
@@ -348,10 +348,8 @@ class TRP_Translation_Render{
348
  global $trp_editor_notices;
349
 
350
  /* replace our special tags so we have valid html */
351
- $output = str_replace('#!trpst#', '<', $output);
352
- $output = str_replace('#!TRPST#', '<', $output);
353
- $output = str_replace('#!trpen#', '>', $output);
354
- $output = str_replace('#!TRPEN#', '>', $output);
355
 
356
  $output = apply_filters('trp_before_translate_content', $output);
357
 
@@ -651,6 +649,7 @@ class TRP_Translation_Render{
651
  && $parent->tag!="script"
652
  && $parent->tag!="style"
653
  && $parent->tag != 'title'
 
654
  && strpos($outertext,'[vc_') === false
655
  && !$this->trp_is_numeric($trimmed_string)
656
  && !preg_match('/^\d+%$/',$trimmed_string)
@@ -659,16 +658,8 @@ class TRP_Translation_Render{
659
  {
660
  // $translateable_strings array needs to be in sync in $nodes array
661
  $string_count = array_push( $translateable_strings, $trimmed_string );
662
- if( $parent->tag == 'button') {
663
- array_push($nodes, array('node' => $row, 'type' => 'button'));
664
- }
665
- else {
666
- if ( $parent->tag == 'option' ) {
667
- array_push( $nodes, array( 'node' => $row, 'type' => 'option' ) );
668
- } elseif ( $parent->tag != 'textarea' ) {//explicitly exclude textarea strings
669
- array_push( $nodes, array( 'node' => $row, 'type' => 'text' ) );
670
- }
671
- }
672
 
673
  //add data-trp-post-id attribute if needed
674
  $nodes = $this->maybe_add_post_id_in_node( $nodes, $row, $string_count );
@@ -992,21 +983,21 @@ class TRP_Translation_Render{
992
  * @return string|string[]|null
993
  */
994
  function remove_trp_html_tags( $string ){
995
- $string = preg_replace( '/(<|&lt;)trp-gettext (.*?)(>|&gt;)/', '', $string );
996
- $string = preg_replace( '/(<|&lt;)(\\\\)*\/trp-gettext(>|&gt;)/', '', $string );
997
 
998
  // In case we have a gettext string which was run through rawurlencode(). See more details on iss6563
999
- $string = preg_replace( '/%23%21trpst%23trp-gettext(.*?)%23%21trpen%23/', '', $string );
1000
- $string = preg_replace( '/%23%21trpst%23%2Ftrp-gettext%23%21trpen%23/', '', $string );
1001
 
1002
  if (!isset($_REQUEST['trp-edit-translation']) || $_REQUEST['trp-edit-translation'] != 'preview') {
1003
- $string = preg_replace('/(<|&lt;)trp-wrap (.*?)(>|&gt;)/', '', $string);
1004
- $string = preg_replace('/(<|&lt;)(\\\\)*\/trp-wrap(>|&gt;)/', '', $string);
1005
  }
1006
 
1007
  //remove post containers before outputting
1008
- $string = preg_replace( '/(<|&lt;)trp-post-container (.*?)(>|&gt;)/', '', $string );
1009
- $string = preg_replace( '/(<|&lt;)(\\\\)*\/trp-post-container(>|&gt;)/', '', $string );
1010
 
1011
  return $string;
1012
  }
@@ -1247,7 +1238,7 @@ class TRP_Translation_Render{
1247
  }
1248
 
1249
  $translated_strings = array();
1250
- $machine_translation_available = $this->machine_translator->is_available();
1251
 
1252
  if ( ! $this->trp_query ) {
1253
  $trp = TRP_Translate_Press::get_trp_instance();
348
  global $trp_editor_notices;
349
 
350
  /* replace our special tags so we have valid html */
351
+ $output = str_ireplace('#!trpst#', '<', $output);
352
+ $output = str_ireplace('#!trpen#', '>', $output);
 
 
353
 
354
  $output = apply_filters('trp_before_translate_content', $output);
355
 
649
  && $parent->tag!="script"
650
  && $parent->tag!="style"
651
  && $parent->tag != 'title'
652
+ && $parent->tag != 'textarea' //explicitly exclude textarea strings
653
  && strpos($outertext,'[vc_') === false
654
  && !$this->trp_is_numeric($trimmed_string)
655
  && !preg_match('/^\d+%$/',$trimmed_string)
658
  {
659
  // $translateable_strings array needs to be in sync in $nodes array
660
  $string_count = array_push( $translateable_strings, $trimmed_string );
661
+ $node_type_to_push = ( in_array( $parent->tag, array( 'button', 'option' ) ) ) ? $parent->tag : 'text';
662
+ array_push($nodes, array('node' => $row, 'type' => $node_type_to_push ));
 
 
 
 
 
 
 
 
663
 
664
  //add data-trp-post-id attribute if needed
665
  $nodes = $this->maybe_add_post_id_in_node( $nodes, $row, $string_count );
983
  * @return string|string[]|null
984
  */
985
  function remove_trp_html_tags( $string ){
986
+ $string = preg_replace( '/(<|&lt;)trp-gettext (.*?)(>|&gt;)/i', '', $string );
987
+ $string = preg_replace( '/(<|&lt;)(\\\\)*\/trp-gettext(>|&gt;)/i', '', $string );
988
 
989
  // In case we have a gettext string which was run through rawurlencode(). See more details on iss6563
990
+ $string = preg_replace( '/%23%21trpst%23trp-gettext(.*?)%23%21trpen%23/i', '', $string );
991
+ $string = preg_replace( '/%23%21trpst%23%2Ftrp-gettext%23%21trpen%23/i', '', $string );
992
 
993
  if (!isset($_REQUEST['trp-edit-translation']) || $_REQUEST['trp-edit-translation'] != 'preview') {
994
+ $string = preg_replace('/(<|&lt;)trp-wrap (.*?)(>|&gt;)/i', '', $string);
995
+ $string = preg_replace('/(<|&lt;)(\\\\)*\/trp-wrap(>|&gt;)/i', '', $string);
996
  }
997
 
998
  //remove post containers before outputting
999
+ $string = preg_replace( '/(<|&lt;)trp-post-container (.*?)(>|&gt;)/i', '', $string );
1000
+ $string = preg_replace( '/(<|&lt;)(\\\\)*\/trp-post-container(>|&gt;)/i', '', $string );
1001
 
1002
  return $string;
1003
  }
1238
  }
1239
 
1240
  $translated_strings = array();
1241
+ $machine_translation_available = $this->machine_translator->is_available( array( $this->settings['default-language'], $language_code ));
1242
 
1243
  if ( ! $this->trp_query ) {
1244
  $trp = TRP_Translate_Press::get_trp_instance();
includes/compatibility-functions.php CHANGED
@@ -1280,3 +1280,15 @@ function trp_woo_wc_api_handle_api_request( ){
1280
  add_filter( 'trp_skip_gettext_processing', '__return_true' );
1281
  add_filter( 'trp_stop_translating_page', '__return_true' );
1282
  }
 
 
 
 
 
 
 
 
 
 
 
 
1280
  add_filter( 'trp_skip_gettext_processing', '__return_true' );
1281
  add_filter( 'trp_stop_translating_page', '__return_true' );
1282
  }
1283
+
1284
+ /**
1285
+ * Add here compatibility with search plugins
1286
+ */
1287
+ add_filter('trp_force_search', 'trp_force_search' );
1288
+ function trp_force_search( $bool ){
1289
+ //force search in xstore theme ajax search
1290
+ if( isset( $_REQUEST['action'] ) && $_REQUEST['action'] === 'etheme_ajax_search' )
1291
+ $bool = true;
1292
+
1293
+ return $bool;
1294
+ }
includes/functions.php CHANGED
@@ -17,7 +17,7 @@ function trp_the_language_switcher(){
17
  * @return mixed|string|void
18
  */
19
  function trp_safe_json_encode($value){
20
- if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
21
  $encoded = json_encode($value, JSON_PRETTY_PRINT);
22
  } else {
23
  $encoded = json_encode($value);
17
  * @return mixed|string|void
18
  */
19
  function trp_safe_json_encode($value){
20
+ if (version_compare(PHP_VERSION, '5.4.0') >= 0 && apply_filters('trp_safe_json_encode_pretty_print', true )) {
21
  $encoded = json_encode($value, JSON_PRETTY_PRINT);
22
  } else {
23
  $encoded = json_encode($value);
includes/google-translate/class-google-translate-v2-machine-translator.php CHANGED
@@ -123,4 +123,32 @@ class TRP_Google_Translate_V2_Machine_Translator extends TRP_Machine_Translator
123
  return isset( $this->settings['trp_machine_translation_settings'], $this->settings['trp_machine_translation_settings']['google-translate-key'] ) ? $this->settings['trp_machine_translation_settings']['google-translate-key'] : false;
124
 
125
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  }
123
  return isset( $this->settings['trp_machine_translation_settings'], $this->settings['trp_machine_translation_settings']['google-translate-key'] ) ? $this->settings['trp_machine_translation_settings']['google-translate-key'] : false;
124
 
125
  }
126
+
127
+
128
+ public function get_supported_languages(){
129
+ $response = wp_remote_post( "https://www.googleapis.com/language/translate/v2/languages", array(
130
+ 'headers' => array(
131
+ 'timeout' => 45,
132
+ 'Referer' => $this->get_referer()
133
+ ),
134
+ 'body' => 'key='.$this->settings['trp_machine_translation_settings']['google-translate-key'],
135
+ )
136
+ );
137
+
138
+ if ( is_array( $response ) && ! is_wp_error( $response ) && isset( $response['response'] ) &&
139
+ isset( $response['response']['code']) && $response['response']['code'] == 200 ) {
140
+ $data = json_decode( $response['body'] );
141
+ $supported_languages = array();
142
+ foreach( $data->data->languages as $language ){
143
+ $supported_languages[] = $language->language;
144
+ }
145
+ return $supported_languages;
146
+ }else{
147
+ return array();
148
+ }
149
+ }
150
+
151
+ public function get_engine_specific_language_codes($languages){
152
+ return $this->trp_languages->get_iso_codes($languages);
153
+ }
154
  }
index.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: TranslatePress - Multilingual
4
  Plugin URI: https://translatepress.com/
5
  Description: Experience a better way of translating your WordPress site using a visual front-end translation editor, with full support for WooCommerce and site builders.
6
- Version: 1.8.8
7
  Author: Cozmoslabs, Razvan Mocanu, Madalin Ungureanu, Cristophor Hurduban
8
  Author URI: https://cozmoslabs.com/
9
  Text Domain: translatepress-multilingual
3
  Plugin Name: TranslatePress - Multilingual
4
  Plugin URI: https://translatepress.com/
5
  Description: Experience a better way of translating your WordPress site using a visual front-end translation editor, with full support for WooCommerce and site builders.
6
+ Version: 1.8.9
7
  Author: Cozmoslabs, Razvan Mocanu, Madalin Ungureanu, Cristophor Hurduban
8
  Author URI: https://cozmoslabs.com/
9
  Text Domain: translatepress-multilingual
languages/translatepress-multilingual.catalog.php CHANGED
@@ -65,6 +65,10 @@
65
  <?php __("Could not install. Try again from <a href=\"%s\" >Plugins Dashboard.</a>", "translatepress-multilingual"); ?>
66
  <?php __("Automatic Translation", "translatepress-multilingual"); ?>
67
  <?php __("DeepL", "translatepress-multilingual"); ?>
 
 
 
 
68
  <?php __("You are not using a permalink structure! Please <a href=\"%s\">enable</a> one or install our <a href=\"%s\">\"Language by GET parameter\"</a> addon, so that TranslatePress can function properly.", "translatepress-multilingual"); ?>
69
  <?php __("Your <strong>TranslatePress</strong> license will expire on %1$s. Please %2$sRenew Your Licence%3$s to continue receiving access to product downloads, automatic updates and support.", "translatepress-multilingual"); ?>
70
  <?php __("Something went wrong, please try again.", "translatepress-multilingual"); ?>
@@ -72,6 +76,7 @@
72
  <?php __("Your <strong>TranslatePress</strong> serial number is invalid or missing. <br/>Please %1$sregister your copy%2$s to receive access to automatic updates and support. Need a license key? %3$sPurchase one now%4$s", "translatepress-multilingual"); ?>
73
  <?php __("NEW: Display different images based on language. Find out <a href=\"https://translatepress.com/docs/image-translation/\" >how to translate images, sliders and more</a> from the TranslatePress editor.", "translatepress-multilingual"); ?>
74
  <?php __("The daily quota for machine translation characters exceeded. Please check the <strong>TranslatePress -> <a href=\"%s\">Automatic Translation</a></strong> page for more information.", "translatepress-multilingual"); ?>
 
75
  <?php __("Full Language Names", "translatepress-multilingual"); ?>
76
  <?php __("Short Language Names", "translatepress-multilingual"); ?>
77
  <?php __("Flags with Full Language Names", "translatepress-multilingual"); ?>
65
  <?php __("Could not install. Try again from <a href=\"%s\" >Plugins Dashboard.</a>", "translatepress-multilingual"); ?>
66
  <?php __("Automatic Translation", "translatepress-multilingual"); ?>
67
  <?php __("DeepL", "translatepress-multilingual"); ?>
68
+ <?php __("Unsupported languages", "translatepress-multilingual"); ?>
69
+ <?php __("Recheck supported languages", "translatepress-multilingual"); ?>
70
+ <?php __("(last checked on %s)", "translatepress-multilingual"); ?>
71
+ <?php __("The selected automatic translation engine does not provide support for these languages.<br>You can still manually translate pages in these languages using the Translation Editor.", "translatepress-multilingual"); ?>
72
  <?php __("You are not using a permalink structure! Please <a href=\"%s\">enable</a> one or install our <a href=\"%s\">\"Language by GET parameter\"</a> addon, so that TranslatePress can function properly.", "translatepress-multilingual"); ?>
73
  <?php __("Your <strong>TranslatePress</strong> license will expire on %1$s. Please %2$sRenew Your Licence%3$s to continue receiving access to product downloads, automatic updates and support.", "translatepress-multilingual"); ?>
74
  <?php __("Something went wrong, please try again.", "translatepress-multilingual"); ?>
76
  <?php __("Your <strong>TranslatePress</strong> serial number is invalid or missing. <br/>Please %1$sregister your copy%2$s to receive access to automatic updates and support. Need a license key? %3$sPurchase one now%4$s", "translatepress-multilingual"); ?>
77
  <?php __("NEW: Display different images based on language. Find out <a href=\"https://translatepress.com/docs/image-translation/\" >how to translate images, sliders and more</a> from the TranslatePress editor.", "translatepress-multilingual"); ?>
78
  <?php __("The daily quota for machine translation characters exceeded. Please check the <strong>TranslatePress -> <a href=\"%s\">Automatic Translation</a></strong> page for more information.", "translatepress-multilingual"); ?>
79
+ <?php __("One or more languages are unsupported by the automatic translation provider. Please check the <strong>TranslatePress -> <a href=\"%s\">Automatic Translation</a></strong> page for more information.", "translatepress-multilingual"); ?>
80
  <?php __("Full Language Names", "translatepress-multilingual"); ?>
81
  <?php __("Short Language Names", "translatepress-multilingual"); ?>
82
  <?php __("Flags with Full Language Names", "translatepress-multilingual"); ?>
languages/translatepress-multilingual.pot CHANGED
@@ -189,7 +189,7 @@ msgstr ""
189
  msgid "Automatic translation has been disabled."
190
  msgstr ""
191
 
192
- #: includes/class-error-manager.php:129, includes/class-plugin-notices.php:340, includes/class-plugin-notices.php:391, includes/class-plugin-notices.php:372, includes/class-plugin-notices.php:405, includes/class-plugin-notices.php:430
193
  msgid "Dismiss this notice."
194
  msgstr ""
195
 
@@ -277,6 +277,22 @@ msgstr ""
277
  msgid "DeepL"
278
  msgstr ""
279
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280
  #: includes/class-plugin-notices.php:338
281
  msgid "You are not using a permalink structure! Please <a href=\"%s\">enable</a> one or install our <a href=\"%s\">\"Language by GET parameter\"</a> addon, so that TranslatePress can function properly."
282
  msgstr ""
@@ -305,6 +321,10 @@ msgstr ""
305
  msgid "The daily quota for machine translation characters exceeded. Please check the <strong>TranslatePress -> <a href=\"%s\">Automatic Translation</a></strong> page for more information."
306
  msgstr ""
307
 
 
 
 
 
308
  #: includes/class-settings.php:26
309
  msgid "Full Language Names"
310
  msgstr ""
@@ -661,11 +681,11 @@ msgstr ""
661
  msgid "Translate Page"
662
  msgstr ""
663
 
664
- #: includes/class-translation-manager.php:1203
665
  msgid "Security check"
666
  msgstr ""
667
 
668
- #: includes/class-translation-manager.php:1277
669
  msgid "<strong>Warning:</strong> Some strings have possibly incorrectly encoded characters. This may result in breaking the queries, rendering the page untranslated in live mode. Consider revising the following strings or their method of outputting."
670
  msgstr ""
671
 
189
  msgid "Automatic translation has been disabled."
190
  msgstr ""
191
 
192
+ #: includes/class-error-manager.php:129, includes/class-plugin-notices.php:340, includes/class-plugin-notices.php:391, includes/class-plugin-notices.php:372, includes/class-plugin-notices.php:405, includes/class-plugin-notices.php:430, includes/class-plugin-notices.php:453
193
  msgid "Dismiss this notice."
194
  msgstr ""
195
 
277
  msgid "DeepL"
278
  msgstr ""
279
 
280
+ #: includes/class-machine-translation-tab.php:147
281
+ msgid "Unsupported languages"
282
+ msgstr ""
283
+
284
+ #: includes/class-machine-translation-tab.php:158
285
+ msgid "Recheck supported languages"
286
+ msgstr ""
287
+
288
+ #: includes/class-machine-translation-tab.php:159
289
+ msgid "(last checked on %s)"
290
+ msgstr ""
291
+
292
+ #: includes/class-machine-translation-tab.php:161
293
+ msgid "The selected automatic translation engine does not provide support for these languages.<br>You can still manually translate pages in these languages using the Translation Editor."
294
+ msgstr ""
295
+
296
  #: includes/class-plugin-notices.php:338
297
  msgid "You are not using a permalink structure! Please <a href=\"%s\">enable</a> one or install our <a href=\"%s\">\"Language by GET parameter\"</a> addon, so that TranslatePress can function properly."
298
  msgstr ""
321
  msgid "The daily quota for machine translation characters exceeded. Please check the <strong>TranslatePress -> <a href=\"%s\">Automatic Translation</a></strong> page for more information."
322
  msgstr ""
323
 
324
+ #: includes/class-plugin-notices.php:450
325
+ msgid "One or more languages are unsupported by the automatic translation provider. Please check the <strong>TranslatePress -> <a href=\"%s\">Automatic Translation</a></strong> page for more information."
326
+ msgstr ""
327
+
328
  #: includes/class-settings.php:26
329
  msgid "Full Language Names"
330
  msgstr ""
681
  msgid "Translate Page"
682
  msgstr ""
683
 
684
+ #: includes/class-translation-manager.php:1205
685
  msgid "Security check"
686
  msgstr ""
687
 
688
+ #: includes/class-translation-manager.php:1279
689
  msgid "<strong>Warning:</strong> Some strings have possibly incorrectly encoded characters. This may result in breaking the queries, rendering the page untranslated in live mode. Consider revising the following strings or their method of outputting."
690
  msgstr ""
691
 
readme.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: cozmoslabs, razvan.mo, madalin.ungureanu, sareiodata, cristophor
3
  Donate link: https://www.translatepress.com/
4
  Tags: translate, translation, multilingual, automatic translation, bilingual, front-end translation, google translate, language
5
  Requires at least: 3.1.0
6
- Tested up to: 5.5.3
7
  Requires PHP: 5.6.20
8
- Stable tag: 1.8.8
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -138,6 +138,12 @@ For more information please check out our [documentation](https://translatepress
138
 
139
 
140
  == Changelog ==
 
 
 
 
 
 
141
  = 1.8.8 =
142
  * Improved compatibility with Oxygen builder.
143
  * Fixed a issue with pagination on blog page displaying page 0
3
  Donate link: https://www.translatepress.com/
4
  Tags: translate, translation, multilingual, automatic translation, bilingual, front-end translation, google translate, language
5
  Requires at least: 3.1.0
6
+ Tested up to: 5.6
7
  Requires PHP: 5.6.20
8
+ Stable tag: 1.8.9
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
138
 
139
 
140
  == Changelog ==
141
+ = 1.8.9 =
142
+ * Fixing search in xStore theme ajax search
143
+ * Fix edge cases of translation misalignment that caused some strings not to be translated and generated some notices
144
+ * Fix some cases of displaying uppercase trp-gettext wrappers
145
+ * Better handling of unsupported languages by automatic translation engine
146
+
147
  = 1.8.8 =
148
  * Improved compatibility with Oxygen builder.
149
  * Fixed a issue with pagination on blog page displaying page 0