TranslatePress – Translate Multilingual sites - Version 1.6.0

Version Description

  • Gettext is no longer processed in REST API requests made from admin referer.
  • Don't update gettext machine translation with empty translation.
  • Fixed machine translation codes not being set on first save settings
  • Solved backwards compatibility with Deepl Add-on version 1.0.0
  • We now don't translate gettext into english.
  • Fix: make sure we are not sending gettext non-unique array strings to Automatic Translation
  • Fix: Add default translation engine if not available.
  • Fix: hide Test API key button when machine translation is disabled or when there's not API key saved.
Download this release

Release Info

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

Code changes from version 1.5.9 to 1.6.0

assets/js/trp-back-end-script.js CHANGED
@@ -216,6 +216,8 @@ jQuery( function() {
216
  var deeplUpsell = TRP_Field_Toggler();
217
  deeplUpsell.init('.trp-translation-engine', '#trp-upsell-deepl', 'deepl_upsell' );
218
 
 
 
219
  // Used for the main machine translation toggle to show/hide all options below it
220
  function TRP_show_hide_machine_translation_options(){
221
  if( jQuery( '#trp-machine-translation-enabled' ).val() != 'yes' )
@@ -231,8 +233,10 @@ jQuery( function() {
231
  function TRP_hide_test_api_key(){
232
  if( jQuery( '.trp-translation-engine:checked' ).val() == 'deepl_upsell' )
233
  jQuery( '#trp-test-api-key' ).hide()
234
- else
235
- jQuery( '#trp-test-api-key' ).show()
 
 
236
  }
237
 
238
  TRP_show_hide_machine_translation_options()
216
  var deeplUpsell = TRP_Field_Toggler();
217
  deeplUpsell.init('.trp-translation-engine', '#trp-upsell-deepl', 'deepl_upsell' );
218
 
219
+ jQuery(document).trigger( 'trpInitFieldToggler' );
220
+
221
  // Used for the main machine translation toggle to show/hide all options below it
222
  function TRP_show_hide_machine_translation_options(){
223
  if( jQuery( '#trp-machine-translation-enabled' ).val() != 'yes' )
233
  function TRP_hide_test_api_key(){
234
  if( jQuery( '.trp-translation-engine:checked' ).val() == 'deepl_upsell' )
235
  jQuery( '#trp-test-api-key' ).hide()
236
+ else {
237
+ if( jQuery('#trp-machine-translation-enabled').val() != 'no' )
238
+ jQuery( '#trp-test-api-key' ).show()
239
+ }
240
  }
241
 
242
  TRP_show_hide_machine_translation_options()
class-translate-press.php CHANGED
@@ -25,6 +25,7 @@ class TRP_Translate_Press{
25
  protected $license_page;
26
  protected $advanced_tab;
27
  protected $translation_memory;
 
28
 
29
  public $active_pro_addons = array();
30
  public static $translate_press = null;
@@ -50,7 +51,7 @@ class TRP_Translate_Press{
50
  define( 'TRP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
51
  define( 'TRP_PLUGIN_BASE', plugin_basename( __DIR__ . '/index.php' ) );
52
  define( 'TRP_PLUGIN_SLUG', 'translatepress-multilingual' );
53
- define( 'TRP_PLUGIN_VERSION', '1.5.9' );
54
 
55
  wp_cache_add_non_persistent_groups(array('trp'));
56
 
25
  protected $license_page;
26
  protected $advanced_tab;
27
  protected $translation_memory;
28
+ protected $machine_translation_tab;
29
 
30
  public $active_pro_addons = array();
31
  public static $translate_press = null;
51
  define( 'TRP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
52
  define( 'TRP_PLUGIN_BASE', plugin_basename( __DIR__ . '/index.php' ) );
53
  define( 'TRP_PLUGIN_SLUG', 'translatepress-multilingual' );
54
+ define( 'TRP_PLUGIN_VERSION', '1.6.0' );
55
 
56
  wp_cache_add_non_persistent_groups(array('trp'));
57
 
includes/class-languages.php CHANGED
@@ -84,6 +84,9 @@ class TRP_Languages{
84
  * @return array String array of iso codes.
85
  */
86
  public function get_iso_codes( $language_codes, $map_google_codes = true ){
 
 
 
87
  $iso_codes = array();
88
  $wp_languages = $this->get_wp_languages();
89
  $map_wp_codes_to_google = apply_filters( 'trp_map_wp_codes_to_google', array(
84
  * @return array String array of iso codes.
85
  */
86
  public function get_iso_codes( $language_codes, $map_google_codes = true ){
87
+ if ( !in_array( 'en_US', $language_codes ) ){
88
+ $language_codes[] = 'en_US';
89
+ }
90
  $iso_codes = array();
91
  $wp_languages = $this->get_wp_languages();
92
  $map_wp_codes_to_google = apply_filters( 'trp_map_wp_codes_to_google', array(
includes/class-machine-translation-tab.php CHANGED
@@ -11,7 +11,8 @@ class TRP_Machine_Translation_Tab {
11
  if( !empty( $settings ) )
12
  $this->settings = $settings;
13
  else
14
- $this->settings = array( 'machine-translation' => 'no' );
 
15
 
16
  if( !class_exists( 'TRP_DeepL' ) )
17
  add_filter( 'trp_machine_translation_engines', [ $this, 'translation_engines_upsell' ], 20 );
@@ -75,6 +76,7 @@ class TRP_Machine_Translation_Tab {
75
  $trp_languages = $trp->get_component( 'languages' );
76
  $trp_settings = $trp->get_component( 'settings' );
77
 
 
78
  $settings['machine-translate-codes'] = $trp_languages->get_iso_codes( $trp_settings->get_setting( 'translation-languages' ) );
79
 
80
  return apply_filters( 'trp_machine_translation_sanitize_settings', $settings );
@@ -84,13 +86,13 @@ class TRP_Machine_Translation_Tab {
84
  * Automatic Translation
85
  */
86
  public function machine_translation_page_content(){
87
- if ( ! $this->machine_translator_logger ) {
88
- $trp = TRP_Translate_Press::get_trp_instance();
89
- $machine_translator_logger = $trp->get_component( 'machine_translator_logger' );
90
- }
91
 
 
92
  $machine_translator_logger->maybe_reset_counter_date();
93
 
 
 
94
  require_once TRP_PLUGIN_DIR . 'partials/machine-translation-settings-page.php';
95
  }
96
 
11
  if( !empty( $settings ) )
12
  $this->settings = $settings;
13
  else
14
+ $this->settings = [ 'machine-translation' => 'no', 'translation-engine' => 'google_translate_v2' ];
15
+
16
 
17
  if( !class_exists( 'TRP_DeepL' ) )
18
  add_filter( 'trp_machine_translation_engines', [ $this, 'translation_engines_upsell' ], 20 );
76
  $trp_languages = $trp->get_component( 'languages' );
77
  $trp_settings = $trp->get_component( 'settings' );
78
 
79
+ /* @deprecated Setting only used for compatibility with Deepl Add-on 1.0.0 */
80
  $settings['machine-translate-codes'] = $trp_languages->get_iso_codes( $trp_settings->get_setting( 'translation-languages' ) );
81
 
82
  return apply_filters( 'trp_machine_translation_sanitize_settings', $settings );
86
  * Automatic Translation
87
  */
88
  public function machine_translation_page_content(){
89
+ $trp = TRP_Translate_Press::get_trp_instance();
 
 
 
90
 
91
+ $machine_translator_logger = $trp->get_component( 'machine_translator_logger' );
92
  $machine_translator_logger->maybe_reset_counter_date();
93
 
94
+ $machine_translator = $trp->get_component( 'machine_translator' );
95
+
96
  require_once TRP_PLUGIN_DIR . 'partials/machine-translation-settings-page.php';
97
  }
98
 
includes/class-machine-translator.php CHANGED
@@ -5,11 +5,13 @@
5
  *
6
  * Facilitates Machine Translation calls
7
  */
8
- abstract class TRP_Machine_Translator {
9
  protected $settings;
10
  protected $referer;
11
  protected $url_converter;
12
  protected $machine_translator_logger;
 
 
13
  /**
14
  * TRP_Machine_Translator constructor.
15
  *
@@ -18,10 +20,14 @@ abstract class TRP_Machine_Translator {
18
  public function __construct( $settings ){
19
  $this->settings = $settings;
20
 
 
21
  if ( ! $this->machine_translator_logger ) {
22
- $trp = TRP_Translate_Press::get_trp_instance();
23
  $this->machine_translator_logger = $trp->get_component('machine_translator_logger');
24
  }
 
 
 
 
25
  }
26
 
27
  /**
@@ -56,6 +62,7 @@ abstract class TRP_Machine_Translator {
56
 
57
  /**
58
  * Verifies that the machine translation request is valid
 
59
  *
60
  * @param string $to_language language we're looking to translate to
61
  * @return bool
@@ -64,7 +71,7 @@ abstract class TRP_Machine_Translator {
64
 
65
  if( empty( $this->get_api_key() ) ||
66
  empty( $to_language ) || $to_language == $this->settings['default-language'] ||
67
- empty( $this->settings['machine-translate-codes'][$this->settings['default-language']] )
68
  )
69
  return false;
70
 
@@ -84,6 +91,37 @@ abstract class TRP_Machine_Translator {
84
 
85
  }
86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  /**
88
  * Verifies user agent to check if the request is being made by a crawler
89
  *
@@ -110,11 +148,12 @@ abstract class TRP_Machine_Translator {
110
  * Function to be used externally
111
  *
112
  * @param $strings
113
- * @param $language_code
 
114
  * @return array
115
  */
116
- public function translate($strings, $language_code){
117
- if ( !empty($strings) && is_array($strings) ) {
118
 
119
  /* google has a problem translating this characters ( '%', '$', '#' )...for some reasons it puts spaces after them so we need to 'encode' them and decode them back. hopefully it won't break anything important */
120
  $trp_exclude_words_from_automatic_translation = apply_filters('trp_exclude_words_from_automatic_translation', array('%', '$', '#'));
@@ -124,7 +163,14 @@ abstract class TRP_Machine_Translator {
124
  $strings[$key] = str_replace($trp_exclude_words_from_automatic_translation, $placeholders, $string);
125
  }
126
 
127
- $machine_strings = $this->translate_array($strings, $language_code);
 
 
 
 
 
 
 
128
 
129
  if (!empty($machine_strings)) {
130
  foreach ($machine_strings as $key => $machine_string) {
@@ -137,17 +183,6 @@ abstract class TRP_Machine_Translator {
137
  }
138
  }
139
 
140
- /**
141
- * Function to implement in specific machine translators APIs
142
- *
143
- * This is not meant for calling externally except for when short-circuiting translate()
144
- *
145
- *
146
- * @param $strings
147
- * @param $language_code
148
- * @return array
149
- */
150
- abstract public function translate_array( $strings, $language_code );
151
 
152
  public function test_request(){}
153
 
5
  *
6
  * Facilitates Machine Translation calls
7
  */
8
+ class TRP_Machine_Translator {
9
  protected $settings;
10
  protected $referer;
11
  protected $url_converter;
12
  protected $machine_translator_logger;
13
+ protected $machine_translation_codes;
14
+ protected $trp_languages;
15
  /**
16
  * TRP_Machine_Translator constructor.
17
  *
20
  public function __construct( $settings ){
21
  $this->settings = $settings;
22
 
23
+ $trp = TRP_Translate_Press::get_trp_instance();
24
  if ( ! $this->machine_translator_logger ) {
 
25
  $this->machine_translator_logger = $trp->get_component('machine_translator_logger');
26
  }
27
+ if ( ! $this->trp_languages ) {
28
+ $this->trp_languages = $trp->get_component('languages');
29
+ }
30
+ $this->machine_translation_codes = $this->trp_languages->get_iso_codes($this->settings['translation-languages']);
31
  }
32
 
33
  /**
62
 
63
  /**
64
  * Verifies that the machine translation request is valid
65
+ * @deprecated since TP 1.6.0 (only here to support Deepl Add-on version 1.0.0)
66
  *
67
  * @param string $to_language language we're looking to translate to
68
  * @return bool
71
 
72
  if( empty( $this->get_api_key() ) ||
73
  empty( $to_language ) || $to_language == $this->settings['default-language'] ||
74
+ empty( $this->machine_translation_codes[$this->settings['default-language']] )
75
  )
76
  return false;
77
 
91
 
92
  }
93
 
94
+ /**
95
+ * Verifies that the machine translation request is valid
96
+ *
97
+ * @param string $target_language_code language we're looking to translate to
98
+ * @param string $source_language_code language we're looking to translate from
99
+ * @return bool
100
+ */
101
+ public function verify_request_parameters($target_language_code, $source_language_code){
102
+ if( empty( $this->get_api_key() ) ||
103
+ empty( $target_language_code ) || empty( $source_language_code ) ||
104
+ empty( $this->machine_translation_codes[$target_language_code] ) ||
105
+ empty( $this->machine_translation_codes[$source_language_code] ) ||
106
+ $this->machine_translation_codes[$target_language_code] == $this->machine_translation_codes[$source_language_code]
107
+ )
108
+ return false;
109
+
110
+ // Method that can be extended in the child class to add extra validation
111
+ if( !$this->extra_request_validations( $target_language_code ) )
112
+ return false;
113
+
114
+ // Check if crawlers are blocked
115
+ if( !empty( $this->settings['block-crawlers'] ) && $this->settings['block-crawlers'] == 'yes' && $this->is_crawler() )
116
+ return false;
117
+
118
+ // Check if daily quota is met
119
+ if( $this->machine_translator_logger->quota_exceeded() )
120
+ return false;
121
+
122
+ return true;
123
+ }
124
+
125
  /**
126
  * Verifies user agent to check if the request is being made by a crawler
127
  *
148
  * Function to be used externally
149
  *
150
  * @param $strings
151
+ * @param $target_language_code
152
+ * @param $source_language_code
153
  * @return array
154
  */
155
+ public function translate($strings, $target_language_code, $source_language_code = null ){
156
+ if ( !empty($strings) && is_array($strings) && method_exists( $this, 'translate_array' ) ) {
157
 
158
  /* google has a problem translating this characters ( '%', '$', '#' )...for some reasons it puts spaces after them so we need to 'encode' them and decode them back. hopefully it won't break anything important */
159
  $trp_exclude_words_from_automatic_translation = apply_filters('trp_exclude_words_from_automatic_translation', array('%', '$', '#'));
163
  $strings[$key] = str_replace($trp_exclude_words_from_automatic_translation, $placeholders, $string);
164
  }
165
 
166
+ $machine_translation_settings = get_option( 'trp_machine_translation_settings', false );
167
+ if ( $machine_translation_settings !== false && $machine_translation_settings['translation-engine'] === 'deepl' && defined( 'TRP_DL_PLUGIN_VERSION' ) && TRP_DL_PLUGIN_VERSION === '1.0.0' ) {
168
+ // backwards compatibility with deepl version 1.0.0 which doesn't have the third function parameter $source_language_code
169
+ $machine_strings = $this->translate_array($strings, $target_language_code);
170
+ }else {
171
+ $machine_strings = $this->translate_array($strings, $target_language_code, $source_language_code);
172
+ }
173
+
174
 
175
  if (!empty($machine_strings)) {
176
  foreach ($machine_strings as $key => $machine_string) {
183
  }
184
  }
185
 
 
 
 
 
 
 
 
 
 
 
 
186
 
187
  public function test_request(){}
188
 
includes/class-settings.php CHANGED
@@ -259,6 +259,7 @@ class TRP_Settings{
259
  // regenerate machine translation codes
260
  $machine_translation_settings = get_option( 'trp_machine_translation_settings', array() );
261
 
 
262
  $machine_translation_settings['machine-translate-codes'] = $this->trp_languages->get_iso_codes( $settings['translation-languages'] );
263
 
264
  update_option( 'trp_machine_translation_settings', $machine_translation_settings );
@@ -301,7 +302,6 @@ class TRP_Settings{
301
  'url-slugs' => array( 'en_US' => 'en', '' ),
302
  'advanced_settings' => get_option('trp_advanced_settings', array() ),
303
  'machine-translation' => 'no',
304
- 'translation-engine' => 'google_translate_v2',
305
  'block-crawlers' => 'yes',
306
  );
307
 
259
  // regenerate machine translation codes
260
  $machine_translation_settings = get_option( 'trp_machine_translation_settings', array() );
261
 
262
+ /* @deprecated Setting only used for compatibility with Deepl 1.0.0 */
263
  $machine_translation_settings['machine-translate-codes'] = $this->trp_languages->get_iso_codes( $settings['translation-languages'] );
264
 
265
  update_option( 'trp_machine_translation_settings', $machine_translation_settings );
302
  'url-slugs' => array( 'en_US' => 'en', '' ),
303
  'advanced_settings' => get_option('trp_advanced_settings', array() ),
304
  'machine-translation' => 'no',
 
305
  'block-crawlers' => 'yes',
306
  );
307
 
includes/class-translation-manager.php CHANGED
@@ -14,6 +14,8 @@ class TRP_Translation_Manager{
14
  protected $machine_translator;
15
  protected $slug_manager;
16
  protected $url_converter;
 
 
17
 
18
  /**
19
  * TRP_Translation_Manager constructor.
@@ -384,8 +386,17 @@ class TRP_Translation_Manager{
384
 
385
  public function call_gettext_filters( $prefix = '' ){
386
  global $pagenow;
387
- // Do not process gettext strings on wp-login pages. Do not process strings in admin area except for when when is_ajax_on_frontend.
388
- if( ( $pagenow != 'wp-login.php' ) && ( !is_admin() || $this::is_ajax_on_frontend() ) ) {
 
 
 
 
 
 
 
 
 
389
  add_filter('gettext', array($this, $prefix.'process_gettext_strings'), 100, 3);
390
  add_filter('gettext_with_context', array($this, $prefix.'process_gettext_strings_with_context'), 100, 4);
391
  add_filter('ngettext', array($this, $prefix.'process_ngettext_strings'), 100, 5);
@@ -508,6 +519,12 @@ class TRP_Translation_Manager{
508
  if( isset( $_REQUEST['action'] ) && strpos($_REQUEST['action'], 'trp_') === 0 )
509
  return $translation;
510
 
 
 
 
 
 
 
511
  if( apply_filters( 'trp_skip_gettext_processing', false, $translation, $text, $domain ) )
512
  return $translation;
513
 
@@ -553,7 +570,7 @@ class TRP_Translation_Manager{
553
  'domain' => $domain,
554
  'status' => $this->trp_query->get_constant_human_reviewed()
555
  )
556
- ), get_locale() );
557
  }
558
  }
559
  }
@@ -576,7 +593,7 @@ class TRP_Translation_Manager{
576
  'translated' => $translation,
577
  'domain' => $domain
578
  )
579
- ), get_locale() );
580
  /* insert it in the global of translated because now it is in the database */
581
  $trp_translated_gettext_texts[ $domain . '::' . $text ] = array(
582
  'id' => $db_id,
@@ -587,17 +604,22 @@ class TRP_Translation_Manager{
587
  }
588
  }
589
 
590
- if ( ! $this->machine_translator ) {
591
- $trp = TRP_Translate_Press::get_trp_instance();
592
  $this->machine_translator = $trp->get_component( 'machine_translator' );
593
  }
594
- if ( $this->machine_translator->is_available() ) {
 
 
 
 
 
595
  global $trp_gettext_strings_for_machine_translation;
596
  if ( $text == $translation ) {
597
  foreach ( $trp_translated_gettext_texts as $trp_translated_gettext_text ) {
598
  if ( $trp_translated_gettext_text['id'] == $db_id ) {
599
- if ( $trp_translated_gettext_text['translated'] == '' ) {
600
- $trp_gettext_strings_for_machine_translation[] = array(
601
  'id' => $db_id,
602
  'original' => $text,
603
  'translated' => '',
@@ -770,25 +792,32 @@ class TRP_Translation_Manager{
770
 
771
  // machine translate new strings
772
  if ( $this->machine_translator->is_available() ) {
 
 
 
 
 
 
773
  $new_strings = array();
774
  foreach( $trp_gettext_strings_for_machine_translation as $trp_gettext_string_for_machine_translation ){
775
  $new_strings[] = $trp_gettext_string_for_machine_translation['original'];
776
  }
777
 
778
- $machine_strings = $this->machine_translator->translate( $new_strings, $TRP_LANGUAGE );
 
779
 
780
  if( !empty( $machine_strings ) ){
781
  foreach( $machine_strings as $key => $machine_string ){
782
  $trp_gettext_strings_for_machine_translation[$key]['translated'] = $machine_string;
783
  }
784
- }
785
 
786
- if (!$this->trp_query) {
787
- $trp = TRP_Translate_Press::get_trp_instance();
788
- $this->trp_query = $trp->get_component('query');
789
- }
790
 
791
- $this->trp_query->update_gettext_strings( $trp_gettext_strings_for_machine_translation, $TRP_LANGUAGE );
 
792
  }
793
  }
794
  }
14
  protected $machine_translator;
15
  protected $slug_manager;
16
  protected $url_converter;
17
+ protected $trp_languages;
18
+ protected $is_admin_request = null;
19
 
20
  /**
21
  * TRP_Translation_Manager constructor.
386
 
387
  public function call_gettext_filters( $prefix = '' ){
388
  global $pagenow;
389
+
390
+ if( ! $this->url_converter ) {
391
+ $trp = TRP_Translate_Press::get_trp_instance();
392
+ $this->url_converter = $trp->get_component( 'url_converter' );
393
+ }
394
+ if ( $this->is_admin_request === null ) {
395
+ $this->is_admin_request = $this->url_converter->is_admin_request();
396
+ }
397
+
398
+ // Do not process gettext strings on wp-login pages. Do not process strings in admin area except for when when is_ajax_on_frontend. Do not process gettext strings when is rest api from admin url referer.
399
+ if( ( $pagenow != 'wp-login.php' ) && ( !is_admin() || $this::is_ajax_on_frontend() ) && !$this->is_admin_request ) {
400
  add_filter('gettext', array($this, $prefix.'process_gettext_strings'), 100, 3);
401
  add_filter('gettext_with_context', array($this, $prefix.'process_gettext_strings_with_context'), 100, 4);
402
  add_filter('ngettext', array($this, $prefix.'process_ngettext_strings'), 100, 5);
519
  if( isset( $_REQUEST['action'] ) && strpos($_REQUEST['action'], 'trp_') === 0 )
520
  return $translation;
521
 
522
+ /* get_locale() returns WP Settings Language (WPLANG). It might not be a language in TP so it may not have a TP table. */
523
+ $current_locale = get_locale();
524
+ if ( !in_array( $current_locale, $this->settings['translation-languages'] ) ){
525
+ return $translation;
526
+ }
527
+
528
  if( apply_filters( 'trp_skip_gettext_processing', false, $translation, $text, $domain ) )
529
  return $translation;
530
 
570
  'domain' => $domain,
571
  'status' => $this->trp_query->get_constant_human_reviewed()
572
  )
573
+ ), $current_locale );
574
  }
575
  }
576
  }
593
  'translated' => $translation,
594
  'domain' => $domain
595
  )
596
+ ), $current_locale );
597
  /* insert it in the global of translated because now it is in the database */
598
  $trp_translated_gettext_texts[ $domain . '::' . $text ] = array(
599
  'id' => $db_id,
604
  }
605
  }
606
 
607
+ $trp = TRP_Translate_Press::get_trp_instance();
608
+ if ( ! $this->machine_translator ) {
609
  $this->machine_translator = $trp->get_component( 'machine_translator' );
610
  }
611
+ if ( !$this->trp_languages) {
612
+ $this->trp_languages = $trp->get_component( 'languages' );
613
+ }
614
+ $machine_translation_codes = $this->trp_languages->get_iso_codes($this->settings['translation-languages']);
615
+ /* We assume Gettext strings are in English so don't automatically translate into English */
616
+ if ( $machine_translation_codes[$TRP_LANGUAGE] != 'en' && $this->machine_translator->is_available() ) {
617
  global $trp_gettext_strings_for_machine_translation;
618
  if ( $text == $translation ) {
619
  foreach ( $trp_translated_gettext_texts as $trp_translated_gettext_text ) {
620
  if ( $trp_translated_gettext_text['id'] == $db_id ) {
621
+ if ( $trp_translated_gettext_text['translated'] == '' && ! isset( $trp_gettext_strings_for_machine_translation[$db_id] ) ) {
622
+ $trp_gettext_strings_for_machine_translation[$db_id] = array(
623
  'id' => $db_id,
624
  'original' => $text,
625
  'translated' => '',
792
 
793
  // machine translate new strings
794
  if ( $this->machine_translator->is_available() ) {
795
+
796
+ /* Transform associative array into ordered numeric array. We need to keep keys numeric and ordered because $new_strings and $machine_strings depend on it.
797
+ * Array was constructed as associative with db ids as keys to avoid duplication.
798
+ */
799
+ $trp_gettext_strings_for_machine_translation = array_values( $trp_gettext_strings_for_machine_translation );
800
+
801
  $new_strings = array();
802
  foreach( $trp_gettext_strings_for_machine_translation as $trp_gettext_string_for_machine_translation ){
803
  $new_strings[] = $trp_gettext_string_for_machine_translation['original'];
804
  }
805
 
806
+ // Gettext strings are always in the English language
807
+ $machine_strings = $this->machine_translator->translate( $new_strings, $TRP_LANGUAGE, 'en_US' );
808
 
809
  if( !empty( $machine_strings ) ){
810
  foreach( $machine_strings as $key => $machine_string ){
811
  $trp_gettext_strings_for_machine_translation[$key]['translated'] = $machine_string;
812
  }
 
813
 
814
+ if (!$this->trp_query) {
815
+ $trp = TRP_Translate_Press::get_trp_instance();
816
+ $this->trp_query = $trp->get_component('query');
817
+ }
818
 
819
+ $this->trp_query->update_gettext_strings( $trp_gettext_strings_for_machine_translation, $TRP_LANGUAGE );
820
+ }
821
  }
822
  }
823
  }
includes/class-translation-render.php CHANGED
@@ -1062,7 +1062,7 @@ class TRP_Translation_Render{
1062
 
1063
  // machine translate new strings
1064
  if ( $machine_translation_available ) {
1065
- $machine_strings = $this->machine_translator->translate( $machine_translatable_strings, $language_code );
1066
  }else{
1067
  $machine_strings = false;
1068
  }
1062
 
1063
  // machine translate new strings
1064
  if ( $machine_translation_available ) {
1065
+ $machine_strings = $this->machine_translator->translate( $machine_translatable_strings, $language_code, $this->settings['default-language'] );
1066
  }else{
1067
  $machine_strings = false;
1068
  }
includes/google-translate/class-google-translate-v2-machine-translator.php CHANGED
@@ -38,32 +38,35 @@ class TRP_Google_Translate_V2_Machine_Translator extends TRP_Machine_Translator
38
  /**
39
  * Returns an array with the API provided translations of the $new_strings array.
40
  *
41
- * @param array $new_strings array with the strings that need translation. The keys are the node number in the DOM so we need to preserve the m
42
- * @param string $trp_language_code string wp language code of the language that we will be translating to. Not equal to the google language code
43
- * @return array array with the translation strings and the preserved keys or an empty array if something went wrong
 
44
  */
45
- public function translate_array( $new_strings, $trp_language_code ){
46
-
47
- if( empty( $new_strings ) || !$this->verify_request( $trp_language_code ) )
 
 
48
  return array();
49
 
50
- $translated_strings = array();
 
51
 
52
- $language_code = $this->settings['machine-translate-codes'][$trp_language_code];
53
- $source_language = $this->settings['machine-translate-codes'][$this->settings['default-language']];
54
 
55
  /* split our strings that need translation in chunks of maximum 128 strings because Google Translate has a limit of 128 strings */
56
  $new_strings_chunks = array_chunk( $new_strings, 128, true );
57
  /* if there are more than 128 strings we make multiple requests */
58
  foreach( $new_strings_chunks as $new_strings_chunk ){
59
- $response = $this->send_request( $source_language, $language_code, $new_strings_chunk );
60
 
61
  // this is run only if "Log machine translation queries." is set to Yes.
62
  $this->machine_translator_logger->log(array(
63
  'strings' => serialize( $new_strings_chunk),
64
  'response' => serialize( $response ),
65
  'lang_source' => $source_language,
66
- 'lang_target' => $language_code,
67
  ));
68
 
69
  /* analyze the response */
38
  /**
39
  * Returns an array with the API provided translations of the $new_strings array.
40
  *
41
+ * @param array $new_strings array with the strings that need translation. The keys are the node number in the DOM so we need to preserve the m
42
+ * @param string $target_language_code language code of the language that we will be translating to. Not equal to the google language code
43
+ * @param string $source_language_code language code of the language that we will be translating from. Not equal to the google language code
44
+ * @return array array with the translation strings and the preserved keys or an empty array if something went wrong
45
  */
46
+ public function translate_array($new_strings, $target_language_code, $source_language_code = null ){
47
+ if ( $source_language_code == null ){
48
+ $source_language_code = $this->settings['default-language'];
49
+ }
50
+ if( empty( $new_strings ) || !$this->verify_request_parameters( $target_language_code, $source_language_code ) )
51
  return array();
52
 
53
+ $source_language = $this->machine_translation_codes[$source_language_code];
54
+ $target_language = $this->machine_translation_codes[$target_language_code];
55
 
56
+ $translated_strings = array();
 
57
 
58
  /* split our strings that need translation in chunks of maximum 128 strings because Google Translate has a limit of 128 strings */
59
  $new_strings_chunks = array_chunk( $new_strings, 128, true );
60
  /* if there are more than 128 strings we make multiple requests */
61
  foreach( $new_strings_chunks as $new_strings_chunk ){
62
+ $response = $this->send_request( $source_language, $target_language, $new_strings_chunk );
63
 
64
  // this is run only if "Log machine translation queries." is set to Yes.
65
  $this->machine_translator_logger->log(array(
66
  'strings' => serialize( $new_strings_chunk),
67
  'response' => serialize( $response ),
68
  'lang_source' => $source_language,
69
+ 'lang_target' => $target_language,
70
  ));
71
 
72
  /* analyze the response */
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.5.9
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.6.0
7
  Author: Cozmoslabs, Razvan Mocanu, Madalin Ungureanu, Cristophor Hurduban
8
  Author URI: https://cozmoslabs.com/
9
  Text Domain: translatepress-multilingual
languages/translatepress-multilingual.pot CHANGED
@@ -13,51 +13,51 @@ msgstr ""
13
  "X-Poedit-SourceCharset: UTF-8\n"
14
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
15
 
16
- #: ../tp-add-on-automatic-language-detection/includes/class-ald-settings.php:37
17
  msgid "First by browser language, then IP address (recommended)"
18
  msgstr ""
19
 
20
- #: ../tp-add-on-automatic-language-detection/includes/class-ald-settings.php:38
21
  msgid "First by IP address, then by browser language"
22
  msgstr ""
23
 
24
- #: ../tp-add-on-automatic-language-detection/includes/class-ald-settings.php:39
25
  msgid "Only by browser language"
26
  msgstr ""
27
 
28
- #: ../tp-add-on-automatic-language-detection/includes/class-ald-settings.php:40
29
  msgid "Only by IP address"
30
  msgstr ""
31
 
32
- #: ../tp-add-on-automatic-language-detection/includes/class-ald-settings.php:110
33
  msgid "WARNING. Cannot determine your language preference based on your current IP.<br>This is most likely because the website is on a local environment."
34
  msgstr ""
35
 
36
- #: ../tp-add-on-automatic-language-detection/partials/license-settings-page.php:4, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:4, ../tp-add-on-extra-languages/partials/license-settings-page.php:4, partials/license-settings-page.php:4, ../translatepress/partials/addons-settings-page.php:3, ../translatepress/partials/license-settings-page.php:8, ../translatepress/partials/license-settings-page.php:46, ../translatepress/partials/main-settings-page.php:5, ../translatepress/partials/test-api-settings-page.php:11, ../translatepress/partials/trp-remove-duplicate-rows.php:3, ../trp-add-on-translator-accounts-add-on/partials/license-settings-page.php:4
37
  msgid "TranslatePress Settings"
38
  msgstr ""
39
 
40
- #: ../tp-add-on-automatic-language-detection/partials/license-settings-page.php:10, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:10, ../tp-add-on-extra-languages/partials/license-settings-page.php:10, partials/license-settings-page.php:10, ../translatepress/partials/license-settings-page.php:14, ../trp-add-on-translator-accounts-add-on/partials/license-settings-page.php:10
41
  msgid "License Key"
42
  msgstr ""
43
 
44
- #: ../tp-add-on-automatic-language-detection/partials/license-settings-page.php:15, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:15, ../tp-add-on-extra-languages/partials/license-settings-page.php:15, partials/license-settings-page.php:15, ../translatepress/partials/license-settings-page.php:38, ../trp-add-on-translator-accounts-add-on/partials/license-settings-page.php:15
45
  msgid "Enter your license key."
46
  msgstr ""
47
 
48
- #: ../tp-add-on-automatic-language-detection/partials/license-settings-page.php:22, ../tp-add-on-automatic-language-detection/partials/license-settings-page.php:31, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:22, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:31, ../tp-add-on-extra-languages/partials/license-settings-page.php:22, ../tp-add-on-extra-languages/partials/license-settings-page.php:31, partials/license-settings-page.php:22, partials/license-settings-page.php:31, ../translatepress/partials/license-settings-page.php:32, ../trp-add-on-translator-accounts-add-on/partials/license-settings-page.php:22, ../trp-add-on-translator-accounts-add-on/partials/license-settings-page.php:31
49
  msgid "Activate License"
50
  msgstr ""
51
 
52
- #: ../tp-add-on-automatic-language-detection/partials/license-settings-page.php:28, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:28, ../tp-add-on-extra-languages/partials/license-settings-page.php:28, partials/license-settings-page.php:28, ../translatepress/partials/license-settings-page.php:22, ../trp-add-on-translator-accounts-add-on/partials/license-settings-page.php:28
53
  msgid "Deactivate License"
54
  msgstr ""
55
 
56
- #: ../tp-add-on-automatic-language-detection/partials/settings-option.php:2
57
  msgid "Method of language detection"
58
  msgstr ""
59
 
60
- #: ../tp-add-on-automatic-language-detection/partials/settings-option.php:14
61
  msgid "Select how the language should be detected for first time visitors.<br>The visitor's last displayed language will be remembered through cookies."
62
  msgstr ""
63
 
@@ -109,11 +109,11 @@ msgstr ""
109
  msgid "Limit this menu item to the following languages"
110
  msgstr ""
111
 
112
- #: class-seo-pack.php:146
113
  msgid "The Yoast SEO Sitemaps will now contain the default language slug: example.com/en/sitemap_index.xml <br/> This works perfectly, just take it into account when submitting the sitemap to Google."
114
  msgstr ""
115
 
116
- #: includes/class-slug-manager.php:32
117
  msgid "Post Slug"
118
  msgstr ""
119
 
@@ -225,7 +225,7 @@ msgstr ""
225
  msgid "Advanced"
226
  msgstr ""
227
 
228
- #: ../translatepress/includes/class-advanced-tab.php:211, ../translatepress/partials/machine-translation-settings-page.php:13, ../translatepress/partials/machine-translation-settings-page.php:75, ../translatepress/partials/machine-translation-settings-page.php:108, ../translatepress/partials/main-settings-page.php:41, ../translatepress/partials/main-settings-page.php:54, ../translatepress/partials/main-settings-page.php:67
229
  msgid "Yes"
230
  msgstr ""
231
 
@@ -269,11 +269,11 @@ msgstr ""
269
  msgid "Others"
270
  msgstr ""
271
 
272
- #: ../translatepress/includes/class-machine-translation-tab.php:28
273
  msgid "Automatic Translation"
274
  msgstr ""
275
 
276
- #: ../translatepress/includes/class-machine-translation-tab.php:125
277
  msgid "DeepL"
278
  msgstr ""
279
 
@@ -353,7 +353,7 @@ msgstr ""
353
  msgid "General"
354
  msgstr ""
355
 
356
- #: ../translatepress/includes/class-settings.php:449, ../translatepress/includes/class-translation-manager.php:242
357
  msgid "Translate Site"
358
  msgstr ""
359
 
@@ -365,7 +365,7 @@ msgstr ""
365
  msgid "License"
366
  msgstr ""
367
 
368
- #: ../translatepress/includes/class-settings.php:490, ../translatepress/includes/class-translation-manager.php:274
369
  msgid "Settings"
370
  msgstr ""
371
 
@@ -373,255 +373,255 @@ msgstr ""
373
  msgid "Pro Features"
374
  msgstr ""
375
 
376
- #: ../translatepress/includes/class-translation-manager.php:84
377
  msgid "Image source"
378
  msgstr ""
379
 
380
- #: ../translatepress/includes/class-translation-manager.php:85
381
  msgid "Alt attribute"
382
  msgstr ""
383
 
384
- #: ../translatepress/includes/class-translation-manager.php:86
385
  msgid "Title attribute"
386
  msgstr ""
387
 
388
- #: ../translatepress/includes/class-translation-manager.php:87
389
  msgid "Anchor link"
390
  msgstr ""
391
 
392
- #: ../translatepress/includes/class-translation-manager.php:88
393
  msgid "Placeholder attribute"
394
  msgstr ""
395
 
396
- #: ../translatepress/includes/class-translation-manager.php:89
397
  msgid "Submit attribute"
398
  msgstr ""
399
 
400
- #: ../translatepress/includes/class-translation-manager.php:90
401
  msgid "Text"
402
  msgstr ""
403
 
404
- #: ../translatepress/includes/class-translation-manager.php:92
405
  msgid "Saved"
406
  msgstr ""
407
 
408
- #: ../translatepress/includes/class-translation-manager.php:93
409
  msgid "Save translation"
410
  msgstr ""
411
 
412
- #: ../translatepress/includes/class-translation-manager.php:94
413
  msgid "Saving translation..."
414
  msgstr ""
415
 
416
- #: ../translatepress/includes/class-translation-manager.php:95
417
  msgid "You have unsaved changes!"
418
  msgstr ""
419
 
420
- #: ../translatepress/includes/class-translation-manager.php:96
421
  msgid "Discard changes"
422
  msgstr ""
423
 
424
- #: ../translatepress/includes/class-translation-manager.php:97
425
  msgid "Discard All"
426
  msgstr ""
427
 
428
- #: ../translatepress/includes/class-translation-manager.php:98
429
  msgid "Loading Strings..."
430
  msgstr ""
431
 
432
- #: ../translatepress/includes/class-translation-manager.php:99
433
  msgid "Select string to translate..."
434
  msgstr ""
435
 
436
- #: ../translatepress/includes/class-translation-manager.php:100
437
  msgid "Close Editor"
438
  msgstr ""
439
 
440
- #: ../translatepress/includes/class-translation-manager.php:101
441
  msgid "From"
442
  msgstr ""
443
 
444
- #: ../translatepress/includes/class-translation-manager.php:102
445
  msgid "To"
446
  msgstr ""
447
 
448
- #: ../translatepress/includes/class-translation-manager.php:103
449
  msgid "Next"
450
  msgstr ""
451
 
452
- #: ../translatepress/includes/class-translation-manager.php:104
453
  msgid "Previous"
454
  msgstr ""
455
 
456
- #: ../translatepress/includes/class-translation-manager.php:105
457
  msgid "Add Media"
458
  msgstr ""
459
 
460
- #: ../translatepress/includes/class-translation-manager.php:106
461
  msgid "Other languages"
462
  msgstr ""
463
 
464
- #: ../translatepress/includes/class-translation-manager.php:107
465
  msgid "View As"
466
  msgstr ""
467
 
468
- #: ../translatepress/includes/class-translation-manager.php:108
469
  msgid "Available in our Pro Versions"
470
  msgstr ""
471
 
472
- #: ../translatepress/includes/class-translation-manager.php:111
473
  msgid "Select or Upload Media"
474
  msgstr ""
475
 
476
- #: ../translatepress/includes/class-translation-manager.php:112
477
  msgid "Use this media"
478
  msgstr ""
479
 
480
- #: ../translatepress/includes/class-translation-manager.php:115
481
  msgid "Translate"
482
  msgstr ""
483
 
484
- #: ../translatepress/includes/class-translation-manager.php:116
485
  msgid "Translate entire block element"
486
  msgstr ""
487
 
488
- #: ../translatepress/includes/class-translation-manager.php:117
489
  msgid "Split block to translate strings individually"
490
  msgstr ""
491
 
492
- #: ../translatepress/includes/class-translation-manager.php:118
493
  msgid "Save changes to translation. Shortcut: CTRL(⌘) + S"
494
  msgstr ""
495
 
496
- #: ../translatepress/includes/class-translation-manager.php:119
497
  msgid "Navigate to next string in dropdown list. Shortcut: CTRL(⌘) + ALT + Right Arrow"
498
  msgstr ""
499
 
500
- #: ../translatepress/includes/class-translation-manager.php:120
501
  msgid "Navigate to previous string in dropdown list. Shortcut: CTRL(⌘) + ALT + Left Arrow"
502
  msgstr ""
503
 
504
- #: ../translatepress/includes/class-translation-manager.php:121
505
  msgid "Discard all changes. Shortcut: CTRL(⌘) + ALT + Z"
506
  msgstr ""
507
 
508
- #: ../translatepress/includes/class-translation-manager.php:122
509
  msgid "Discard changes to this text box. To discard changes to all text boxes use shortcut: CTRL(⌘) + ALT + Z"
510
  msgstr ""
511
 
512
- #: ../translatepress/includes/class-translation-manager.php:124
513
  msgid "Are you sure you want to split this phrase into smaller parts?"
514
  msgstr ""
515
 
516
- #: ../translatepress/includes/class-translation-manager.php:125
517
  msgid "This string is not ready for translation yet. <br>Try again in a moment..."
518
  msgstr ""
519
 
520
- #: ../translatepress/includes/class-translation-manager.php:127
521
  msgid "For this option to work, please update the Browse as other role add-on to the latest version."
522
  msgstr ""
523
 
524
- #: ../translatepress/includes/class-translation-manager.php:128
525
  msgid "To translate slugs, please update the SEO Pack add-on to the latest version."
526
  msgstr ""
527
 
528
- #: ../translatepress/includes/class-translation-manager.php:131
529
  msgid "You can add a new language from <a href=\"%s\">Settings->TranslatePress</a>"
530
  msgstr ""
531
 
532
- #: ../translatepress/includes/class-translation-manager.php:132
533
  msgid "However, you can still use TranslatePress to <strong style=\"background: #f5fb9d;\">modify gettext strings</strong> available in your page."
534
  msgstr ""
535
 
536
- #: ../translatepress/includes/class-translation-manager.php:133
537
  msgid "Strings that are user-created cannot be modified, only those from themes and plugins."
538
  msgstr ""
539
 
540
- #: ../translatepress/includes/class-translation-manager.php:135
541
  msgid "Extra Translation Features"
542
  msgstr ""
543
 
544
- #: ../translatepress/includes/class-translation-manager.php:136
545
  msgid "Support for 221 Extra Languages"
546
  msgstr ""
547
 
548
- #: ../translatepress/includes/class-translation-manager.php:137
549
  msgid "Yoast SEO support"
550
  msgstr ""
551
 
552
- #: ../translatepress/includes/class-translation-manager.php:138
553
  msgid "Translate SEO Title, Description, Slug"
554
  msgstr ""
555
 
556
- #: ../translatepress/includes/class-translation-manager.php:139
557
  msgid "Publish only when translation is complete"
558
  msgstr ""
559
 
560
- #: ../translatepress/includes/class-translation-manager.php:140
561
  msgid "Translate by Browsing as User Role"
562
  msgstr ""
563
 
564
- #: ../translatepress/includes/class-translation-manager.php:141
565
  msgid "Different Menu Items for each Language"
566
  msgstr ""
567
 
568
- #: ../translatepress/includes/class-translation-manager.php:142
569
  msgid "Automatic User Language Detection"
570
  msgstr ""
571
 
572
- #: ../translatepress/includes/class-translation-manager.php:143
573
  msgid "Supported By Real People"
574
  msgstr ""
575
 
576
- #: ../translatepress/includes/class-translation-manager.php:144
577
  msgid "Find Out More"
578
  msgstr ""
579
 
580
- #: ../translatepress/includes/class-translation-manager.php:146
581
  msgid "No available suggestions"
582
  msgstr ""
583
 
584
- #: ../translatepress/includes/class-translation-manager.php:147
585
  msgid "Suggestions from translation memory"
586
  msgstr ""
587
 
588
- #: ../translatepress/includes/class-translation-manager.php:148
589
  msgid "Click to Copy"
590
  msgstr ""
591
 
592
- #: ../translatepress/includes/class-translation-manager.php:154
593
  msgid "Slugs"
594
  msgstr ""
595
 
596
- #: ../translatepress/includes/class-translation-manager.php:155
597
  msgid "Meta Information"
598
  msgstr ""
599
 
600
- #: ../translatepress/includes/class-translation-manager.php:156
601
  msgid "String List"
602
  msgstr ""
603
 
604
- #: ../translatepress/includes/class-translation-manager.php:157
605
  msgid "Gettext Strings"
606
  msgstr ""
607
 
608
- #: ../translatepress/includes/class-translation-manager.php:158
609
  msgid "Images"
610
  msgstr ""
611
 
612
- #: ../translatepress/includes/class-translation-manager.php:159
613
  msgid "Dynamically Added Strings"
614
  msgstr ""
615
 
616
- #: ../translatepress/includes/class-translation-manager.php:255
617
  msgid "Translate Page"
618
  msgstr ""
619
 
620
- #: ../translatepress/includes/class-translation-manager.php:952
621
  msgid "Security check"
622
  msgstr ""
623
 
624
- #: ../translatepress/includes/class-translation-manager.php:1026
625
  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."
626
  msgstr ""
627
 
@@ -861,39 +861,39 @@ msgstr ""
861
  msgid "By upgrading you'll get access to all paid add-ons, premium support and help fund the future development of TranslatePress."
862
  msgstr ""
863
 
864
- #: ../translatepress/partials/machine-translation-settings-page.php:61
865
  msgid "Test API credentials"
866
  msgstr ""
867
 
868
- #: ../translatepress/partials/machine-translation-settings-page.php:63
869
  msgid "Click here to check if the selected translation engine is configured correctly."
870
  msgstr ""
871
 
872
- #: ../translatepress/partials/machine-translation-settings-page.php:71
873
  msgid "Block Crawlers"
874
  msgstr ""
875
 
876
- #: ../translatepress/partials/machine-translation-settings-page.php:78
877
  msgid "Block crawlers from triggering automatic translations on your website."
878
  msgstr ""
879
 
880
- #: ../translatepress/partials/machine-translation-settings-page.php:84
881
  msgid "Limit machine translation / characters per day"
882
  msgstr ""
883
 
884
- #: ../translatepress/partials/machine-translation-settings-page.php:90
885
  msgid "Add a limit to the number of automatically translated characters so you can better budget your project."
886
  msgstr ""
887
 
888
- #: ../translatepress/partials/machine-translation-settings-page.php:96
889
  msgid "Today's character count:"
890
  msgstr ""
891
 
892
- #: ../translatepress/partials/machine-translation-settings-page.php:104
893
  msgid "Log machine translation queries."
894
  msgstr ""
895
 
896
- #: ../translatepress/partials/machine-translation-settings-page.php:111
897
  msgid "Only enable for testing purposes. Can impact performance.<br>All records are stored in the wp_trp_machine_translation_log database table. Use a plugin like <a href=\"https://wordpress.org/plugins/wp-data-access/\">WP Data Access</a> to browse the logs or directly from your database manager (PHPMyAdmin, etc.)"
898
  msgstr ""
899
 
13
  "X-Poedit-SourceCharset: UTF-8\n"
14
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
15
 
16
+ #: includes/class-ald-settings.php:37
17
  msgid "First by browser language, then IP address (recommended)"
18
  msgstr ""
19
 
20
+ #: includes/class-ald-settings.php:38
21
  msgid "First by IP address, then by browser language"
22
  msgstr ""
23
 
24
+ #: includes/class-ald-settings.php:39
25
  msgid "Only by browser language"
26
  msgstr ""
27
 
28
+ #: includes/class-ald-settings.php:40
29
  msgid "Only by IP address"
30
  msgstr ""
31
 
32
+ #: includes/class-ald-settings.php:110
33
  msgid "WARNING. Cannot determine your language preference based on your current IP.<br>This is most likely because the website is on a local environment."
34
  msgstr ""
35
 
36
+ #: partials/license-settings-page.php:4, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:4, ../tp-add-on-extra-languages/partials/license-settings-page.php:4, ../tp-add-on-seo-pack/partials/license-settings-page.php:4, ../translatepress/partials/addons-settings-page.php:3, ../translatepress/partials/license-settings-page.php:8, ../translatepress/partials/license-settings-page.php:46, ../translatepress/partials/main-settings-page.php:5, ../translatepress/partials/test-api-settings-page.php:11, ../translatepress/partials/trp-remove-duplicate-rows.php:3, ../trp-add-on-translator-accounts-add-on/partials/license-settings-page.php:4
37
  msgid "TranslatePress Settings"
38
  msgstr ""
39
 
40
+ #: partials/license-settings-page.php:10, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:10, ../tp-add-on-extra-languages/partials/license-settings-page.php:10, ../tp-add-on-seo-pack/partials/license-settings-page.php:10, ../translatepress/partials/license-settings-page.php:14, ../trp-add-on-translator-accounts-add-on/partials/license-settings-page.php:10
41
  msgid "License Key"
42
  msgstr ""
43
 
44
+ #: partials/license-settings-page.php:15, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:15, ../tp-add-on-extra-languages/partials/license-settings-page.php:15, ../tp-add-on-seo-pack/partials/license-settings-page.php:15, ../translatepress/partials/license-settings-page.php:38, ../trp-add-on-translator-accounts-add-on/partials/license-settings-page.php:15
45
  msgid "Enter your license key."
46
  msgstr ""
47
 
48
+ #: partials/license-settings-page.php:22, partials/license-settings-page.php:31, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:22, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:31, ../tp-add-on-extra-languages/partials/license-settings-page.php:22, ../tp-add-on-extra-languages/partials/license-settings-page.php:31, ../tp-add-on-seo-pack/partials/license-settings-page.php:22, ../tp-add-on-seo-pack/partials/license-settings-page.php:31, ../translatepress/partials/license-settings-page.php:32, ../trp-add-on-translator-accounts-add-on/partials/license-settings-page.php:22, ../trp-add-on-translator-accounts-add-on/partials/license-settings-page.php:31
49
  msgid "Activate License"
50
  msgstr ""
51
 
52
+ #: partials/license-settings-page.php:28, ../tp-add-on-browse-as-other-roles/partials/license-settings-page.php:28, ../tp-add-on-extra-languages/partials/license-settings-page.php:28, ../tp-add-on-seo-pack/partials/license-settings-page.php:28, ../translatepress/partials/license-settings-page.php:22, ../trp-add-on-translator-accounts-add-on/partials/license-settings-page.php:28
53
  msgid "Deactivate License"
54
  msgstr ""
55
 
56
+ #: partials/settings-option.php:2
57
  msgid "Method of language detection"
58
  msgstr ""
59
 
60
+ #: partials/settings-option.php:14
61
  msgid "Select how the language should be detected for first time visitors.<br>The visitor's last displayed language will be remembered through cookies."
62
  msgstr ""
63
 
109
  msgid "Limit this menu item to the following languages"
110
  msgstr ""
111
 
112
+ #: ../tp-add-on-seo-pack/class-seo-pack.php:146
113
  msgid "The Yoast SEO Sitemaps will now contain the default language slug: example.com/en/sitemap_index.xml <br/> This works perfectly, just take it into account when submitting the sitemap to Google."
114
  msgstr ""
115
 
116
+ #: ../tp-add-on-seo-pack/includes/class-slug-manager.php:32
117
  msgid "Post Slug"
118
  msgstr ""
119
 
225
  msgid "Advanced"
226
  msgstr ""
227
 
228
+ #: ../translatepress/includes/class-advanced-tab.php:211, ../translatepress/partials/machine-translation-settings-page.php:13, ../translatepress/partials/machine-translation-settings-page.php:77, ../translatepress/partials/machine-translation-settings-page.php:110, ../translatepress/partials/main-settings-page.php:41, ../translatepress/partials/main-settings-page.php:54, ../translatepress/partials/main-settings-page.php:67
229
  msgid "Yes"
230
  msgstr ""
231
 
269
  msgid "Others"
270
  msgstr ""
271
 
272
+ #: ../translatepress/includes/class-machine-translation-tab.php:29
273
  msgid "Automatic Translation"
274
  msgstr ""
275
 
276
+ #: ../translatepress/includes/class-machine-translation-tab.php:127
277
  msgid "DeepL"
278
  msgstr ""
279
 
353
  msgid "General"
354
  msgstr ""
355
 
356
+ #: ../translatepress/includes/class-settings.php:449, ../translatepress/includes/class-translation-manager.php:244
357
  msgid "Translate Site"
358
  msgstr ""
359
 
365
  msgid "License"
366
  msgstr ""
367
 
368
+ #: ../translatepress/includes/class-settings.php:490, ../translatepress/includes/class-translation-manager.php:276
369
  msgid "Settings"
370
  msgstr ""
371
 
373
  msgid "Pro Features"
374
  msgstr ""
375
 
376
+ #: ../translatepress/includes/class-translation-manager.php:86
377
  msgid "Image source"
378
  msgstr ""
379
 
380
+ #: ../translatepress/includes/class-translation-manager.php:87
381
  msgid "Alt attribute"
382
  msgstr ""
383
 
384
+ #: ../translatepress/includes/class-translation-manager.php:88
385
  msgid "Title attribute"
386
  msgstr ""
387
 
388
+ #: ../translatepress/includes/class-translation-manager.php:89
389
  msgid "Anchor link"
390
  msgstr ""
391
 
392
+ #: ../translatepress/includes/class-translation-manager.php:90
393
  msgid "Placeholder attribute"
394
  msgstr ""
395
 
396
+ #: ../translatepress/includes/class-translation-manager.php:91
397
  msgid "Submit attribute"
398
  msgstr ""
399
 
400
+ #: ../translatepress/includes/class-translation-manager.php:92
401
  msgid "Text"
402
  msgstr ""
403
 
404
+ #: ../translatepress/includes/class-translation-manager.php:94
405
  msgid "Saved"
406
  msgstr ""
407
 
408
+ #: ../translatepress/includes/class-translation-manager.php:95
409
  msgid "Save translation"
410
  msgstr ""
411
 
412
+ #: ../translatepress/includes/class-translation-manager.php:96
413
  msgid "Saving translation..."
414
  msgstr ""
415
 
416
+ #: ../translatepress/includes/class-translation-manager.php:97
417
  msgid "You have unsaved changes!"
418
  msgstr ""
419
 
420
+ #: ../translatepress/includes/class-translation-manager.php:98
421
  msgid "Discard changes"
422
  msgstr ""
423
 
424
+ #: ../translatepress/includes/class-translation-manager.php:99
425
  msgid "Discard All"
426
  msgstr ""
427
 
428
+ #: ../translatepress/includes/class-translation-manager.php:100
429
  msgid "Loading Strings..."
430
  msgstr ""
431
 
432
+ #: ../translatepress/includes/class-translation-manager.php:101
433
  msgid "Select string to translate..."
434
  msgstr ""
435
 
436
+ #: ../translatepress/includes/class-translation-manager.php:102
437
  msgid "Close Editor"
438
  msgstr ""
439
 
440
+ #: ../translatepress/includes/class-translation-manager.php:103
441
  msgid "From"
442
  msgstr ""
443
 
444
+ #: ../translatepress/includes/class-translation-manager.php:104
445
  msgid "To"
446
  msgstr ""
447
 
448
+ #: ../translatepress/includes/class-translation-manager.php:105
449
  msgid "Next"
450
  msgstr ""
451
 
452
+ #: ../translatepress/includes/class-translation-manager.php:106
453
  msgid "Previous"
454
  msgstr ""
455
 
456
+ #: ../translatepress/includes/class-translation-manager.php:107
457
  msgid "Add Media"
458
  msgstr ""
459
 
460
+ #: ../translatepress/includes/class-translation-manager.php:108
461
  msgid "Other languages"
462
  msgstr ""
463
 
464
+ #: ../translatepress/includes/class-translation-manager.php:109
465
  msgid "View As"
466
  msgstr ""
467
 
468
+ #: ../translatepress/includes/class-translation-manager.php:110
469
  msgid "Available in our Pro Versions"
470
  msgstr ""
471
 
472
+ #: ../translatepress/includes/class-translation-manager.php:113
473
  msgid "Select or Upload Media"
474
  msgstr ""
475
 
476
+ #: ../translatepress/includes/class-translation-manager.php:114
477
  msgid "Use this media"
478
  msgstr ""
479
 
480
+ #: ../translatepress/includes/class-translation-manager.php:117
481
  msgid "Translate"
482
  msgstr ""
483
 
484
+ #: ../translatepress/includes/class-translation-manager.php:118
485
  msgid "Translate entire block element"
486
  msgstr ""
487
 
488
+ #: ../translatepress/includes/class-translation-manager.php:119
489
  msgid "Split block to translate strings individually"
490
  msgstr ""
491
 
492
+ #: ../translatepress/includes/class-translation-manager.php:120
493
  msgid "Save changes to translation. Shortcut: CTRL(⌘) + S"
494
  msgstr ""
495
 
496
+ #: ../translatepress/includes/class-translation-manager.php:121
497
  msgid "Navigate to next string in dropdown list. Shortcut: CTRL(⌘) + ALT + Right Arrow"
498
  msgstr ""
499
 
500
+ #: ../translatepress/includes/class-translation-manager.php:122
501
  msgid "Navigate to previous string in dropdown list. Shortcut: CTRL(⌘) + ALT + Left Arrow"
502
  msgstr ""
503
 
504
+ #: ../translatepress/includes/class-translation-manager.php:123
505
  msgid "Discard all changes. Shortcut: CTRL(⌘) + ALT + Z"
506
  msgstr ""
507
 
508
+ #: ../translatepress/includes/class-translation-manager.php:124
509
  msgid "Discard changes to this text box. To discard changes to all text boxes use shortcut: CTRL(⌘) + ALT + Z"
510
  msgstr ""
511
 
512
+ #: ../translatepress/includes/class-translation-manager.php:126
513
  msgid "Are you sure you want to split this phrase into smaller parts?"
514
  msgstr ""
515
 
516
+ #: ../translatepress/includes/class-translation-manager.php:127
517
  msgid "This string is not ready for translation yet. <br>Try again in a moment..."
518
  msgstr ""
519
 
520
+ #: ../translatepress/includes/class-translation-manager.php:129
521
  msgid "For this option to work, please update the Browse as other role add-on to the latest version."
522
  msgstr ""
523
 
524
+ #: ../translatepress/includes/class-translation-manager.php:130
525
  msgid "To translate slugs, please update the SEO Pack add-on to the latest version."
526
  msgstr ""
527
 
528
+ #: ../translatepress/includes/class-translation-manager.php:133
529
  msgid "You can add a new language from <a href=\"%s\">Settings->TranslatePress</a>"
530
  msgstr ""
531
 
532
+ #: ../translatepress/includes/class-translation-manager.php:134
533
  msgid "However, you can still use TranslatePress to <strong style=\"background: #f5fb9d;\">modify gettext strings</strong> available in your page."
534
  msgstr ""
535
 
536
+ #: ../translatepress/includes/class-translation-manager.php:135
537
  msgid "Strings that are user-created cannot be modified, only those from themes and plugins."
538
  msgstr ""
539
 
540
+ #: ../translatepress/includes/class-translation-manager.php:137
541
  msgid "Extra Translation Features"
542
  msgstr ""
543
 
544
+ #: ../translatepress/includes/class-translation-manager.php:138
545
  msgid "Support for 221 Extra Languages"
546
  msgstr ""
547
 
548
+ #: ../translatepress/includes/class-translation-manager.php:139
549
  msgid "Yoast SEO support"
550
  msgstr ""
551
 
552
+ #: ../translatepress/includes/class-translation-manager.php:140
553
  msgid "Translate SEO Title, Description, Slug"
554
  msgstr ""
555
 
556
+ #: ../translatepress/includes/class-translation-manager.php:141
557
  msgid "Publish only when translation is complete"
558
  msgstr ""
559
 
560
+ #: ../translatepress/includes/class-translation-manager.php:142
561
  msgid "Translate by Browsing as User Role"
562
  msgstr ""
563
 
564
+ #: ../translatepress/includes/class-translation-manager.php:143
565
  msgid "Different Menu Items for each Language"
566
  msgstr ""
567
 
568
+ #: ../translatepress/includes/class-translation-manager.php:144
569
  msgid "Automatic User Language Detection"
570
  msgstr ""
571
 
572
+ #: ../translatepress/includes/class-translation-manager.php:145
573
  msgid "Supported By Real People"
574
  msgstr ""
575
 
576
+ #: ../translatepress/includes/class-translation-manager.php:146
577
  msgid "Find Out More"
578
  msgstr ""
579
 
580
+ #: ../translatepress/includes/class-translation-manager.php:148
581
  msgid "No available suggestions"
582
  msgstr ""
583
 
584
+ #: ../translatepress/includes/class-translation-manager.php:149
585
  msgid "Suggestions from translation memory"
586
  msgstr ""
587
 
588
+ #: ../translatepress/includes/class-translation-manager.php:150
589
  msgid "Click to Copy"
590
  msgstr ""
591
 
592
+ #: ../translatepress/includes/class-translation-manager.php:156
593
  msgid "Slugs"
594
  msgstr ""
595
 
596
+ #: ../translatepress/includes/class-translation-manager.php:157
597
  msgid "Meta Information"
598
  msgstr ""
599
 
600
+ #: ../translatepress/includes/class-translation-manager.php:158
601
  msgid "String List"
602
  msgstr ""
603
 
604
+ #: ../translatepress/includes/class-translation-manager.php:159
605
  msgid "Gettext Strings"
606
  msgstr ""
607
 
608
+ #: ../translatepress/includes/class-translation-manager.php:160
609
  msgid "Images"
610
  msgstr ""
611
 
612
+ #: ../translatepress/includes/class-translation-manager.php:161
613
  msgid "Dynamically Added Strings"
614
  msgstr ""
615
 
616
+ #: ../translatepress/includes/class-translation-manager.php:257
617
  msgid "Translate Page"
618
  msgstr ""
619
 
620
+ #: ../translatepress/includes/class-translation-manager.php:981
621
  msgid "Security check"
622
  msgstr ""
623
 
624
+ #: ../translatepress/includes/class-translation-manager.php:1055
625
  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."
626
  msgstr ""
627
 
861
  msgid "By upgrading you'll get access to all paid add-ons, premium support and help fund the future development of TranslatePress."
862
  msgstr ""
863
 
864
+ #: ../translatepress/partials/machine-translation-settings-page.php:62
865
  msgid "Test API credentials"
866
  msgstr ""
867
 
868
+ #: ../translatepress/partials/machine-translation-settings-page.php:64
869
  msgid "Click here to check if the selected translation engine is configured correctly."
870
  msgstr ""
871
 
872
+ #: ../translatepress/partials/machine-translation-settings-page.php:73
873
  msgid "Block Crawlers"
874
  msgstr ""
875
 
876
+ #: ../translatepress/partials/machine-translation-settings-page.php:80
877
  msgid "Block crawlers from triggering automatic translations on your website."
878
  msgstr ""
879
 
880
+ #: ../translatepress/partials/machine-translation-settings-page.php:86
881
  msgid "Limit machine translation / characters per day"
882
  msgstr ""
883
 
884
+ #: ../translatepress/partials/machine-translation-settings-page.php:92
885
  msgid "Add a limit to the number of automatically translated characters so you can better budget your project."
886
  msgstr ""
887
 
888
+ #: ../translatepress/partials/machine-translation-settings-page.php:98
889
  msgid "Today's character count:"
890
  msgstr ""
891
 
892
+ #: ../translatepress/partials/machine-translation-settings-page.php:106
893
  msgid "Log machine translation queries."
894
  msgstr ""
895
 
896
+ #: ../translatepress/partials/machine-translation-settings-page.php:113
897
  msgid "Only enable for testing purposes. Can impact performance.<br>All records are stored in the wp_trp_machine_translation_log database table. Use a plugin like <a href=\"https://wordpress.org/plugins/wp-data-access/\">WP Data Access</a> to browse the logs or directly from your database manager (PHPMyAdmin, etc.)"
898
  msgstr ""
899
 
partials/machine-translation-settings-page.php CHANGED
@@ -55,15 +55,17 @@
55
 
56
  <?php do_action ( 'trp_machine_translation_extra_settings_middle', $this->settings ); ?>
57
 
58
- <tr id="trp-test-api-key">
59
- <th scope="row"></th>
60
- <td>
61
- <a href="<?php echo esc_url( admin_url( 'admin.php?page=trp_test_machine_api' ) ); ?>" class="button-secondary"><?php _e( 'Test API credentials', 'translatepress-multilingual' ); ?></a>
62
- <p class="description">
63
- <?php _e( 'Click here to check if the selected translation engine is configured correctly.', 'translatepress-multilingual' ) ?>
64
- </p>
65
- </td>
66
- </tr>
 
 
67
 
68
  <tr style="border-bottom: 1px solid #ccc;"></tr>
69
 
55
 
56
  <?php do_action ( 'trp_machine_translation_extra_settings_middle', $this->settings ); ?>
57
 
58
+ <?php if( !empty( $machine_translator->get_api_key() ) ) : ?>
59
+ <tr id="trp-test-api-key">
60
+ <th scope="row"></th>
61
+ <td>
62
+ <a href="<?php echo esc_url( admin_url( 'admin.php?page=trp_test_machine_api' ) ); ?>" class="button-secondary"><?php _e( 'Test API credentials', 'translatepress-multilingual' ); ?></a>
63
+ <p class="description">
64
+ <?php _e( 'Click here to check if the selected translation engine is configured correctly.', 'translatepress-multilingual' ) ?>
65
+ </p>
66
+ </td>
67
+ </tr>
68
+ <?php endif; ?>
69
 
70
  <tr style="border-bottom: 1px solid #ccc;"></tr>
71
 
readme.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: cozmoslabs, razvan.mo, madalin.ungureanu, 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.2.3
7
  Requires PHP: 5.6.20
8
- Stable tag: 1.5.9
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -143,6 +143,16 @@ For more information please check out [TranslatePress - Multilingual plugin docu
143
 
144
 
145
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
146
  = 1.5.9 =
147
  * Add an option to block crawlers from triggering automatic translations
148
  * Added support for excluding words from automatic translation
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.2.4
7
  Requires PHP: 5.6.20
8
+ Stable tag: 1.6.0
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
143
 
144
 
145
  == Changelog ==
146
+ = 1.6.0 =
147
+ * Gettext is no longer processed in REST API requests made from admin referer.
148
+ * Don't update gettext machine translation with empty translation.
149
+ * Fixed machine translation codes not being set on first save settings
150
+ * Solved backwards compatibility with Deepl Add-on version 1.0.0
151
+ * We now don't translate gettext into english.
152
+ * Fix: make sure we are not sending gettext non-unique array strings to Automatic Translation
153
+ * Fix: Add default translation engine if not available.
154
+ * Fix: hide Test API key button when machine translation is disabled or when there's not API key saved.
155
+
156
  = 1.5.9 =
157
  * Add an option to block crawlers from triggering automatic translations
158
  * Added support for excluding words from automatic translation