TranslatePress – Translate Multilingual sites - Version 1.5.9

Version Description

  • Add an option to block crawlers from triggering automatic translations
  • Added support for excluding words from automatic translation
  • Compatibility with WooCommerce Checkout Add-Ons plugin
  • Improved integration with WooCommerce PDF Invoices & Packing Slips by translating product name and options in invoices
  • Removed possible trp-wrap tags ending up in front-end content
  • Improved display of license error messages
  • Corrected and added missing flags for 7 languages
  • Eliminate need for jQuery in language switcher shortcode
  • Fixed issue with translating admin ajax JSON strings
  • Fixed issue with html tags breaking HTML
  • Fixed warning in when saving advanced settings
  • Fixed trpst characters in WooCommerce shipping calculator
  • Fixed getting translations on fallback admin-ajax
  • New integration with Deepl API Automatic translation in PRO versions
Download this release

Release Info

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

Code changes from version 1.5.8 to 1.5.9

Files changed (35) hide show
  1. assets/images/deepl-add-on.png +0 -0
  2. assets/images/flags/de_AT.png +0 -0
  3. assets/images/flags/fur.png +0 -0
  4. assets/images/flags/gl_ES.png +0 -0
  5. assets/images/flags/kn.png +0 -0
  6. assets/images/flags/pt_AO.png +0 -0
  7. assets/images/flags/pt_PT_ao90.png +0 -0
  8. assets/images/flags/skr.png +0 -0
  9. assets/js/trp-back-end-script.js +70 -38
  10. assets/js/trp-translate-dom-changes.js +1 -1
  11. assets/lib/simplehtmldom/simple_html_dom.php +11 -4
  12. class-translate-press.php +26 -8
  13. includes/advanced-settings/exclude-words-from-auto-translate.php +28 -0
  14. includes/class-advanced-tab.php +8 -72
  15. includes/class-language-switcher.php +2 -0
  16. includes/class-machine-translation-tab.php +129 -0
  17. includes/class-machine-translator-logger.php +72 -53
  18. includes/class-machine-translator.php +103 -90
  19. includes/class-plugin-notices.php +19 -15
  20. includes/class-settings.php +62 -52
  21. includes/class-translation-manager.php +3 -4
  22. includes/class-translation-render.php +15 -9
  23. includes/functions.php +46 -0
  24. includes/google-translate/class-google-translate-v2-machine-translator.php +108 -0
  25. includes/google-translate/functions.php +37 -0
  26. index.php +1 -1
  27. languages/translatepress-multilingual.catalog.php +31 -16
  28. languages/translatepress-multilingual.pot +169 -109
  29. partials/addons-settings-page.php +9 -1
  30. partials/language-switcher-shortcode.php +19 -12
  31. partials/machine-translation-settings-page.php +121 -0
  32. partials/main-settings-language-selector.php +1 -1
  33. partials/main-settings-page.php +0 -26
  34. partials/test-api-settings-page.php +40 -0
  35. readme.txt +18 -1
assets/images/deepl-add-on.png ADDED
Binary file
assets/images/flags/de_AT.png ADDED
Binary file
assets/images/flags/fur.png ADDED
Binary file
assets/images/flags/gl_ES.png CHANGED
Binary file
assets/images/flags/kn.png ADDED
Binary file
assets/images/flags/pt_AO.png ADDED
Binary file
assets/images/flags/pt_PT_ao90.png ADDED
Binary file
assets/images/flags/skr.png ADDED
Binary file
assets/js/trp-back-end-script.js CHANGED
@@ -150,41 +150,6 @@ jQuery( function() {
150
  this.initialize();
151
  }
152
 
153
- /*
154
- * Show Google Translate API Key only when Google Translate is active
155
- */
156
- function TRP_Field_Toggler (){
157
- var _$setting_toggled;
158
- var _$trigger_field;
159
- var _trigger_field_value_for_show;
160
-
161
- function show_hide_based_on_value( value ) {
162
- if ( value === _trigger_field_value_for_show ) {
163
- _$setting_toggled.show();
164
- } else {
165
- _$setting_toggled.hide();
166
- }
167
- }
168
-
169
- function add_event_on_change() {
170
- _$trigger_field.on('change', function () {
171
- show_hide_based_on_value( this.value );
172
- });
173
- }
174
-
175
- function init( trigger_select_id, setting_id, value_for_show ){
176
- _trigger_field_value_for_show = value_for_show;
177
- _$trigger_field = jQuery( trigger_select_id );
178
- _$setting_toggled = jQuery( setting_id ).parents('tr');
179
- show_hide_based_on_value( _$trigger_field.val() );
180
- add_event_on_change();
181
- }
182
-
183
- return {
184
- init: init
185
- };
186
- };
187
-
188
  /*
189
  * Manage adding and removing items from an option of tpe list from Advanced Settings page
190
  */
@@ -245,8 +210,40 @@ jQuery( function() {
245
  jQuery("#trp-options .warning").show('fast');
246
  });
247
 
248
- var trpGoogleTranslate = TRP_Field_Toggler();
249
- trpGoogleTranslate.init('#trp-g-translate', '#trp-g-translate-key', 'yes' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
250
 
251
  // Options of type List adding, from Advanced Settings page
252
  var trpListOptions = document.querySelectorAll( '.trp-adst-list-option' );
@@ -254,6 +251,41 @@ jQuery( function() {
254
  new TRP_Advanced_Settings_List( trpListOptions[i] );
255
  }
256
 
257
-
258
  });
259
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
  this.initialize();
151
  }
152
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
  /*
154
  * Manage adding and removing items from an option of tpe list from Advanced Settings page
155
  */
210
  jQuery("#trp-options .warning").show('fast');
211
  });
212
 
213
+ var trpGoogleTranslateKey = TRP_Field_Toggler();
214
+ trpGoogleTranslateKey.init('.trp-translation-engine', '#trp-g-translate-key', 'google_translate_v2' );
215
+
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' )
222
+ jQuery( '.trp-machine-translation-options tbody tr:not(:first-child)').hide()
223
+ else
224
+ jQuery( '.trp-machine-translation-options tbody tr:not(:first-child)').show()
225
+
226
+ if( jQuery( '#trp-machine-translation-enabled' ).val() == 'yes' )
227
+ jQuery('.trp-translation-engine:checked').trigger('change')
228
+ }
229
+
230
+ // Hide this row when DeepL upsell is showing
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()
239
+ jQuery('#trp-machine-translation-enabled').on( 'change', function(){
240
+ TRP_show_hide_machine_translation_options()
241
+ })
242
+
243
+ TRP_hide_test_api_key()
244
+ jQuery('.trp-translation-engine').on( 'change', function(){
245
+ TRP_hide_test_api_key()
246
+ })
247
 
248
  // Options of type List adding, from Advanced Settings page
249
  var trpListOptions = document.querySelectorAll( '.trp-adst-list-option' );
251
  new TRP_Advanced_Settings_List( trpListOptions[i] );
252
  }
253
 
 
254
  });
255
 
256
+ function TRP_Field_Toggler (){
257
+ var _$setting_toggled, _$trigger_field, _trigger_field_value_for_show, _trigger_field_value
258
+
259
+ function show_hide_based_on_value( value ) {
260
+ if ( value === _trigger_field_value_for_show )
261
+ _$setting_toggled.show()
262
+ else
263
+ _$setting_toggled.hide()
264
+ }
265
+
266
+ function add_event_on_change() {
267
+
268
+ _$trigger_field.on('change', function () {
269
+ show_hide_based_on_value( this.value )
270
+ })
271
+
272
+ }
273
+
274
+ function init( trigger_select_id, setting_id, value_for_show ){
275
+ _trigger_field_value_for_show = value_for_show
276
+ _$trigger_field = jQuery( trigger_select_id )
277
+ _$setting_toggled = jQuery( setting_id ).parents('tr')
278
+
279
+ if( _$trigger_field.hasClass( 'trp-radio') )
280
+ _trigger_field_value = jQuery( trigger_select_id + ':checked' ).val()
281
+ else
282
+ _trigger_field_value = _$trigger_field.val()
283
+
284
+ show_hide_based_on_value( _trigger_field_value )
285
+ add_event_on_change()
286
+ }
287
+
288
+ return {
289
+ init: init
290
+ }
291
+ }
assets/js/trp-translate-dom-changes.js CHANGED
@@ -48,7 +48,7 @@ function TRP_Translator(){
48
  }
49
  },
50
  error: function( errorThrown ){
51
- if ( url == custom_ajax_url ){
52
  _this.ajax_get_translation( nodesInfo, string_originals, wp_ajax_url, skip_machine_translation );
53
  console.log( 'Notice: TranslatePress trp-ajax request uses fall back to admin ajax.' );
54
  }else{
48
  }
49
  },
50
  error: function( errorThrown ){
51
+ if ( url == custom_ajax_url && custom_ajax_url != wp_ajax_url ){
52
  _this.ajax_get_translation( nodesInfo, string_originals, wp_ajax_url, skip_machine_translation );
53
  console.log( 'Notice: TranslatePress trp-ajax request uses fall back to admin ajax.' );
54
  }else{
assets/lib/simplehtmldom/simple_html_dom.php CHANGED
@@ -49,9 +49,16 @@ namespace TranslatePress;
49
  * TranslatePress modifications
50
  *
51
  * "TRP_" prefix was appended to all the define constants.
 
52
  * namespace TranslatePress was added.
 
53
  * MAX_FILE_SIZE has been modified from value 600000 to new value: define( 'TRP_MAX_FILE_SIZE', 100000000 );
54
  *
 
 
 
 
 
55
  */
56
 
57
  define('TRP_HDOM_TYPE_ELEMENT', 1);
@@ -148,7 +155,7 @@ class simple_html_dom_node
148
  *
149
  * @var string
150
  */
151
- public $tag = 'text';
152
 
153
  /**
154
  * List of attributes
@@ -495,7 +502,7 @@ class simple_html_dom_node
495
  if (is_object($debug_object))
496
  {
497
  $text = '';
498
- if ($this->tag == 'text')
499
  {
500
  if (!empty($this->text))
501
  {
@@ -1838,7 +1845,7 @@ class simple_html_dom
1838
  $node->nodetype = TRP_HDOM_TYPE_TEXT;
1839
  $node->_[TRP_HDOM_INFO_END] = 0;
1840
  $node->_[TRP_HDOM_INFO_TEXT] = '<'.$tag . $space[0] . $name;
1841
- $node->tag = 'text';
1842
  $this->link_nodes($node, false);
1843
  return true;
1844
  }
@@ -1846,7 +1853,7 @@ class simple_html_dom
1846
  // handle mismatch '<'
1847
  if ($this->doc[$this->pos-1]=='<') { // Attributes cannot start after opening tag
1848
  $node->nodetype = TRP_HDOM_TYPE_TEXT;
1849
- $node->tag = 'text';
1850
  $node->attr = array();
1851
  $node->_[TRP_HDOM_INFO_END] = 0;
1852
  $node->_[TRP_HDOM_INFO_TEXT] = substr($this->doc, $begin_tag_pos, $this->pos-$begin_tag_pos-1);
49
  * TranslatePress modifications
50
  *
51
  * "TRP_" prefix was appended to all the define constants.
52
+ *
53
  * namespace TranslatePress was added.
54
+ *
55
  * MAX_FILE_SIZE has been modified from value 600000 to new value: define( 'TRP_MAX_FILE_SIZE', 100000000 );
56
  *
57
+ * In class simple_html_dom_node, propery $tag has been renamed from 'text' to 'trptext'.
58
+ * Also, all other 3 occurrences of 'text' where changed to 'trptext'.
59
+ * (Reason for this change: tag <text> exists in HTML docs so we need a different reserved tag.)
60
+ * (In class-translation-render.php we use find('trptext') because of this. ).
61
+ *
62
  */
63
 
64
  define('TRP_HDOM_TYPE_ELEMENT', 1);
155
  *
156
  * @var string
157
  */
158
+ public $tag = 'trptext';
159
 
160
  /**
161
  * List of attributes
502
  if (is_object($debug_object))
503
  {
504
  $text = '';
505
+ if ($this->tag == 'trptext')
506
  {
507
  if (!empty($this->text))
508
  {
1845
  $node->nodetype = TRP_HDOM_TYPE_TEXT;
1846
  $node->_[TRP_HDOM_INFO_END] = 0;
1847
  $node->_[TRP_HDOM_INFO_TEXT] = '<'.$tag . $space[0] . $name;
1848
+ $node->tag = 'trptext';
1849
  $this->link_nodes($node, false);
1850
  return true;
1851
  }
1853
  // handle mismatch '<'
1854
  if ($this->doc[$this->pos-1]=='<') { // Attributes cannot start after opening tag
1855
  $node->nodetype = TRP_HDOM_TYPE_TEXT;
1856
+ $node->tag = 'trptext';
1857
  $node->attr = array();
1858
  $node->_[TRP_HDOM_INFO_END] = 0;
1859
  $node->_[TRP_HDOM_INFO_TEXT] = substr($this->doc, $begin_tag_pos, $this->pos-$begin_tag_pos-1);
class-translate-press.php CHANGED
@@ -50,7 +50,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.8' );
54
 
55
  wp_cache_add_non_persistent_groups(array('trp'));
56
 
@@ -99,6 +99,7 @@ class TRP_Translate_Press{
99
  require_once TRP_PLUGIN_DIR . 'includes/functions.php';
100
  require_once TRP_PLUGIN_DIR . 'assets/lib/simplehtmldom/simple_html_dom.php';
101
  require_once TRP_PLUGIN_DIR . 'includes/shortcodes.php';
 
102
  }
103
 
104
  /**
@@ -112,11 +113,13 @@ class TRP_Translate_Press{
112
  $this->advanced_tab = new TRP_Advanced_Tab($this->settings->get_settings());
113
  $this->advanced_tab->include_custom_codes();
114
 
 
 
 
115
  $this->translation_render = new TRP_Translation_Render( $this->settings->get_settings() );
116
  $this->url_converter = new TRP_Url_Converter( $this->settings->get_settings() );
117
  $this->language_switcher = new TRP_Language_Switcher( $this->settings->get_settings(), $this );
118
  $this->query = new TRP_Query( $this->settings->get_settings() );
119
- $this->machine_translator = new TRP_Machine_Translator( $this->settings->get_settings() );
120
  $this->machine_translator_logger = new TRP_Machine_Translator_Logger( $this->settings->get_settings() );
121
  $this->translation_manager = new TRP_Translation_Manager( $this->settings->get_settings() );
122
  $this->editor_api_regular_strings = new TRP_Editor_Api_Regular_Strings( $this->settings->get_settings() );
@@ -140,16 +143,17 @@ class TRP_Translate_Press{
140
  // the names of your product should match the download names in EDD exactly
141
  $trp_all_pro_addons = array(
142
  "tp-add-on-automatic-language-detection" => "Automatic User Language Detection",
143
- "tp-add-on-browse-as-other-roles" => "Browse as other Role",
144
- "tp-add-on-extra-languages" => "Multiple Languages",
145
  "tp-add-on-navigation-based-on-language" => "Navigation Based on Language",
146
- "tp-add-on-seo-pack" => "SEO Pack",
147
- "tp-add-on-translator-accounts" => "Translator Accounts",
 
148
  );
149
  $active_plugins = get_option('active_plugins');
150
  foreach ( $trp_all_pro_addons as $trp_pro_addon_folder => $trp_pro_addon_name ){
151
  foreach( $active_plugins as $active_plugin ){
152
- if( strpos( $active_plugin, $trp_pro_addon_folder.'/' ) === 0 ){
153
  $this->active_pro_addons[$trp_pro_addon_folder] = $trp_pro_addon_name;
154
  }
155
  }
@@ -174,8 +178,16 @@ class TRP_Translate_Press{
174
  $this->loader->add_action( 'admin_init', $this->advanced_tab, 'register_setting' );
175
  $this->loader->add_action( 'admin_notices', $this->advanced_tab, 'admin_notices' );
176
 
 
 
 
 
 
 
 
 
177
 
178
- $this->loader->add_action( 'wp_ajax_nopriv_trp_get_translations', $this->editor_api_regular_strings, 'get_translations' );
179
 
180
  $this->loader->add_action( 'wp_ajax_trp_get_translations_regular', $this->editor_api_regular_strings, 'get_translations' );
181
  $this->loader->add_action( 'wp_ajax_trp_save_translations_regular', $this->editor_api_regular_strings, 'save_translations' );
@@ -312,6 +324,9 @@ class TRP_Translate_Press{
312
 
313
  /* load textdomain */
314
  $this->loader->add_action( "init", $this, 'init_translation', 8 );
 
 
 
315
  }
316
 
317
  /**
@@ -334,4 +349,7 @@ class TRP_Translate_Press{
334
  load_plugin_textdomain( 'translatepress-multilingual', false, basename(dirname(__FILE__)) . '/languages/' );
335
  }
336
 
 
 
 
337
  }
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
 
99
  require_once TRP_PLUGIN_DIR . 'includes/functions.php';
100
  require_once TRP_PLUGIN_DIR . 'assets/lib/simplehtmldom/simple_html_dom.php';
101
  require_once TRP_PLUGIN_DIR . 'includes/shortcodes.php';
102
+ require_once TRP_PLUGIN_DIR . 'includes/class-machine-translation-tab.php';
103
  }
104
 
105
  /**
113
  $this->advanced_tab = new TRP_Advanced_Tab($this->settings->get_settings());
114
  $this->advanced_tab->include_custom_codes();
115
 
116
+ $this->machine_translation_tab = new TRP_Machine_Translation_Tab();
117
+ $this->machine_translation_tab->load_engines();
118
+
119
  $this->translation_render = new TRP_Translation_Render( $this->settings->get_settings() );
120
  $this->url_converter = new TRP_Url_Converter( $this->settings->get_settings() );
121
  $this->language_switcher = new TRP_Language_Switcher( $this->settings->get_settings(), $this );
122
  $this->query = new TRP_Query( $this->settings->get_settings() );
 
123
  $this->machine_translator_logger = new TRP_Machine_Translator_Logger( $this->settings->get_settings() );
124
  $this->translation_manager = new TRP_Translation_Manager( $this->settings->get_settings() );
125
  $this->editor_api_regular_strings = new TRP_Editor_Api_Regular_Strings( $this->settings->get_settings() );
143
  // the names of your product should match the download names in EDD exactly
144
  $trp_all_pro_addons = array(
145
  "tp-add-on-automatic-language-detection" => "Automatic User Language Detection",
146
+ "tp-add-on-browse-as-other-roles" => "Browse as other Role",
147
+ "tp-add-on-extra-languages" => "Multiple Languages",
148
  "tp-add-on-navigation-based-on-language" => "Navigation Based on Language",
149
+ "tp-add-on-seo-pack" => "SEO Pack",
150
+ "tp-add-on-translator-accounts" => "Translator Accounts",
151
+ "tp-add-on-deepl" => "DeepL Automatic Translation",
152
  );
153
  $active_plugins = get_option('active_plugins');
154
  foreach ( $trp_all_pro_addons as $trp_pro_addon_folder => $trp_pro_addon_name ){
155
  foreach( $active_plugins as $active_plugin ){
156
+ if( strpos( $active_plugin, $trp_pro_addon_folder.'/' ) === 0 ){
157
  $this->active_pro_addons[$trp_pro_addon_folder] = $trp_pro_addon_name;
158
  }
159
  }
178
  $this->loader->add_action( 'admin_init', $this->advanced_tab, 'register_setting' );
179
  $this->loader->add_action( 'admin_notices', $this->advanced_tab, 'admin_notices' );
180
 
181
+ //Machine Translation tab
182
+ $this->loader->add_action( 'trp_settings_tabs', $this->machine_translation_tab, 'add_tab_to_navigation', 10, 1 );
183
+ $this->loader->add_action( 'admin_menu', $this->machine_translation_tab, 'add_submenu_page' );
184
+ $this->loader->add_action( 'admin_init', $this->machine_translation_tab, 'register_setting' );
185
+ $this->loader->add_action( 'admin_notices', $this->machine_translation_tab, 'admin_notices' );
186
+
187
+ //Machine Translation Logger defaults
188
+ $this->loader->add_action( 'trp_machine_translation_sanitize_settings', $this->machine_translator_logger, 'sanitize_settings', 10, 1 );
189
 
190
+ $this->loader->add_action( 'wp_ajax_nopriv_trp_get_translations_regular', $this->editor_api_regular_strings, 'get_translations' );
191
 
192
  $this->loader->add_action( 'wp_ajax_trp_get_translations_regular', $this->editor_api_regular_strings, 'get_translations' );
193
  $this->loader->add_action( 'wp_ajax_trp_save_translations_regular', $this->editor_api_regular_strings, 'save_translations' );
324
 
325
  /* load textdomain */
326
  $this->loader->add_action( "init", $this, 'init_translation', 8 );
327
+
328
+ // machine translation
329
+ $this->loader->add_action( 'plugins_loaded', $this, 'init_machine_translation', 10 );
330
  }
331
 
332
  /**
349
  load_plugin_textdomain( 'translatepress-multilingual', false, basename(dirname(__FILE__)) . '/languages/' );
350
  }
351
 
352
+ public function init_machine_translation(){
353
+ $this->machine_translator = $this->machine_translation_tab->get_active_engine( $this->settings->get_settings() );
354
+ }
355
  }
includes/advanced-settings/exclude-words-from-auto-translate.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ add_filter( 'trp_register_advanced_settings', 'trp_register_exclude_words_from_auto_translate', 100 );
4
+ function trp_register_exclude_words_from_auto_translate( $settings_array ){
5
+ $settings_array[] = array(
6
+ 'name' => 'exclude_words_from_auto_translate',
7
+ 'type' => 'list',
8
+ 'columns' => array(
9
+ 'words' => __('String', 'translatepress-multilingual' ),
10
+ ),
11
+ 'label' => esc_html__( 'Exclude strings from automatic translation', 'translatepress-multilingual' ),
12
+ 'description' => wp_kses( __( 'Do not automatically translate these strings (ex. names, technical words...)<br>Paragraphs containing these strings will still be translated except for the specified part.', 'translatepress-multilingual' ), array( 'br' => array() ) ),
13
+ );
14
+ return $settings_array;
15
+ }
16
+
17
+
18
+ add_filter( 'trp_exclude_words_from_automatic_translation', 'trp_exclude_words_from_auto_translate' );
19
+ function trp_exclude_words_from_auto_translate( $exclude_words ){
20
+ $option = get_option( 'trp_advanced_settings', true );
21
+ $add_skip_selectors = array( );
22
+ if ( isset( $option['exclude_words_from_auto_translate'] ) && is_array( $option['exclude_words_from_auto_translate']['words'] ) ) {
23
+ $exclude_words = array_merge( $exclude_words, $option['exclude_words_from_auto_translate']['words'] );
24
+ }
25
+
26
+ return $exclude_words;
27
+ }
28
+
includes/class-advanced-tab.php CHANGED
@@ -51,7 +51,7 @@ class TRP_Advanced_Tab {
51
  settings_errors( 'trp_advanced_settings' );
52
  }
53
 
54
- /*
55
  * Sanitize settings
56
  */
57
  public function sanitize_settings( $submitted_settings ){
@@ -85,9 +85,11 @@ class TRP_Advanced_Tab {
85
  foreach ( $registered_setting['columns'] as $column => $column_name ) {
86
  $one_column = $column;
87
  $settings[ $registered_setting['name'] ][ $column ] = array();
88
- foreach ( $submitted_settings[ $registered_setting['name'] ][ $column ] as $key => $value ) {
89
- $settings[ $registered_setting['name'] ][ $column ][] = sanitize_text_field( $value );
90
- }
 
 
91
  }
92
 
93
  // remove empty rows
@@ -151,7 +153,7 @@ class TRP_Advanced_Tab {
151
  include_once(TRP_PLUGIN_DIR . 'includes/advanced-settings/show-dynamic-content-before-translation.php');
152
  include_once(TRP_PLUGIN_DIR . 'includes/advanced-settings/strip-gettext-post-content.php');
153
  include_once(TRP_PLUGIN_DIR . 'includes/advanced-settings/strip-gettext-post-meta.php');
154
- include_once(TRP_PLUGIN_DIR . 'includes/advanced-settings/machine-translation-limits.php');
155
  }
156
 
157
  /*
@@ -165,14 +167,6 @@ class TRP_Advanced_Tab {
165
  * Hooked to trp_settings_navigation_tabs
166
  */
167
  public function output_advanced_options(){
168
- if ( ! $this->machine_translator_logger ) {
169
- $trp = TRP_Translate_Press::get_trp_instance();
170
- $this->machine_translator_logger = $trp->get_component('machine_translator_logger');
171
- }
172
-
173
- $this->machine_translator_logger->maybe_reset_counter_date();
174
-
175
-
176
  $advanced_settings_array = $this->get_settings();
177
  foreach( $advanced_settings_array as $setting ){
178
  switch( $setting['type'] ){
@@ -194,15 +188,6 @@ class TRP_Advanced_Tab {
194
  case 'list':
195
  echo $this->add_to_list_setting( $setting );
196
  break;
197
- case 'machine_translation_counter':
198
- echo $this->machine_translation_counter( $setting );
199
- break;
200
- case 'machine_translation_counter_date':
201
- echo $this->machine_translation_counter_date( $setting );
202
- break;
203
- case 'machine_translation_trigger_quota_notification':
204
- echo $this->storage( $setting );
205
- break;
206
  }
207
  }
208
  }
@@ -365,53 +350,4 @@ class TRP_Advanced_Tab {
365
  </tr>";
366
  return apply_filters( 'trp_advanced_setting_list', $html );
367
  }
368
-
369
- /**
370
- * Return HTML of a machine_translation_counter type setting
371
- *
372
- * @param $setting
373
- *
374
- * @return 'string'
375
- */
376
- public function machine_translation_counter( $setting ){
377
- $option = get_option( 'trp_advanced_settings', true );
378
- if(isset($option['machine_translation_counter'])){
379
- $counter = $option['machine_translation_counter'];
380
- } else {
381
- $counter = '0';
382
- }
383
-
384
- $html = "
385
- <tr>
386
- <th scope='row'>{$setting['label']}</th>
387
- <td>{$counter}</td>
388
- </tr>";
389
-
390
- return apply_filters( 'trp_advanced_setting_machine_translation_counter', $html );
391
- }
392
-
393
- /**
394
- * Return HTML of a machine_translation_counter_date type setting
395
- *
396
- * @param $setting
397
- *
398
- * @return 'string'
399
- */
400
- public function machine_translation_counter_date( $setting ){
401
- $option = get_option( 'trp_advanced_settings', true );
402
-
403
- if(isset($option['machine_translation_counter_date'])){
404
- $date = $option['machine_translation_counter_date'];
405
- } else {
406
- $date = date('Y-m-d');
407
- }
408
-
409
- $html = "
410
- <tr>
411
- <th scope='row'>{$setting['label']}</th>
412
- <td>{$date}</td>
413
- </tr>";
414
-
415
- return apply_filters( 'trp_advanced_setting_list', $html );
416
- }
417
- }
51
  settings_errors( 'trp_advanced_settings' );
52
  }
53
 
54
+ /**
55
  * Sanitize settings
56
  */
57
  public function sanitize_settings( $submitted_settings ){
85
  foreach ( $registered_setting['columns'] as $column => $column_name ) {
86
  $one_column = $column;
87
  $settings[ $registered_setting['name'] ][ $column ] = array();
88
+ if ( isset($submitted_settings[ $registered_setting['name'] ][ $column ] ) ) {
89
+ foreach ($submitted_settings[$registered_setting['name']][$column] as $key => $value) {
90
+ $settings[$registered_setting['name']][$column][] = sanitize_text_field($value);
91
+ }
92
+ }
93
  }
94
 
95
  // remove empty rows
153
  include_once(TRP_PLUGIN_DIR . 'includes/advanced-settings/show-dynamic-content-before-translation.php');
154
  include_once(TRP_PLUGIN_DIR . 'includes/advanced-settings/strip-gettext-post-content.php');
155
  include_once(TRP_PLUGIN_DIR . 'includes/advanced-settings/strip-gettext-post-meta.php');
156
+ include_once(TRP_PLUGIN_DIR . 'includes/advanced-settings/exclude-words-from-auto-translate.php');
157
  }
158
 
159
  /*
167
  * Hooked to trp_settings_navigation_tabs
168
  */
169
  public function output_advanced_options(){
 
 
 
 
 
 
 
 
170
  $advanced_settings_array = $this->get_settings();
171
  foreach( $advanced_settings_array as $setting ){
172
  switch( $setting['type'] ){
188
  case 'list':
189
  echo $this->add_to_list_setting( $setting );
190
  break;
 
 
 
 
 
 
 
 
 
191
  }
192
  }
193
  }
350
  </tr>";
351
  return apply_filters( 'trp_advanced_setting_list', $html );
352
  }
353
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-language-switcher.php CHANGED
@@ -134,6 +134,8 @@ class TRP_Language_Switcher{
134
  $other_languages[$code] = $name;
135
  }
136
  }
 
 
137
 
138
  if( ! $this->trp_settings_object ) {
139
  $trp = TRP_Translate_Press::get_trp_instance();
134
  $other_languages[$code] = $name;
135
  }
136
  }
137
+ $current_language = apply_filters('trp_ls_shortcode_current_language', $current_language, $published_languages, $TRP_LANGUAGE, $this->settings);
138
+ $other_languages = apply_filters('trp_ls_shortcode_other_languages', $other_languages, $published_languages, $TRP_LANGUAGE, $this->settings);
139
 
140
  if( ! $this->trp_settings_object ) {
141
  $trp = TRP_Translate_Press::get_trp_instance();
includes/class-machine-translation-tab.php ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class TRP_Machine_Translation_Tab {
4
+
5
+ private $settings;
6
+
7
+ public function __construct() {
8
+
9
+ $settings = get_option( 'trp_machine_translation_settings', false );
10
+
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 );
18
+
19
+ }
20
+
21
+ /*
22
+ * Add new tab to TP settings
23
+ *
24
+ * Hooked to trp_settings_tabs
25
+ */
26
+ public function add_tab_to_navigation( $tabs ){
27
+ $tab = array(
28
+ 'name' => __( 'Automatic Translation', 'translatepress-multilingual' ),
29
+ 'url' => admin_url( 'admin.php?page=trp_machine_translation' ),
30
+ 'page' => 'trp_machine_translation'
31
+ );
32
+
33
+ array_splice( $tabs, 2, 0, array( $tab ) );
34
+
35
+ return $tabs;
36
+ }
37
+
38
+ /*
39
+ * Add submenu for advanced page tab
40
+ *
41
+ * Hooked to admin_menu
42
+ */
43
+ public function add_submenu_page() {
44
+ add_submenu_page( 'TRPHidden', 'TranslatePress Automatic Translation', 'TRPHidden', 'manage_options', 'trp_machine_translation', array( $this, 'machine_translation_page_content' ) );
45
+ add_submenu_page( 'TRPHidden', 'TranslatePress Test Automatic Translation API', 'TRPHidden', 'manage_options', 'trp_test_machine_api', array( $this, 'test_api_page_content' ) );
46
+ }
47
+
48
+ /**
49
+ * Register setting
50
+ *
51
+ * Hooked to admin_init
52
+ */
53
+ public function register_setting(){
54
+ register_setting( 'trp_machine_translation_settings', 'trp_machine_translation_settings', array( $this, 'sanitize_settings' ) );
55
+ }
56
+
57
+ /**
58
+ * Output admin notices after saving settings.
59
+ */
60
+ public function admin_notices(){
61
+ if( isset( $_GET['page'] ) && $_GET['page'] == 'trp_machine_translation' )
62
+ settings_errors();
63
+ }
64
+
65
+ /*
66
+ * Sanitize settings
67
+ */
68
+ public function sanitize_settings( $settings ){
69
+ if( !empty( $settings['machine-translation'] ) )
70
+ $settings['machine-translation'] = sanitize_text_field( $settings['machine-translation'] );
71
+ else
72
+ $settings['machine-translation'] = 'no';
73
+
74
+ $trp = TRP_Translate_Press::get_trp_instance();
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 );
81
+ }
82
+
83
+ /*
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
+
97
+ /**
98
+ * Test selected API functionality
99
+ */
100
+ public function test_api_page_content(){
101
+ require_once TRP_PLUGIN_DIR . 'partials/test-api-settings-page.php';
102
+ }
103
+
104
+ public function load_engines(){
105
+ include_once TRP_PLUGIN_DIR . 'includes/google-translate/functions.php';
106
+ include_once TRP_PLUGIN_DIR . 'includes/google-translate/class-google-translate-v2-machine-translator.php';
107
+ }
108
+
109
+ public function get_active_engine( $settings ){
110
+ $default = 'TRP_Google_Translate_V2_Machine_Translator';
111
+
112
+ if( empty( $settings['translation-engine'] ) )
113
+ $value = $default;
114
+ else {
115
+ $value = 'TRP_' . ucwords( $settings['translation-engine'] ) . '_Machine_Translator'; // class name needs to follow this pattern
116
+
117
+ if( !class_exists( $value ) )
118
+ $value = $default;
119
+ }
120
+
121
+ return new $value( $settings );
122
+ }
123
+
124
+ public function translation_engines_upsell( $engines ){
125
+ $engines[] = array( 'value' => 'deepl_upsell', 'label' => __( 'DeepL', 'translatepress-multilingual' ) );
126
+
127
+ return $engines;
128
+ }
129
+ }
includes/class-machine-translator-logger.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
- class TRP_Machine_Translator_Logger
3
- {
4
  protected $settings;
5
  protected $query;
6
  protected $url_converter;
@@ -14,47 +14,42 @@ class TRP_Machine_Translator_Logger
14
  * @param array $settings Settings option.
15
  */
16
  public function __construct( $settings ){
17
- $this->settings = $settings;
18
- $this->counter = intval($this->get_advanced_sub_option('machine_translation_counter', 0));
19
- $this->counter_date = $this->get_advanced_sub_option('machine_translation_counter_date', date ("Y-m-d" ));
20
- $this->limit = intval($this->get_advanced_sub_option('machine_translation_limit', 1000000));
21
  // if a new day has passed, update the counter and date
22
  $this->maybe_reset_counter_date();
23
  }
24
 
25
- public function log($args = array()){
 
 
26
 
27
- if ( ! $this->query ) {
28
- $trp = TRP_Translate_Press::get_trp_instance();
29
  $this->query = $trp->get_component('query');
30
- }
31
 
32
- if ( ! $this->url_converter ) {
33
- $trp = TRP_Translate_Press::get_trp_instance();
34
  $this->url_converter = $trp->get_component('url_converter');
35
- }
36
 
37
- if(empty($args)){
38
  return false;
39
- }
40
 
41
- if( $this->get_advanced_sub_option('machine_translation_log', false) !== 'yes' ){
42
  return false;
43
- }
44
 
45
- if( !$this->query->check_machine_translation_log_table() ){
46
  return false;
47
- }
48
 
49
  // expected structure.
50
  $log = array(
51
- 'url' => $this->url_converter->cur_page_url(),
52
- 'strings' => $args['strings'],
53
- 'characters' => $this->count(unserialize($args['strings'])),
54
- 'response' => $args['response'],
55
  'lang_source' => $args['lang_source'],
56
  'lang_target' => $args['lang_target'],
57
- 'timestamp' => date ("Y-m-d H:i:s" )
58
  );
59
 
60
  $table_name = $this->query->db->prefix . 'trp_machine_translation_log';
@@ -64,28 +59,27 @@ class TRP_Machine_Translator_Logger
64
  $prepared_query = $this->query->db->prepare( $query, $log );
65
  $this->query->db->get_results( $prepared_query, OBJECT_K );
66
 
67
- if ($this->query->db->last_error !== '') {
68
  return false;
69
- }
70
  return true;
71
  }
72
 
73
  private function count($strings){
74
- if(!is_array($strings)){
75
  return 0;
76
- }
77
 
78
  $char_number = 0;
79
- foreach($strings as $string){
80
  $char_number += strlen($string);
81
- }
82
 
83
  return $char_number;
84
  }
85
 
86
  public function count_towards_quota($strings){
87
  $this->counter += $this->count($strings);
88
- $this->update_advanced_sub_option('machine_translation_counter', $this->counter);
 
89
 
90
  return $this->counter;
91
  }
@@ -100,43 +94,68 @@ class TRP_Machine_Translator_Logger
100
  }
101
 
102
  // we've exceeded our daily quota
103
- $this->update_advanced_sub_option('machine_translation_trigger_quota_notification' , true );
 
104
  return true;
105
  }
106
 
107
  public function maybe_reset_counter_date(){
108
  $some = 'else';
109
 
110
- if ($this->counter_date === date ("Y-m-d" ))
111
- {
112
- // the day has not passed
113
  return false;
114
- } else {
 
115
  // there is a new day
116
- $this->update_advanced_sub_option('machine_translation_counter_date' , date ("Y-m-d" ) );
 
 
 
117
  // clear the counter
118
- $this->update_advanced_sub_option('machine_translation_counter' , 0 );
 
 
 
119
  // clear the notification
120
- $this->update_advanced_sub_option('machine_translation_trigger_quota_notification' , false );
 
 
 
 
 
 
 
 
121
 
122
- return true;
123
- }
124
  }
125
 
126
- private function get_advanced_sub_option($option_name, $default){
127
 
128
- if( isset($this->settings['advanced_settings'][$option_name]) )
129
- {
130
- return $this->settings['advanced_settings'][$option_name];
131
- } else {
132
- return $default;
 
 
 
 
 
133
  }
 
 
134
  }
135
 
136
- private function update_advanced_sub_option($option_name, $value){
137
- // update TP settings instance
138
- $this->settings['advanced_settings'][$option_name] = $value;
139
- // update in the database as well
140
- update_option('trp_advanced_settings', $this->settings['advanced_settings']);
 
 
 
 
 
141
  }
142
- }
1
  <?php
2
+
3
+ class TRP_Machine_Translator_Logger {
4
  protected $settings;
5
  protected $query;
6
  protected $url_converter;
14
  * @param array $settings Settings option.
15
  */
16
  public function __construct( $settings ){
17
+ $this->settings = $settings;
18
+ $this->counter = intval( $this->get_option('machine_translation_counter', 0) );
19
+ $this->counter_date = $this->get_option('machine_translation_counter_date', date ("Y-m-d" ));
20
+ $this->limit = intval( $this->get_option('machine_translation_limit', 1000000) );
21
  // if a new day has passed, update the counter and date
22
  $this->maybe_reset_counter_date();
23
  }
24
 
25
+ public function log( $args = array() ){
26
+
27
+ $trp = TRP_Translate_Press::get_trp_instance();
28
 
29
+ if ( ! $this->query )
 
30
  $this->query = $trp->get_component('query');
 
31
 
32
+ if ( ! $this->url_converter )
 
33
  $this->url_converter = $trp->get_component('url_converter');
 
34
 
35
+ if( empty($args) )
36
  return false;
 
37
 
38
+ if( $this->get_option('machine_translation_log', false) !== 'yes' )
39
  return false;
 
40
 
41
+ if( !$this->query->check_machine_translation_log_table() )
42
  return false;
 
43
 
44
  // expected structure.
45
  $log = array(
46
+ 'url' => $this->url_converter->cur_page_url(),
47
+ 'strings' => $args['strings'],
48
+ 'characters' => $this->count(unserialize($args['strings'])),
49
+ 'response' => $args['response'],
50
  'lang_source' => $args['lang_source'],
51
  'lang_target' => $args['lang_target'],
52
+ 'timestamp' => date ("Y-m-d H:i:s" )
53
  );
54
 
55
  $table_name = $this->query->db->prefix . 'trp_machine_translation_log';
59
  $prepared_query = $this->query->db->prepare( $query, $log );
60
  $this->query->db->get_results( $prepared_query, OBJECT_K );
61
 
62
+ if ( $this->query->db->last_error !== '' )
63
  return false;
64
+
65
  return true;
66
  }
67
 
68
  private function count($strings){
69
+ if( !is_array($strings) )
70
  return 0;
 
71
 
72
  $char_number = 0;
73
+ foreach($strings as $string)
74
  $char_number += strlen($string);
 
75
 
76
  return $char_number;
77
  }
78
 
79
  public function count_towards_quota($strings){
80
  $this->counter += $this->count($strings);
81
+
82
+ $this->update_options( array( array( 'name' => 'machine_translation_counter', 'value' => $this->counter ) ) );
83
 
84
  return $this->counter;
85
  }
94
  }
95
 
96
  // we've exceeded our daily quota
97
+ $this->update_options( array( array( 'name' => 'machine_translation_trigger_quota_notification', 'value' => true ) ) );
98
+
99
  return true;
100
  }
101
 
102
  public function maybe_reset_counter_date(){
103
  $some = 'else';
104
 
105
+ // if the day has not passed
106
+ if ( $this->counter_date === date ( "Y-m-d" ) )
 
107
  return false;
108
+
109
+ $options = array(
110
  // there is a new day
111
+ array(
112
+ 'name' => 'machine_translation_counter_date',
113
+ 'value' => date( "Y-m-d" ),
114
+ ),
115
  // clear the counter
116
+ array(
117
+ 'name' => 'machine_translation_counter',
118
+ 'value' => 0,
119
+ ),
120
  // clear the notification
121
+ array(
122
+ 'name' => 'machine_translation_trigger_quota_notification',
123
+ 'value' => false,
124
+ ),
125
+ );
126
+
127
+ $this->update_options( $options );
128
+
129
+ return true;
130
 
 
 
131
  }
132
 
133
+ private function get_option($option_name, $default){
134
 
135
+ return isset( $this->settings[$option_name] ) ? $this->settings[$option_name] : $default;
136
+
137
+ }
138
+
139
+ private function update_options( $options ){
140
+ $machine_translation_settings = get_option( 'trp_machine_translation_settings', array() );
141
+
142
+ foreach( $options as $option ){
143
+ $this->settings[$option['name']] = $option['value'];
144
+ $machine_translation_settings[$option['name']] = $option['value'];
145
  }
146
+
147
+ update_option( 'trp_machine_translation_settings', $machine_translation_settings );
148
  }
149
 
150
+ public function sanitize_settings( $settings ){
151
+ $machine_translation_settings = get_option( 'trp_machine_translation_settings', array() );
152
+
153
+ if( isset( $machine_translation_settings['machine_translation_counter'] ) )
154
+ $settings['machine_translation_counter'] = $machine_translation_settings['machine_translation_counter'];
155
+
156
+ if( isset( $machine_translation_settings['machine_translation_counter_date'] ) )
157
+ $settings['machine_translation_counter_date'] = $machine_translation_settings['machine_translation_counter_date'];
158
+
159
+ return $settings;
160
  }
161
+ }
includes/class-machine-translator.php CHANGED
@@ -5,7 +5,7 @@
5
  *
6
  * Facilitates Machine Translation calls
7
  */
8
- class TRP_Machine_Translator{
9
  protected $settings;
10
  protected $referer;
11
  protected $url_converter;
@@ -17,22 +17,27 @@ class TRP_Machine_Translator{
17
  */
18
  public function __construct( $settings ){
19
  $this->settings = $settings;
 
 
 
 
 
20
  }
21
 
22
  /**
23
  * Whether automatic translation is available.
24
  *
25
- * @return bool function that determines if the automatic translation is enabled
26
  */
27
  public function is_available(){
28
- if( !empty( $this->settings['g-translate'] ) && $this->settings['g-translate'] == 'yes' )
29
  return true;
30
  else
31
  return false;
32
  }
33
 
34
  /**
35
- * Return referer to be sent in Google Translation request header
36
  *
37
  * @return string
38
  */
@@ -42,107 +47,115 @@ class TRP_Machine_Translator{
42
  $trp = TRP_Translate_Press::get_trp_instance();
43
  $this->url_converter = $trp->get_component( 'url_converter' );
44
  }
 
45
  $this->referer = $this->url_converter->get_abs_home();
46
  }
 
47
  return $this->referer;
48
  }
49
 
50
- /**
51
- * Send request to Google Translation API
52
- *
53
- * @param string $source_language Translate from language
54
- * @param string $language_code Translate to language
55
- * @param array $strings_array Array of string to translate
56
- *
57
- * @return array|WP_Error Response
58
- */
59
- public function send_request( $source_language, $language_code, $strings_array ){
60
- /* build our translation request */
61
- $translation_request = 'key='.$this->settings['g-translate-key'];
62
- $translation_request .= '&source='.$source_language;
63
- $translation_request .= '&target='.$language_code;
64
- foreach( $strings_array as $new_string ){
65
- $translation_request .= '&q='.rawurlencode(html_entity_decode( $new_string, ENT_QUOTES ));
66
- }
67
- $referer = $this->get_referer();
68
-
69
- /* Due to url length restrictions we need so send a POST request faked as a GET request and send the strings in the body of the request and not in the URL */
70
- $response = wp_remote_post( "https://www.googleapis.com/language/translate/v2", array(
71
- 'headers' => array(
72
- 'X-HTTP-Method-Override' => 'GET', //this fakes a GET request
73
- 'Referer' => $referer
74
- ),
75
- 'body' => $translation_request,
76
- )
77
- );
78
- return $response;
79
- }
80
 
81
  /**
82
- * Returns an array with the API provided translations of the $new_strings array.
83
  *
84
- * @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
85
- * @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
86
- * @return array array with the translation strings and the preserved keys or an empty array if something went wrong
87
  */
88
- public function translate_array( $new_strings, $trp_language_code ){
89
- /* we need these settings to go on */
90
- $language_code = $this->settings['google-translate-codes'][$trp_language_code];
91
- $source_language = $this->settings['google-translate-codes'][$this->settings['default-language']];
92
- if( empty( $this->settings['g-translate-key'] ) || empty( $this->settings['google-translate-codes'][$this->settings['default-language']] ) || empty( $language_code ) || ( $language_code == $source_language ) ) {
93
- return array();
94
- }
95
 
96
- $translated_strings = array();
97
 
98
- if ( ! $this->machine_translator_logger ) {
99
- $trp = TRP_Translate_Press::get_trp_instance();
100
- $this->machine_translator_logger = $trp->get_component('machine_translator_logger');
 
 
 
 
101
  }
 
 
102
 
103
- // if character quote expired we don't send strings for automatic translation.
104
- if( !empty( $new_strings ) && !$this->machine_translator_logger->quota_exceeded() ){
105
- /* split our strings that need translation in chunks of maximum 128 strings because Google Translate has a limit of 128 strings */
106
- $new_strings_chunks = array_chunk( $new_strings, 128, true );
107
- /* if there are more than 128 strings we make multiple requests */
108
- foreach( $new_strings_chunks as $new_strings_chunk ){
109
- $response = $this->send_request( $source_language, $language_code, $new_strings_chunk );
110
-
111
- // this is run only if "Log machine translation queries." is set to Yes.
112
- $this->machine_translator_logger->log(array(
113
- 'strings' => serialize( $new_strings_chunk),
114
- 'response' => serialize( $response ),
115
- 'lang_source' => $source_language,
116
- 'lang_target' => $language_code,
117
- ));
118
-
119
- /* analyze the response */
120
- if ( is_array( $response ) && ! is_wp_error( $response ) ) {
121
-
122
- $this->machine_translator_logger->count_towards_quota( $new_strings_chunk );
123
-
124
- /* decode it */
125
- $translation_response = json_decode( $response['body'] );
126
- if( !empty( $translation_response->error ) ){
127
- return array(); // return an empty array if we encountered an error. This means we don't store any translation in the DB
128
- }
129
- else{
130
- /* if we have strings build the translation strings array and make sure we keep the original keys from $new_string */
131
- $translations = $translation_response->data->translations;
132
- $i = 0;
133
- foreach( $new_strings_chunk as $key => $old_string ){
134
- if( !empty( $translations[$i]->translatedText ) ) {
135
- $translated_strings[$key] = $translations[$i]->translatedText;
136
- }
137
- $i++;
138
- }
139
- }
140
- }
141
 
 
 
 
 
142
  }
 
 
 
143
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
 
145
- // will have the same indexes as $new_string or it will be an empty array if something went wrong
146
- return $translated_strings;
147
  }
148
- }
5
  *
6
  * Facilitates Machine Translation calls
7
  */
8
+ abstract class TRP_Machine_Translator {
9
  protected $settings;
10
  protected $referer;
11
  protected $url_converter;
17
  */
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
  /**
28
  * Whether automatic translation is available.
29
  *
30
+ * @return bool
31
  */
32
  public function is_available(){
33
+ if( !empty( $this->settings['machine-translation'] ) && $this->settings['machine-translation'] == 'yes' )
34
  return true;
35
  else
36
  return false;
37
  }
38
 
39
  /**
40
+ * Return site referer
41
  *
42
  * @return string
43
  */
47
  $trp = TRP_Translate_Press::get_trp_instance();
48
  $this->url_converter = $trp->get_component( 'url_converter' );
49
  }
50
+
51
  $this->referer = $this->url_converter->get_abs_home();
52
  }
53
+
54
  return $this->referer;
55
  }
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
62
+ */
63
+ public function verify_request( $to_language ){
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
+
71
+ // Method that can be extended in the child class to add extra validation
72
+ if( !$this->extra_request_validations( $to_language ) )
73
+ return false;
74
+
75
+ // Check if crawlers are blocked
76
+ if( !empty( $this->settings['block-crawlers'] ) && $this->settings['block-crawlers'] == 'yes' && $this->is_crawler() )
77
+ return false;
78
+
79
+ // Check if daily quota is met
80
+ if( $this->machine_translator_logger->quota_exceeded() )
81
+ return false;
82
+
83
+ return true;
84
+
85
+ }
 
86
 
87
  /**
88
+ * Verifies user agent to check if the request is being made by a crawler
89
  *
90
+ * @return boolean
 
 
91
  */
92
+ private function is_crawler(){
93
+ if( !isset( $_SERVER['HTTP_USER_AGENT'] ) )
94
+ return false;
 
 
 
 
95
 
96
+ $crawlers = apply_filters( 'trp_machine_translator_crawlers', 'rambler|abacho|acoi|accona|aspseek|altavista|estyle|scrubby|lycos|geona|ia_archiver|alexa|sogou|skype|facebook|twitter|pinterest|linkedin|naver|bing|google|yahoo|duckduckgo|yandex|baidu|teoma|xing|java\/1.7.0_45|bot|crawl|slurp|spider|mediapartners|\sask\s|\saol\s' );
97
 
98
+ return preg_match( '/'. $crawlers .'/i', $_SERVER['HTTP_USER_AGENT'] );
99
+ }
100
+
101
+ private function get_placeholders( $count ){
102
+ $placeholders = array();
103
+ for( $i = 1 ; $i <= $count; $i++ ){
104
+ $placeholders[] = '1TP' . $i;
105
  }
106
+ return $placeholders;
107
+ }
108
 
109
+ /**
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('%', '$', '#'));
121
+ $placeholders = $this->get_placeholders(count($trp_exclude_words_from_automatic_translation));
122
+
123
+ foreach ($strings as $key => $string) {
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) {
131
+ $machine_strings[$key] = str_ireplace( $placeholders, $trp_exclude_words_from_automatic_translation, $machine_string );
132
+ }
133
  }
134
+ return $machine_strings;
135
+ }else {
136
+ return array();
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
+
154
+ public function get_api_key(){
155
+ return false;
156
+ }
157
 
158
+ public function extra_request_validations( $to_language ){
159
+ return true;
160
  }
161
+ }
includes/class-plugin-notices.php CHANGED
@@ -42,7 +42,7 @@ class TRP_Add_General_Notices{
42
  if ( current_user_can( 'manage_options' ) ){
43
  // Check that the user hasn't already clicked to ignore the message
44
  if ( ! get_user_meta($user_id, $this->notificationId.'_dismiss_notification' ) || $this->force_show ) {//ignore the dismissal if we have force_show
45
- echo $finalMessage = wp_kses( apply_filters($this->notificationId.'_notification_message','<div class="'. $this->notificationClass .'" >'.$this->notificationMessage.'</div>', $this->notificationMessage), [ 'div' => [ 'class' => [] ], 'p' => ['style' => [], 'class' => []], 'a' => ['href' => [], 'type'=> [], 'class'=> []], 'span' => ['class'=> []] ] );
46
  }
47
  do_action( $this->notificationId.'_notification_displayed', $current_user, $pagenow );
48
  }
@@ -70,7 +70,7 @@ Class TRP_Plugin_Notifications {
70
  private static $_instance = null;
71
  private $prefix = 'trp';
72
  private $menu_slug = 'options-general.php';
73
- public $pluginPages = array( 'translate-press', 'trp_addons_page', 'trp_license_key', 'trp_advanced_page' );
74
 
75
  protected function __construct() {
76
  add_action( 'admin_init', array( $this, 'dismiss_admin_notifications' ), 200 );
@@ -168,7 +168,6 @@ Class TRP_Plugin_Notifications {
168
 
169
  global $current_user;
170
 
171
-
172
  /**
173
  * added a $show_in_all_backend argument in version 1.4.6 that allows some notifications to be displayed on all the pages not just the plugin pages
174
  * we needed it for license notifications
@@ -347,11 +346,16 @@ class TRP_Trigger_Plugin_Notifications{
347
 
348
  /* this must be unique */
349
  $notification_id = 'trp_invalid_license';
 
350
  $message = '<p style="padding-right:30px;">';
351
- if( $license_detail->error == 'missing' )
352
- $message .= '<p>'. sprintf( __('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' ), "<a href='". admin_url('/admin.php?page=trp_license_key') ."'>", "</a>", "<a href='https://translatepress.com/pricing/?utm_source=TP&utm_medium=dashboard&utm_campaign=TP-SN-Purchase' target='_blank' class='button-primary'>", "</a>" ).'</p>';
353
- elseif($license_detail->error == 'expired')
354
- $message .= '<p>'. sprintf( __('Your <strong>TranslatePress</strong> license has expired. <br/>Please %1$sRenew Your Licence%2$s to continue receiving access to product downloads, automatic updates and support. %3$sRenew now %4$s' , 'translatepress-multilingual' ), "<a href='https://www.translatepress.com/account/?utm_source=TP&utm_medium=dashboard&utm_campaign=TP-Renewal' target='_blank'>", "</a>", "<a href='https://www.translatepress.com/account/?utm_source=TP&utm_medium=dashboard&utm_campaign=TP-Renewal' target='_blank' class='button-primary'>", "</a>" ). '</p>';
 
 
 
 
355
  $message .= '</p>';
356
 
357
  if( !$notifications->is_plugin_page() ) {
@@ -399,22 +403,22 @@ class TRP_Trigger_Plugin_Notifications{
399
  *
400
  */
401
  $trp = TRP_Translate_Press::get_trp_instance();
402
- if ( ! $this->settings_obj ){
403
  $this->settings_obj = $trp->get_component( 'settings' );
404
- }
405
 
406
- if ( ! $this->machine_translator_logger ){
407
  $this->machine_translator_logger = $trp->get_component( 'machine_translator_logger' );
408
- }
409
 
410
- $gtranslate = $this->settings_obj->get_setting('g-translate', 'no');
411
 
412
- if( 'yes' === $gtranslate && $this->machine_translator_logger->quota_exceeded() ) {
413
  /* this must be unique */
414
  $notification_id = 'trp_machine_translation_quota_exceeded_'. date('Ymd');
415
 
416
  $message = '<img style="float: left; margin: 10px 12px 10px 0; max-width: 80px;" src="' . TRP_PLUGIN_URL . 'assets/images/get_param_addon.jpg" />';
417
- $message .= '<p style="margin-top: 16px;padding-right:30px;">' . esc_html__('The daily quota for machine translation characters exceeded. Please check the TranslatePress -> Settings -> Advanced Settings for more information.', 'translatepress-multilingual') . '</p>';
 
 
418
  //make sure to use the trp_dismiss_admin_notification arg
419
  $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>';
420
 
@@ -423,4 +427,4 @@ class TRP_Trigger_Plugin_Notifications{
423
 
424
  }
425
 
426
- }
42
  if ( current_user_can( 'manage_options' ) ){
43
  // Check that the user hasn't already clicked to ignore the message
44
  if ( ! get_user_meta($user_id, $this->notificationId.'_dismiss_notification' ) || $this->force_show ) {//ignore the dismissal if we have force_show
45
+ echo $finalMessage = wp_kses( apply_filters($this->notificationId.'_notification_message','<div class="'. $this->notificationClass .'" >'.$this->notificationMessage.'</div>', $this->notificationMessage), [ 'div' => [ 'class' => [] ], 'p' => ['style' => [], 'class' => []], 'a' => ['href' => [], 'type'=> [], 'class'=> []], 'span' => ['class'=> []], 'strong' => [] ] );
46
  }
47
  do_action( $this->notificationId.'_notification_displayed', $current_user, $pagenow );
48
  }
70
  private static $_instance = null;
71
  private $prefix = 'trp';
72
  private $menu_slug = 'options-general.php';
73
+ public $pluginPages = array( 'translate-press', 'trp_addons_page', 'trp_license_key', 'trp_advanced_page', 'trp_machine_translation', 'trp_test_machine_api' );
74
 
75
  protected function __construct() {
76
  add_action( 'admin_init', array( $this, 'dismiss_admin_notifications' ), 200 );
168
 
169
  global $current_user;
170
 
 
171
  /**
172
  * added a $show_in_all_backend argument in version 1.4.6 that allows some notifications to be displayed on all the pages not just the plugin pages
173
  * we needed it for license notifications
346
 
347
  /* this must be unique */
348
  $notification_id = 'trp_invalid_license';
349
+
350
  $message = '<p style="padding-right:30px;">';
351
+
352
+ if( $license_detail->error == 'missing' )
353
+ $message .= '<p>'. sprintf( __('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' ), "<a href='". admin_url('/admin.php?page=trp_license_key') ."'>", "</a>", "<a href='https://translatepress.com/pricing/?utm_source=TP&utm_medium=dashboard&utm_campaign=TP-SN-Purchase' target='_blank' class='button-primary'>", "</a>" ).'</p>';
354
+ elseif( $license_detail->error == 'expired' )
355
+ $message .= '<p>'. sprintf( __('Your <strong>TranslatePress</strong> license has expired. <br/>Please %1$sRenew Your Licence%2$s to continue receiving access to product downloads, automatic updates and support. %3$sRenew now %4$s' , 'translatepress-multilingual' ), "<a href='https://www.translatepress.com/account/?utm_source=TP&utm_medium=dashboard&utm_campaign=TP-Renewal' target='_blank'>", "</a>", "<a href='https://www.translatepress.com/account/?utm_source=TP&utm_medium=dashboard&utm_campaign=TP-Renewal' target='_blank' class='button-primary'>", "</a>" ). '</p>';
356
+ else
357
+ $message .= '<p>' . __( 'Something went wrong, please try again.', 'translatepress-multilingual' ) . '</p>';
358
+
359
  $message .= '</p>';
360
 
361
  if( !$notifications->is_plugin_page() ) {
403
  *
404
  */
405
  $trp = TRP_Translate_Press::get_trp_instance();
406
+ if ( ! $this->settings_obj )
407
  $this->settings_obj = $trp->get_component( 'settings' );
 
408
 
409
+ if ( ! $this->machine_translator_logger )
410
  $this->machine_translator_logger = $trp->get_component( 'machine_translator_logger' );
 
411
 
412
+ $machine_translation_enabled = $this->settings_obj->get_setting('machine-translation', 'no');
413
 
414
+ if( 'yes' === $machine_translation_enabled && $this->machine_translator_logger->quota_exceeded() ) {
415
  /* this must be unique */
416
  $notification_id = 'trp_machine_translation_quota_exceeded_'. date('Ymd');
417
 
418
  $message = '<img style="float: left; margin: 10px 12px 10px 0; max-width: 80px;" src="' . TRP_PLUGIN_URL . 'assets/images/get_param_addon.jpg" />';
419
+ $message .= '<p style="margin-top: 16px;padding-right:30px;">';
420
+ $message .= sprintf( __( 'The daily quota for machine translation characters exceeded. Please check the <strong>TranslatePress -> Settings -> <a href="%s">Machine Translation</a></strong> page for more information.', 'translatepress-multilingual' ), admin_url( 'admin.php?page=trp_machine_translation' ) );
421
+ $message .= '</p>';
422
  //make sure to use the trp_dismiss_admin_notification arg
423
  $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>';
424
 
427
 
428
  }
429
 
430
+ }
includes/class-settings.php CHANGED
@@ -76,10 +76,10 @@ class TRP_Settings{
76
  }
77
 
78
  /**
79
- * Returns settings_option.
80
- *
81
- * @return array Settings option.
82
- */
83
  public function get_settings(){
84
  if ( $this->settings == null ){
85
  $this->set_options();
@@ -110,23 +110,21 @@ class TRP_Settings{
110
  */
111
  public function register_menu_page(){
112
  add_options_page( 'TranslatePress', 'TranslatePress', apply_filters( 'trp_settings_capability', 'manage_options' ), 'translate-press', array( $this, 'settings_page_content' ) );
 
113
  add_submenu_page( 'TRPHidden', 'TranslatePress Addons', 'TRPHidden', 'manage_options', 'trp_addons_page', array($this, 'addons_page_content') );
114
- add_submenu_page( 'TRPHidden', 'TranslatePress Test Google API Key', 'TRPHidden', 'manage_options', 'trp_test_google_key_page', array($this, 'test_google_key_page_content') );
115
  }
116
 
117
  /**
118
  * Settings page content.
119
  */
120
  public function settings_page_content(){
121
- $trp = TRP_Translate_Press::get_trp_instance();
122
  if ( ! $this->trp_languages ){
 
123
  $this->trp_languages = $trp->get_component( 'languages' );
124
  }
125
- if ( ! $this->machine_translator ){
126
- $this->machine_translator = $trp->get_component( 'machine_translator' );
127
- }
128
  $languages = $this->trp_languages->get_languages( 'english_name' );
129
- $gtranslate_referer = $this->machine_translator->get_referer();
130
  require_once TRP_PLUGIN_DIR . 'partials/main-settings-page.php';
131
  }
132
 
@@ -137,13 +135,6 @@ class TRP_Settings{
137
  require_once TRP_PLUGIN_DIR . 'partials/addons-settings-page.php';
138
  }
139
 
140
- /**
141
- * Test Google Key page content.
142
- */
143
- public function test_google_key_page_content(){
144
- require_once TRP_PLUGIN_DIR . 'partials/test-google-key-settings-page.php';
145
- }
146
-
147
  /**
148
  * Register settings option.
149
  */
@@ -188,17 +179,6 @@ class TRP_Settings{
188
  array_unshift( $settings['publish-languages'], $settings['default-language'] );
189
  }
190
 
191
-
192
- if( !empty( $settings['g-translate'] ) )
193
- $settings['g-translate'] = sanitize_text_field( $settings['g-translate'] );
194
- else
195
- $settings['g-translate'] = 'no';
196
-
197
-
198
-
199
- if( !empty( $settings['g-translate-key'] ) )
200
- $settings['g-translate-key'] = sanitize_text_field( $settings['g-translate-key'] );
201
-
202
  if( !empty( $settings['native_or_english_name'] ) )
203
  $settings['native_or_english_name'] = sanitize_text_field( $settings['native_or_english_name'] );
204
  else
@@ -273,11 +253,16 @@ class TRP_Settings{
273
  $this->trp_query->check_gettext_table( $language_code );
274
  }
275
 
276
- $settings['google-translate-codes'] = $this->trp_languages->get_iso_codes( $settings['translation-languages'] );
277
-
278
  // regenerate permalinks in case something changed
279
  flush_rewrite_rules();
280
 
 
 
 
 
 
 
 
281
  return apply_filters( 'trp_extra_sanitize_settings', $settings );
282
  }
283
 
@@ -302,21 +287,43 @@ class TRP_Settings{
302
  $default = 'en_US';
303
  }
304
  $default_settings = array(
305
- 'default-language' => $default,
306
- 'translation-languages' => array( $default ),
307
- 'publish-languages' => array( $default ),
308
- 'native_or_english_name' => 'english_name',
309
- 'add-subdirectory-to-default-language' => 'no',
310
- 'force-language-to-custom-links' => 'yes',
311
- 'g-translate' => 'no',
312
- 'trp-ls-floater' => 'yes',
313
- 'shortcode-options' => 'flags-full-names',
314
- 'menu-options' => 'flags-full-names',
315
- 'floater-options' => 'flags-full-names',
316
- 'floater-position' => 'bottom-right',
317
- 'url-slugs' => array( 'en_US' => 'en', '' ),
318
- 'advanced_settings' => get_option('trp_advanced_settings', array() ),
 
 
319
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
320
  if ( 'not_set' == $settings_option ){
321
  update_option ( 'trp_settings', $default_settings );
322
  $settings_option = $default_settings;
@@ -327,6 +334,7 @@ class TRP_Settings{
327
  }
328
  }
329
  }
 
330
  $this->settings = $settings_option;
331
  }
332
 
@@ -336,7 +344,7 @@ class TRP_Settings{
336
  * @param string $hook Admin page.
337
  */
338
  public function enqueue_scripts_and_styles( $hook ) {
339
- if ( $hook == 'settings_page_translate-press' || $hook == 'admin_page_trp_license_key' || $hook == 'admin_page_trp_addons_page' || $hook == 'admin_page_trp_advanced_page' ) {
340
  wp_enqueue_style(
341
  'trp-settings-style',
342
  TRP_PLUGIN_URL . 'assets/css/trp-back-end-style.css',
@@ -345,14 +353,17 @@ class TRP_Settings{
345
  );
346
  }
347
 
348
- if ( $hook == 'settings_page_translate-press' || $hook == 'admin_page_trp_advanced_page' ) {
349
  wp_enqueue_script( 'trp-settings-script', TRP_PLUGIN_URL . 'assets/js/trp-back-end-script.js', array( 'jquery', 'jquery-ui-sortable' ), TRP_PLUGIN_VERSION );
 
350
  if ( ! $this->trp_languages ){
351
- $trp = TRP_Translate_Press::get_trp_instance();
352
  $this->trp_languages = $trp->get_component( 'languages' );
353
  }
 
354
  $all_language_codes = $this->trp_languages->get_all_language_codes();
355
- $iso_codes = $this->trp_languages->get_iso_codes( $all_language_codes, false );
 
356
  wp_localize_script( 'trp-settings-script', 'trp_url_slugs_info', array( 'iso_codes' => $iso_codes, 'error_message_duplicate_slugs' => __( 'Error! Duplicate URL slug values.', 'translatepress-multilingual' ) ) );
357
 
358
  wp_enqueue_script( 'trp-select2-lib-js', TRP_PLUGIN_URL . 'assets/lib/select2-lib/dist/js/select2.min.js', array( 'jquery' ), TRP_PLUGIN_VERSION );
@@ -443,10 +454,10 @@ class TRP_Settings{
443
  'name' => __( 'Addons', 'translatepress-multilingual' ),
444
  'url' => admin_url( 'admin.php?page=trp_addons_page' ),
445
  'page' => 'trp_addons_page'
446
- )
447
  );
448
 
449
- if( class_exists('TRP_LICENSE_PAGE') ) {
450
  $tabs[] = array(
451
  'name' => __( 'License', 'translatepress-multilingual' ),
452
  'url' => admin_url( 'admin.php?page=trp_license_key' ),
@@ -461,7 +472,7 @@ class TRP_Settings{
461
  $active_tab = esc_attr( wp_unslash( $_GET['page'] ) );
462
  }
463
 
464
- require ( TRP_PLUGIN_DIR . 'partials/settings-navigation-tabs.php');
465
  }
466
 
467
  /**
@@ -486,4 +497,3 @@ class TRP_Settings{
486
  }
487
 
488
  }
489
-
76
  }
77
 
78
  /**
79
+ * Returns settings_option.
80
+ *
81
+ * @return array Settings option.
82
+ */
83
  public function get_settings(){
84
  if ( $this->settings == null ){
85
  $this->set_options();
110
  */
111
  public function register_menu_page(){
112
  add_options_page( 'TranslatePress', 'TranslatePress', apply_filters( 'trp_settings_capability', 'manage_options' ), 'translate-press', array( $this, 'settings_page_content' ) );
113
+
114
  add_submenu_page( 'TRPHidden', 'TranslatePress Addons', 'TRPHidden', 'manage_options', 'trp_addons_page', array($this, 'addons_page_content') );
 
115
  }
116
 
117
  /**
118
  * Settings page content.
119
  */
120
  public function settings_page_content(){
 
121
  if ( ! $this->trp_languages ){
122
+ $trp = TRP_Translate_Press::get_trp_instance();
123
  $this->trp_languages = $trp->get_component( 'languages' );
124
  }
125
+
 
 
126
  $languages = $this->trp_languages->get_languages( 'english_name' );
127
+
128
  require_once TRP_PLUGIN_DIR . 'partials/main-settings-page.php';
129
  }
130
 
135
  require_once TRP_PLUGIN_DIR . 'partials/addons-settings-page.php';
136
  }
137
 
 
 
 
 
 
 
 
138
  /**
139
  * Register settings option.
140
  */
179
  array_unshift( $settings['publish-languages'], $settings['default-language'] );
180
  }
181
 
 
 
 
 
 
 
 
 
 
 
 
182
  if( !empty( $settings['native_or_english_name'] ) )
183
  $settings['native_or_english_name'] = sanitize_text_field( $settings['native_or_english_name'] );
184
  else
253
  $this->trp_query->check_gettext_table( $language_code );
254
  }
255
 
 
 
256
  // regenerate permalinks in case something changed
257
  flush_rewrite_rules();
258
 
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 );
265
+
266
  return apply_filters( 'trp_extra_sanitize_settings', $settings );
267
  }
268
 
287
  $default = 'en_US';
288
  }
289
  $default_settings = array(
290
+ 'default-language' => $default,
291
+ 'translation-languages' => array( $default ),
292
+ 'publish-languages' => array( $default ),
293
+ 'native_or_english_name' => 'english_name',
294
+ 'add-subdirectory-to-default-language' => 'no',
295
+ 'force-language-to-custom-links' => 'yes',
296
+ 'trp-ls-floater' => 'yes',
297
+ 'shortcode-options' => 'flags-full-names',
298
+ 'menu-options' => 'flags-full-names',
299
+ 'floater-options' => 'flags-full-names',
300
+ 'floater-position' => 'bottom-right',
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
+
308
+ $machine_translation_settings = get_option( 'trp_machine_translation_settings', false );
309
+
310
+ // move the old API key option
311
+ if( !empty( $settings_option['g-translate-key'] ) && empty( $machine_translation_settings['google-translate-key'] ) ){
312
+ $machine_translation_settings['google-translate-key'] = $settings_option['g-translate-key'];
313
+
314
+ update_option( 'trp_machine_translation_settings', $machine_translation_settings );
315
+ }
316
+
317
+ // enable machine translation if it was activated before
318
+ if( !empty( $settings_option['g-translate'] ) && $settings_option['g-translate'] == 'yes' && ( isset( $machine_translation_settings['machine-translation'] ) && $machine_translation_settings['machine-translation'] != 'yes' ) ){
319
+ $machine_translation_settings['machine-translation'] = 'yes';
320
+
321
+ update_option( 'trp_machine_translation_settings', $machine_translation_settings );
322
+ }
323
+
324
+ if( !empty( $machine_translation_settings ) )
325
+ $default_settings = array_merge( $default_settings, $machine_translation_settings );
326
+
327
  if ( 'not_set' == $settings_option ){
328
  update_option ( 'trp_settings', $default_settings );
329
  $settings_option = $default_settings;
334
  }
335
  }
336
  }
337
+
338
  $this->settings = $settings_option;
339
  }
340
 
344
  * @param string $hook Admin page.
345
  */
346
  public function enqueue_scripts_and_styles( $hook ) {
347
+ if( in_array( $hook, [ 'settings_page_translate-press', 'admin_page_trp_license_key', 'admin_page_trp_addons_page', 'admin_page_trp_advanced_page', 'admin_page_trp_machine_translation', 'admin_page_trp_test_machine_api' ] ) ){
348
  wp_enqueue_style(
349
  'trp-settings-style',
350
  TRP_PLUGIN_URL . 'assets/css/trp-back-end-style.css',
353
  );
354
  }
355
 
356
+ if( in_array( $hook, array( 'settings_page_translate-press', 'admin_page_trp_advanced_page', 'admin_page_trp_machine_translation' ) ) ) {
357
  wp_enqueue_script( 'trp-settings-script', TRP_PLUGIN_URL . 'assets/js/trp-back-end-script.js', array( 'jquery', 'jquery-ui-sortable' ), TRP_PLUGIN_VERSION );
358
+
359
  if ( ! $this->trp_languages ){
360
+ $trp = TRP_Translate_Press::get_trp_instance();
361
  $this->trp_languages = $trp->get_component( 'languages' );
362
  }
363
+
364
  $all_language_codes = $this->trp_languages->get_all_language_codes();
365
+ $iso_codes = $this->trp_languages->get_iso_codes( $all_language_codes, false );
366
+
367
  wp_localize_script( 'trp-settings-script', 'trp_url_slugs_info', array( 'iso_codes' => $iso_codes, 'error_message_duplicate_slugs' => __( 'Error! Duplicate URL slug values.', 'translatepress-multilingual' ) ) );
368
 
369
  wp_enqueue_script( 'trp-select2-lib-js', TRP_PLUGIN_URL . 'assets/lib/select2-lib/dist/js/select2.min.js', array( 'jquery' ), TRP_PLUGIN_VERSION );
454
  'name' => __( 'Addons', 'translatepress-multilingual' ),
455
  'url' => admin_url( 'admin.php?page=trp_addons_page' ),
456
  'page' => 'trp_addons_page'
457
+ ),
458
  );
459
 
460
+ if( class_exists( 'TRP_LICENSE_PAGE' ) ) {
461
  $tabs[] = array(
462
  'name' => __( 'License', 'translatepress-multilingual' ),
463
  'url' => admin_url( 'admin.php?page=trp_license_key' ),
472
  $active_tab = esc_attr( wp_unslash( $_GET['page'] ) );
473
  }
474
 
475
+ require TRP_PLUGIN_DIR . 'partials/settings-navigation-tabs.php';
476
  }
477
 
478
  /**
497
  }
498
 
499
  }
 
includes/class-translation-manager.php CHANGED
@@ -772,15 +772,14 @@ class TRP_Translation_Manager{
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
- /* 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 */
776
- $new_strings[] = str_replace( array( '%', '$', '#' ), array( '1TP1', '1TP2', '1TP3' ), $trp_gettext_string_for_machine_translation['original'] );
777
  }
778
 
779
- $machine_strings = $this->machine_translator->translate_array( $new_strings, $TRP_LANGUAGE );
780
 
781
  if( !empty( $machine_strings ) ){
782
  foreach( $machine_strings as $key => $machine_string ){
783
- $trp_gettext_strings_for_machine_translation[$key]['translated'] = str_ireplace( array( '1TP1', '1TP2', '1TP3' ), array( '%', '$', '#' ), $machine_string );
784
  }
785
  }
786
 
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
 
includes/class-translation-render.php CHANGED
@@ -305,7 +305,9 @@ class TRP_Translation_Render{
305
 
306
  /* replace our special tags so we have valid html */
307
  $output = str_replace('#!trpst#', '<', $output);
 
308
  $output = str_replace('#!trpen#', '>', $output);
 
309
 
310
  $output = apply_filters('trp_before_translate_content', $output);
311
 
@@ -320,8 +322,7 @@ class TRP_Translation_Render{
320
 
321
  /* make sure we only translate on the rest_prepare_$post_type filter in REST requests and not the whole json */
322
  if( strpos( $this->url_converter->cur_page_url(), get_rest_url() ) !== false && strpos( current_filter(), 'rest_prepare_' ) !== 0){
323
- $trpremoved = preg_replace( '/(<|&lt;)trp-gettext (.*?)(>|&gt;)/', '', $output );
324
- $trpremoved = preg_replace( '/(<|&lt;)(\\\\)*\/trp-gettext(>|&gt;)/', '', $trpremoved );
325
  return $trpremoved;
326
  }
327
 
@@ -354,9 +355,11 @@ class TRP_Translation_Render{
354
 
355
  //check if we have a json response
356
  if ( ! empty( $json_array ) ) {
357
- if( !is_array( $json_array ) )//make sure we send an array as json_decode even with true parameter might not return one
358
- $json_array = array( $json_array );
359
- array_walk_recursive( $json_array, array( $this, 'translate_json' ) );
 
 
360
  }
361
 
362
  return trp_safe_json_encode( $json_array );
@@ -393,8 +396,7 @@ class TRP_Translation_Render{
393
 
394
  $html = TranslatePress\str_get_html($output, true, true, TRP_DEFAULT_TARGET_CHARSET, false, TRP_DEFAULT_BR_TEXT, TRP_DEFAULT_SPAN_TEXT);
395
  if ( $html === false ){
396
- $trpremoved = preg_replace( '/(<|&lt;)trp-gettext (.*?)(>|&gt;)/', '', $output );
397
- $trpremoved = preg_replace( '/(<|&lt;)(\\\\)*\/trp-gettext(>|&gt;)/', '', $trpremoved );
398
  return $trpremoved;
399
  }
400
 
@@ -575,7 +577,7 @@ class TRP_Translation_Render{
575
  }
576
  }
577
 
578
- foreach ( $html->find('text') as $row ){
579
  $outertext = $row->outertext;
580
  $parent = $row->parent();
581
  $trimmed_string = trp_full_trim($outertext);
@@ -852,6 +854,10 @@ class TRP_Translation_Render{
852
  function remove_trp_html_tags( $string ){
853
  $string = preg_replace( '/(<|&lt;)trp-gettext (.*?)(>|&gt;)/', '', $string );
854
  $string = preg_replace( '/(<|&lt;)(\\\\)*\/trp-gettext(>|&gt;)/', '', $string );
 
 
 
 
855
  return $string;
856
  }
857
 
@@ -1056,7 +1062,7 @@ class TRP_Translation_Render{
1056
 
1057
  // machine translate new strings
1058
  if ( $machine_translation_available ) {
1059
- $machine_strings = $this->machine_translator->translate_array( $machine_translatable_strings, $language_code );
1060
  }else{
1061
  $machine_strings = false;
1062
  }
305
 
306
  /* replace our special tags so we have valid html */
307
  $output = str_replace('#!trpst#', '<', $output);
308
+ $output = str_replace('#!TRPST#', '<', $output);
309
  $output = str_replace('#!trpen#', '>', $output);
310
+ $output = str_replace('#!TRPEN#', '>', $output);
311
 
312
  $output = apply_filters('trp_before_translate_content', $output);
313
 
322
 
323
  /* make sure we only translate on the rest_prepare_$post_type filter in REST requests and not the whole json */
324
  if( strpos( $this->url_converter->cur_page_url(), get_rest_url() ) !== false && strpos( current_filter(), 'rest_prepare_' ) !== 0){
325
+ $trpremoved = $this->remove_trp_html_tags( $output );
 
326
  return $trpremoved;
327
  }
328
 
355
 
356
  //check if we have a json response
357
  if ( ! empty( $json_array ) ) {
358
+ if( is_array( $json_array ) ) {
359
+ array_walk_recursive($json_array, array($this, 'translate_json'));
360
+ }else {
361
+ $json_array = $this->translate_page($json_array);
362
+ }
363
  }
364
 
365
  return trp_safe_json_encode( $json_array );
396
 
397
  $html = TranslatePress\str_get_html($output, true, true, TRP_DEFAULT_TARGET_CHARSET, false, TRP_DEFAULT_BR_TEXT, TRP_DEFAULT_SPAN_TEXT);
398
  if ( $html === false ){
399
+ $trpremoved = $this->remove_trp_html_tags( $output );
 
400
  return $trpremoved;
401
  }
402
 
577
  }
578
  }
579
 
580
+ foreach ( $html->find('trptext') as $row ){
581
  $outertext = $row->outertext;
582
  $parent = $row->parent();
583
  $trimmed_string = trp_full_trim($outertext);
854
  function remove_trp_html_tags( $string ){
855
  $string = preg_replace( '/(<|&lt;)trp-gettext (.*?)(>|&gt;)/', '', $string );
856
  $string = preg_replace( '/(<|&lt;)(\\\\)*\/trp-gettext(>|&gt;)/', '', $string );
857
+ if (!isset($_REQUEST['trp-edit-translation']) || $_REQUEST['trp-edit-translation'] != 'preview') {
858
+ $string = preg_replace('/(<|&lt;)trp-wrap (.*?)(>|&gt;)/', '', $string);
859
+ $string = preg_replace('/(<|&lt;)(\\\\)*\/trp-wrap(>|&gt;)/', '', $string);
860
+ }
861
  return $string;
862
  }
863
 
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
  }
includes/functions.php CHANGED
@@ -943,3 +943,49 @@ function trp_woo_cart_item_name( $product_name, $cart_item, $cart_item_key ){
943
  }
944
  return $product_name;
945
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
943
  }
944
  return $product_name;
945
  }
946
+
947
+ /**
948
+ * Compatibility with WooCommerce PDF Invoices & Packing Slips
949
+ *
950
+ * Translate product name and variation (meta) in pdf invoices.
951
+ */
952
+ add_filter( 'wpo_wcpdf_order_item_data', 'trp_woo_wcpdf_translate_product_name', 10, 3 );
953
+ function trp_woo_wcpdf_translate_product_name( $data, $order, $type ){
954
+ if ( isset( $data['name'] ) ) {
955
+ $trp = TRP_Translate_Press::get_trp_instance();
956
+ $translation_render = $trp->get_component('translation_render');
957
+ remove_filter( 'trp_stop_translating_page', 'trp_woo_pdf_invoices_and_packing_slips_compatibility_dont_translate_pdf', 10 );
958
+ $data['name'] = $translation_render->translate_page($data['name']);
959
+ if ( isset( $data['meta'] ) ) {
960
+ $data['meta'] = $translation_render->translate_page($data['meta']);
961
+ }
962
+ add_filter( 'trp_stop_translating_page', 'trp_woo_pdf_invoices_and_packing_slips_compatibility_dont_translate_pdf', 10, 2 );
963
+ }
964
+ return $data;
965
+ }
966
+
967
+ /**
968
+ * Compatibility with WooCommerce Checkout Add-Ons plugin
969
+ *
970
+ * Exclude name of "paid add-on" item from being run through gettext.
971
+ *
972
+ * No other filters were found. Advanced settings strip meta did not work.
973
+ * It's being added through WC->add_fee and inserted directly in db in custom table.
974
+ */
975
+ add_action( 'woocommerce_cart_calculate_fees', 'trp_woo_checkout_add_ons_filter_trpstr', 10, 2);
976
+ function trp_woo_checkout_add_ons_filter_trpstr(){
977
+ if ( class_exists('WC_Checkout_Add_Ons_Frontend') ) {
978
+ add_filter('trp_skip_gettext_processing', 'trp_woo_checkout_exclude_strings', 1000, 4);
979
+ }
980
+ }
981
+
982
+ function trp_woo_checkout_exclude_strings( $return, $translation, $text, $domain) {
983
+ if ( $domain === 'woocommerce-checkout-add-ons' ) {
984
+ $add_ons = wc_checkout_add_ons()->get_add_ons();
985
+ foreach ($add_ons as $add_on) {
986
+ if ( $add_on->name === $text)
987
+ return true;
988
+ }
989
+ }
990
+ return $return;
991
+ }
includes/google-translate/class-google-translate-v2-machine-translator.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Exit if accessed directly
4
+ if ( ! defined( 'ABSPATH' ) ) exit;
5
+
6
+ class TRP_Google_Translate_V2_Machine_Translator extends TRP_Machine_Translator {
7
+ /**
8
+ * Send request to Google Translation API
9
+ *
10
+ * @param string $source_language Translate from language
11
+ * @param string $language_code Translate to language
12
+ * @param array $strings_array Array of string to translate
13
+ *
14
+ * @return array|WP_Error Response
15
+ */
16
+ public function send_request( $source_language, $language_code, $strings_array ){
17
+ /* build our translation request */
18
+ $translation_request = 'key='.$this->settings['google-translate-key'];
19
+ $translation_request .= '&source='.$source_language;
20
+ $translation_request .= '&target='.$language_code;
21
+ foreach( $strings_array as $new_string ){
22
+ $translation_request .= '&q='.rawurlencode(html_entity_decode( $new_string, ENT_QUOTES ));
23
+ }
24
+ $referer = $this->get_referer();
25
+
26
+ /* Due to url length restrictions we need so send a POST request faked as a GET request and send the strings in the body of the request and not in the URL */
27
+ $response = wp_remote_post( "https://www.googleapis.com/language/translate/v2", array(
28
+ 'headers' => array(
29
+ 'X-HTTP-Method-Override' => 'GET', //this fakes a GET request
30
+ 'Referer' => $referer
31
+ ),
32
+ 'body' => $translation_request,
33
+ )
34
+ );
35
+ return $response;
36
+ }
37
+
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 */
70
+ if ( is_array( $response ) && ! is_wp_error( $response ) ) {
71
+
72
+ $this->machine_translator_logger->count_towards_quota( $new_strings_chunk );
73
+
74
+ /* decode it */
75
+ $translation_response = json_decode( $response['body'] );
76
+ if( !empty( $translation_response->error ) ){
77
+ return array(); // return an empty array if we encountered an error. This means we don't store any translation in the DB
78
+ }
79
+ else{
80
+ /* if we have strings build the translation strings array and make sure we keep the original keys from $new_string */
81
+ $translations = $translation_response->data->translations;
82
+ $i = 0;
83
+ foreach( $new_strings_chunk as $key => $old_string ){
84
+ if( !empty( $translations[$i]->translatedText ) ) {
85
+ $translated_strings[$key] = $translations[$i]->translatedText;
86
+ }
87
+ $i++;
88
+ }
89
+ }
90
+ }
91
+
92
+ }
93
+
94
+ // will have the same indexes as $new_string or it will be an empty array if something went wrong
95
+ return $translated_strings;
96
+ }
97
+
98
+ /**
99
+ * Send a test request to verify if the functionality is working
100
+ */
101
+ public function test_request(){
102
+ return $this->send_request( 'en', 'es', array( 'about' ) );
103
+ }
104
+
105
+ public function get_api_key(){
106
+ return isset( $this->settings['google-translate-key'] ) ? $this->settings['google-translate-key'] : false;
107
+ }
108
+ }
includes/google-translate/functions.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ add_filter( 'trp_machine_translation_engines', 'trp_gt_add_engine', 10 );
4
+ function trp_gt_add_engine( $engines ){
5
+ $engines[] = array( 'value' => 'google_translate_v2', 'label' => __( 'Google Translate v2', 'translatepress-multilingual' ) );
6
+
7
+ return $engines;
8
+ }
9
+
10
+ add_action( 'trp_machine_translation_extra_settings_middle', 'trp_gt_add_settings' );
11
+ function trp_gt_add_settings( $settings ){
12
+ $trp = TRP_Translate_Press::get_trp_instance();
13
+ $machine_translator = $trp->get_component( 'machine_translator' );
14
+ ?>
15
+
16
+ <tr>
17
+ <th scope="row"><?php esc_html_e( 'Google Translate API Key', 'translatepress-multilingual' ); ?> </th>
18
+ <td>
19
+ <input type="text" id="trp-g-translate-key" class="trp-text-input" name="trp_machine_translation_settings[google-translate-key]" value="<?php if( !empty( $settings['google-translate-key'] ) ) echo esc_attr( $settings['google-translate-key']);?>"/>
20
+ <p class="description">
21
+ <?php echo wp_kses( __( 'Visit <a href="https://cloud.google.com/docs/authentication/api-keys" target="_blank">this link</a> to see how you can set up an API key, <strong>control API costs</strong> and set HTTP referrer restrictions.', 'translatepress-multilingual' ), [ 'a' => [ 'href' => [], 'title' => [], 'target' => [] ], 'strong' => [] ] ); ?>
22
+ <br><?php echo sprintf( esc_html__( 'Your HTTP referrer is: %s', 'translatepress-multilingual' ), $machine_translator->get_referer() ); ?>
23
+ </p>
24
+ </td>
25
+
26
+ </tr>
27
+
28
+ <?php
29
+ }
30
+
31
+ add_filter( 'trp_machine_translation_sanitize_settings', 'trp_gt_sanitize_settings' );
32
+ function trp_gt_sanitize_settings( $settings ){
33
+ if( !empty( $settings['google-translate-key'] ) )
34
+ $settings['google-translate-key'] = sanitize_text_field( $settings['google-translate-key'] );
35
+
36
+ return $settings;
37
+ }
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.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.5.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
@@ -38,16 +38,13 @@
38
  <?php __("Exclude these strings from being translated as Gettext strings by TranslatePress. Leave the domain empty to take into account any Gettext string.<br/>Can still be translated through po/mo files.", "translatepress-multilingual"); ?>
39
  <?php __("Exclude selectors from translation", "translatepress-multilingual"); ?>
40
  <?php __("Do not translate strings that are found in html nodes matching these selectors.<br>Excludes all the children of HTML nodes matching these selectors from being translated.", "translatepress-multilingual"); ?>
 
 
 
41
  <?php __("Fix broken HTML", "translatepress-multilingual"); ?>
42
  <?php __("General attempt to fix broken or missing HTML on translated pages.<br/><strong>Only try this if the \"Fix spaces between html attribute\" did not solve the issue.</strong>", "translatepress-multilingual"); ?>
43
  <?php __("Fix spaces between HTML attributes", "translatepress-multilingual"); ?>
44
  <?php __("Fixes attributes without spaces between them because they are not valid HTML.<br> May help fix missing or broken content from the HTML on translated pages.", "translatepress-multilingual"); ?>
45
- <?php __("Limit machine translation / characters per day", "translatepress-multilingual"); ?>
46
- <?php __("Add a limit to the number of automatically translated characters so you can better budget your project.</a>. ", "translatepress-multilingual"); ?>
47
- <?php __("Today's character count:", "translatepress-multilingual"); ?>
48
- <?php __("Today: ", "translatepress-multilingual"); ?>
49
- <?php __("Log machine translation queries.", "translatepress-multilingual"); ?>
50
- <?php __("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.)", "translatepress-multilingual"); ?>
51
  <?php __("Fix missing dynamic content", "translatepress-multilingual"); ?>
52
  <?php __("May help fix missing content inserted using JavaScript. <br> It shows dynamically inserted content in original language for a moment before the translation request is finished.", "translatepress-multilingual"); ?>
53
  <?php __("Filter Gettext wrapping from post content and title", "translatepress-multilingual"); ?>
@@ -66,13 +63,16 @@
66
  <?php __("Your license key has reached its activation limit.", "translatepress-multilingual"); ?>
67
  <?php __("You have successfully activated your license", "translatepress-multilingual"); ?>
68
  <?php __("Others", "translatepress-multilingual"); ?>
 
 
69
  <?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"); ?>
70
  <?php __("Dismiss this notice.", "translatepress-multilingual"); ?>
71
  <?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"); ?>
72
  <?php __("Your <strong>TranslatePress</strong> license has expired. <br/>Please %1$sRenew Your Licence%2$s to continue receiving access to product downloads, automatic updates and support. %3$sRenew now %4$s", "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 __("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"); ?>
75
- <?php __("The daily quota for machine translation characters exceeded. Please check the TranslatePress -> Settings -> Advanced Settings for more information.", "translatepress-multilingual"); ?>
76
  <?php __("Full Language Names", "translatepress-multilingual"); ?>
77
  <?php __("Short Language Names", "translatepress-multilingual"); ?>
78
  <?php __("Flags with Full Language Names", "translatepress-multilingual"); ?>
@@ -179,6 +179,10 @@
179
  <?php __("If the page does not redirect automatically", "translatepress-multilingual"); ?>
180
  <?php __("click here", "translatepress-multilingual"); ?>
181
  <?php __("<strong>TranslatePress</strong> requires <strong><a href=\"http://php.net/manual/en/book.mbstring.php\">Multibyte String PHP library</a></strong>. Please contact your server administrator to install it on your server.", "translatepress-multilingual"); ?>
 
 
 
 
182
  <?php __("<strong>TranslatePress</strong> requires at least PHP version 5.6.20+ to run. It is the <a href=\"%s\">minimum requirement of the latest WordPress version</a>. Please contact your server administrator to update your PHP version.", "translatepress-multilingual"); ?>
183
  <?php __("Advanced Addons", "translatepress-multilingual"); ?>
184
  <?php __("These addons extend your translation plugin and are available in the Developer, Business and Personal plans.", "translatepress-multilingual"); ?>
@@ -186,6 +190,7 @@
186
  <?php __("Add as many languages as you need for your project to go global.<br>Publish your language only when all your translations are done.", "translatepress-multilingual"); ?>
187
  <?php __("Pro Addons", "translatepress-multilingual"); ?>
188
  <?php __("These addons extend your translation plugin and are available in the Business and Developer plans.", "translatepress-multilingual"); ?>
 
189
  <?php __("Automatically redirects new visitors to their preferred language based on browser settings or IP address</br> and remembers the last visited language.", "translatepress-multilingual"); ?>
190
  <?php __("Create translator accounts for new users or allow existing users <br/>that are not administrators to translate your website.", "translatepress-multilingual"); ?>
191
  <?php __("Navigate your website just like a particular user role would. <br/>Really useful for dynamic content or hidden content that appears for particular users.", "translatepress-multilingual"); ?>
@@ -198,6 +203,23 @@
198
  <?php __("Active on this site", "translatepress-multilingual"); ?>
199
  <?php __("Your license is invalid", "translatepress-multilingual"); ?>
200
  <?php __("If you do not have any of the <a href=\"%s\">Advanced or Pro Addons</a> activated you do not need a license key", "translatepress-multilingual"); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
  <?php __("Select the language you wish to make your website available in.", "translatepress-multilingual"); ?>
202
  <?php __("To add <strong>more then two languages</strong> and support for SEO Title, Description, Slug and more check out <a href=\"%s\" class=\"button button-primary\" target=\"_blank\" title=\"TranslatePress Pro\">TranslatePress PRO</a>", "translatepress-multilingual"); ?>
203
  <?php __("Not only you are getting extra features and premium support, you also help fund the future development of TranslatePress.", "translatepress-multilingual"); ?>
@@ -208,18 +230,11 @@
208
  <?php __("In most cases changing the default flag is all it is needed: ", "translatepress-multilingual"); ?>
209
  <?php __("replace the default flag", "translatepress-multilingual"); ?>
210
  <?php __("Native language name", "translatepress-multilingual"); ?>
211
- <?php __("No", "translatepress-multilingual"); ?>
212
  <?php __("Select Yes if you want to display languages in their native names. Otherwise, languages will be displayed in English.", "translatepress-multilingual"); ?>
213
  <?php __("Use a subdirectory for the default language", "translatepress-multilingual"); ?>
214
  <?php __("Select Yes if you want to add the subdirectory in the URL for the default language.</br>By selecting Yes, the default language seen by website visitors will become the first one in the \"All Languages\" list.", "translatepress-multilingual"); ?>
215
  <?php __("Force language in custom links", "translatepress-multilingual"); ?>
216
  <?php __("Select Yes if you want to force custom links without language encoding to keep the currently selected language.", "translatepress-multilingual"); ?>
217
- <?php __("Google Translate", "translatepress-multilingual"); ?>
218
- <?php __("Enable or disable the automatic translation of the site with Google Translate. Only untranslated strings will receive a translation.<br>You can later edit these automatic translations.<br>Note: Not all languages support automatic translation. Please consult the <a href=\"https://cloud.google.com/translate/docs/languages\" target=\"_blank\" title=\"Automatic translation supported languages.\">supported languages list</a>. ", "translatepress-multilingual"); ?>
219
- <?php __("Google Translate API Key", "translatepress-multilingual"); ?>
220
- <?php __("Test API key", "translatepress-multilingual"); ?>
221
- <?php __("Visit <a href=\"https://cloud.google.com/docs/authentication/api-keys\" target=\"_blank\">this link</a> to see how you can set up an API key, <strong>control API costs</strong> and set HTTP referrer restrictions.", "translatepress-multilingual"); ?>
222
- <?php __("Your HTTP referrer is: %s", "translatepress-multilingual"); ?>
223
  <?php __("Language Switcher", "translatepress-multilingual"); ?>
224
  <?php __("Shortcode ", "translatepress-multilingual"); ?>
225
  <?php __("Use shortcode on any page or widget.", "translatepress-multilingual"); ?>
@@ -228,9 +243,9 @@
228
  <?php __("Learn more in our documentation.", "translatepress-multilingual"); ?>
229
  <?php __("Floating language selection", "translatepress-multilingual"); ?>
230
  <?php __("Add a floating dropdown that follows the user on every page.", "translatepress-multilingual"); ?>
231
- <?php __("Google API Key from settings page:", "translatepress-multilingual"); ?>
232
  <?php __("HTTP Referrer:", "translatepress-multilingual"); ?>
233
- <?php __("Use this HTTP Referrer if you want to restrict usage of the API from Google Dashboard.", "translatepress-multilingual"); ?>
234
  <?php __("Response:", "translatepress-multilingual"); ?>
235
  <?php __("Response Body:", "translatepress-multilingual"); ?>
236
  <?php __("Entire Response From wp_remote_get():", "translatepress-multilingual"); ?>
38
  <?php __("Exclude these strings from being translated as Gettext strings by TranslatePress. Leave the domain empty to take into account any Gettext string.<br/>Can still be translated through po/mo files.", "translatepress-multilingual"); ?>
39
  <?php __("Exclude selectors from translation", "translatepress-multilingual"); ?>
40
  <?php __("Do not translate strings that are found in html nodes matching these selectors.<br>Excludes all the children of HTML nodes matching these selectors from being translated.", "translatepress-multilingual"); ?>
41
+ <?php __("String", "translatepress-multilingual"); ?>
42
+ <?php __("Exclude strings from automatic translation", "translatepress-multilingual"); ?>
43
+ <?php __("Do not automatically translate these strings (ex. names, technical words...)<br>Paragraphs containing these strings will still be translated except for the specified part.", "translatepress-multilingual"); ?>
44
  <?php __("Fix broken HTML", "translatepress-multilingual"); ?>
45
  <?php __("General attempt to fix broken or missing HTML on translated pages.<br/><strong>Only try this if the \"Fix spaces between html attribute\" did not solve the issue.</strong>", "translatepress-multilingual"); ?>
46
  <?php __("Fix spaces between HTML attributes", "translatepress-multilingual"); ?>
47
  <?php __("Fixes attributes without spaces between them because they are not valid HTML.<br> May help fix missing or broken content from the HTML on translated pages.", "translatepress-multilingual"); ?>
 
 
 
 
 
 
48
  <?php __("Fix missing dynamic content", "translatepress-multilingual"); ?>
49
  <?php __("May help fix missing content inserted using JavaScript. <br> It shows dynamically inserted content in original language for a moment before the translation request is finished.", "translatepress-multilingual"); ?>
50
  <?php __("Filter Gettext wrapping from post content and title", "translatepress-multilingual"); ?>
63
  <?php __("Your license key has reached its activation limit.", "translatepress-multilingual"); ?>
64
  <?php __("You have successfully activated your license", "translatepress-multilingual"); ?>
65
  <?php __("Others", "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 __("Dismiss this notice.", "translatepress-multilingual"); ?>
70
  <?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"); ?>
71
  <?php __("Your <strong>TranslatePress</strong> license has expired. <br/>Please %1$sRenew Your Licence%2$s to continue receiving access to product downloads, automatic updates and support. %3$sRenew now %4$s", "translatepress-multilingual"); ?>
72
+ <?php __("Something went wrong, please try again.", "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 __("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"); ?>
75
+ <?php __("The daily quota for machine translation characters exceeded. Please check the <strong>TranslatePress -> Settings -> <a href=\"%s\">Machine Translation</a></strong> page for more information.", "translatepress-multilingual"); ?>
76
  <?php __("Full Language Names", "translatepress-multilingual"); ?>
77
  <?php __("Short Language Names", "translatepress-multilingual"); ?>
78
  <?php __("Flags with Full Language Names", "translatepress-multilingual"); ?>
179
  <?php __("If the page does not redirect automatically", "translatepress-multilingual"); ?>
180
  <?php __("click here", "translatepress-multilingual"); ?>
181
  <?php __("<strong>TranslatePress</strong> requires <strong><a href=\"http://php.net/manual/en/book.mbstring.php\">Multibyte String PHP library</a></strong>. Please contact your server administrator to install it on your server.", "translatepress-multilingual"); ?>
182
+ <?php __("Google Translate v2", "translatepress-multilingual"); ?>
183
+ <?php __("Google Translate API Key", "translatepress-multilingual"); ?>
184
+ <?php __("Visit <a href=\"https://cloud.google.com/docs/authentication/api-keys\" target=\"_blank\">this link</a> to see how you can set up an API key, <strong>control API costs</strong> and set HTTP referrer restrictions.", "translatepress-multilingual"); ?>
185
+ <?php __("Your HTTP referrer is: %s", "translatepress-multilingual"); ?>
186
  <?php __("<strong>TranslatePress</strong> requires at least PHP version 5.6.20+ to run. It is the <a href=\"%s\">minimum requirement of the latest WordPress version</a>. Please contact your server administrator to update your PHP version.", "translatepress-multilingual"); ?>
187
  <?php __("Advanced Addons", "translatepress-multilingual"); ?>
188
  <?php __("These addons extend your translation plugin and are available in the Developer, Business and Personal plans.", "translatepress-multilingual"); ?>
190
  <?php __("Add as many languages as you need for your project to go global.<br>Publish your language only when all your translations are done.", "translatepress-multilingual"); ?>
191
  <?php __("Pro Addons", "translatepress-multilingual"); ?>
192
  <?php __("These addons extend your translation plugin and are available in the Business and Developer plans.", "translatepress-multilingual"); ?>
193
+ <?php __("Automatically translate your website through the DeepL API.", "translatepress-multilingual"); ?>
194
  <?php __("Automatically redirects new visitors to their preferred language based on browser settings or IP address</br> and remembers the last visited language.", "translatepress-multilingual"); ?>
195
  <?php __("Create translator accounts for new users or allow existing users <br/>that are not administrators to translate your website.", "translatepress-multilingual"); ?>
196
  <?php __("Navigate your website just like a particular user role would. <br/>Really useful for dynamic content or hidden content that appears for particular users.", "translatepress-multilingual"); ?>
203
  <?php __("Active on this site", "translatepress-multilingual"); ?>
204
  <?php __("Your license is invalid", "translatepress-multilingual"); ?>
205
  <?php __("If you do not have any of the <a href=\"%s\">Advanced or Pro Addons</a> activated you do not need a license key", "translatepress-multilingual"); ?>
206
+ <?php __("TranslatePress Automatic Translation", "translatepress-multilingual"); ?>
207
+ <?php __("Enable Automatic Translation", "translatepress-multilingual"); ?>
208
+ <?php __("No", "translatepress-multilingual"); ?>
209
+ <?php __("Enable or disable the automatic translation of the site. Only untranslated strings will receive a translation.", "translatepress-multilingual"); ?>
210
+ <?php __("Translation Engine", "translatepress-multilingual"); ?>
211
+ <?php __("Choose which engine you want to use in order to automatically translate your website.", "translatepress-multilingual"); ?>
212
+ <?php __("<strong>DeepL</strong> automatic translation is available as a premium add-on in <a href=\"%s\" class=\"button button-primary\" target=\"_blank\" title=\"TranslatePress Pro\">TranslatePress PRO</a>", "translatepress-multilingual"); ?>
213
+ <?php __("By upgrading you'll get access to all paid add-ons, premium support and help fund the future development of TranslatePress.", "translatepress-multilingual"); ?>
214
+ <?php __("Test API credentials", "translatepress-multilingual"); ?>
215
+ <?php __("Click here to check if the selected translation engine is configured correctly.", "translatepress-multilingual"); ?>
216
+ <?php __("Block Crawlers", "translatepress-multilingual"); ?>
217
+ <?php __("Block crawlers from triggering automatic translations on your website.", "translatepress-multilingual"); ?>
218
+ <?php __("Limit machine translation / characters per day", "translatepress-multilingual"); ?>
219
+ <?php __("Add a limit to the number of automatically translated characters so you can better budget your project.", "translatepress-multilingual"); ?>
220
+ <?php __("Today's character count:", "translatepress-multilingual"); ?>
221
+ <?php __("Log machine translation queries.", "translatepress-multilingual"); ?>
222
+ <?php __("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.)", "translatepress-multilingual"); ?>
223
  <?php __("Select the language you wish to make your website available in.", "translatepress-multilingual"); ?>
224
  <?php __("To add <strong>more then two languages</strong> and support for SEO Title, Description, Slug and more check out <a href=\"%s\" class=\"button button-primary\" target=\"_blank\" title=\"TranslatePress Pro\">TranslatePress PRO</a>", "translatepress-multilingual"); ?>
225
  <?php __("Not only you are getting extra features and premium support, you also help fund the future development of TranslatePress.", "translatepress-multilingual"); ?>
230
  <?php __("In most cases changing the default flag is all it is needed: ", "translatepress-multilingual"); ?>
231
  <?php __("replace the default flag", "translatepress-multilingual"); ?>
232
  <?php __("Native language name", "translatepress-multilingual"); ?>
 
233
  <?php __("Select Yes if you want to display languages in their native names. Otherwise, languages will be displayed in English.", "translatepress-multilingual"); ?>
234
  <?php __("Use a subdirectory for the default language", "translatepress-multilingual"); ?>
235
  <?php __("Select Yes if you want to add the subdirectory in the URL for the default language.</br>By selecting Yes, the default language seen by website visitors will become the first one in the \"All Languages\" list.", "translatepress-multilingual"); ?>
236
  <?php __("Force language in custom links", "translatepress-multilingual"); ?>
237
  <?php __("Select Yes if you want to force custom links without language encoding to keep the currently selected language.", "translatepress-multilingual"); ?>
 
 
 
 
 
 
238
  <?php __("Language Switcher", "translatepress-multilingual"); ?>
239
  <?php __("Shortcode ", "translatepress-multilingual"); ?>
240
  <?php __("Use shortcode on any page or widget.", "translatepress-multilingual"); ?>
243
  <?php __("Learn more in our documentation.", "translatepress-multilingual"); ?>
244
  <?php __("Floating language selection", "translatepress-multilingual"); ?>
245
  <?php __("Add a floating dropdown that follows the user on every page.", "translatepress-multilingual"); ?>
246
+ <?php __("API Key from settings page:", "translatepress-multilingual"); ?>
247
  <?php __("HTTP Referrer:", "translatepress-multilingual"); ?>
248
+ <?php __("Use this HTTP Referrer if the API lets you restrict key usage from its Dashboard.", "translatepress-multilingual"); ?>
249
  <?php __("Response:", "translatepress-multilingual"); ?>
250
  <?php __("Response Body:", "translatepress-multilingual"); ?>
251
  <?php __("Entire Response From wp_remote_get():", "translatepress-multilingual"); ?>
languages/translatepress-multilingual.pot CHANGED
@@ -13,55 +13,55 @@ msgstr ""
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-google-key-settings-page.php:10, ../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
 
64
- #: ../tp-add-on-extra-languages/class-extra-languages.php:57, ../translatepress/includes/class-settings.php:356
65
  msgid "Error! Duplicate URL slug values."
66
  msgstr ""
67
 
@@ -89,7 +89,7 @@ msgstr ""
89
  msgid "Are you sure you want to remove this language?"
90
  msgstr ""
91
 
92
- #: ../tp-add-on-extra-languages/partials/language-selector-pro.php:43, ../translatepress/includes/class-advanced-tab.php:348, ../translatepress/includes/class-advanced-tab.php:358, ../translatepress/partials/main-settings-language-selector.php:40
93
  msgid "Remove"
94
  msgstr ""
95
 
@@ -97,7 +97,7 @@ msgstr ""
97
  msgid "Choose..."
98
  msgstr ""
99
 
100
- #: ../tp-add-on-extra-languages/partials/language-selector-pro.php:58, ../translatepress/includes/class-advanced-tab.php:358, ../translatepress/partials/main-settings-language-selector.php:55
101
  msgid "Add"
102
  msgstr ""
103
 
@@ -109,11 +109,11 @@ msgstr ""
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
 
@@ -169,6 +169,18 @@ msgstr ""
169
  msgid "Do not translate strings that are found in html nodes matching these selectors.<br>Excludes all the children of HTML nodes matching these selectors from being translated."
170
  msgstr ""
171
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  #: ../translatepress/includes/advanced-settings/fix-broken-html.php:8
173
  msgid "Fix broken HTML"
174
  msgstr ""
@@ -185,30 +197,6 @@ msgstr ""
185
  msgid "Fixes attributes without spaces between them because they are not valid HTML.<br> May help fix missing or broken content from the HTML on translated pages."
186
  msgstr ""
187
 
188
- #: ../translatepress/includes/advanced-settings/machine-translation-limits.php:9
189
- msgid "Limit machine translation / characters per day"
190
- msgstr ""
191
-
192
- #: ../translatepress/includes/advanced-settings/machine-translation-limits.php:10
193
- msgid "Add a limit to the number of automatically translated characters so you can better budget your project.</a>. "
194
- msgstr ""
195
-
196
- #: ../translatepress/includes/advanced-settings/machine-translation-limits.php:21
197
- msgid "Today's character count:"
198
- msgstr ""
199
-
200
- #: ../translatepress/includes/advanced-settings/machine-translation-limits.php:32
201
- msgid "Today: "
202
- msgstr ""
203
-
204
- #: ../translatepress/includes/advanced-settings/machine-translation-limits.php:42
205
- msgid "Log machine translation queries."
206
- msgstr ""
207
-
208
- #: ../translatepress/includes/advanced-settings/machine-translation-limits.php:43
209
- 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.)"
210
- msgstr ""
211
-
212
  #: ../translatepress/includes/advanced-settings/show-dynamic-content-before-translation.php:8
213
  msgid "Fix missing dynamic content"
214
  msgstr ""
@@ -237,11 +225,11 @@ msgstr ""
237
  msgid "Advanced"
238
  msgstr ""
239
 
240
- #: ../translatepress/includes/class-advanced-tab.php:226, ../translatepress/partials/main-settings-page.php:41, ../translatepress/partials/main-settings-page.php:54, ../translatepress/partials/main-settings-page.php:67, ../translatepress/partials/main-settings-page.php:80
241
  msgid "Yes"
242
  msgstr ""
243
 
244
- #: ../translatepress/includes/class-advanced-tab.php:348, ../translatepress/includes/class-advanced-tab.php:358
245
  msgid "Are you sure you want to remove this item?"
246
  msgstr ""
247
 
@@ -281,32 +269,44 @@ msgstr ""
281
  msgid "Others"
282
  msgstr ""
283
 
284
- #: ../translatepress/includes/class-plugin-notices.php:331
 
 
 
 
 
 
 
 
285
  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."
286
  msgstr ""
287
 
288
- #: ../translatepress/includes/class-plugin-notices.php:333, ../translatepress/includes/class-plugin-notices.php:359, ../translatepress/includes/class-plugin-notices.php:378, ../translatepress/includes/class-plugin-notices.php:392, ../translatepress/includes/class-plugin-notices.php:419
289
  msgid "Dismiss this notice."
290
  msgstr ""
291
 
292
- #: ../translatepress/includes/class-plugin-notices.php:352
293
  msgid "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"
294
  msgstr ""
295
 
296
- #: ../translatepress/includes/class-plugin-notices.php:354
297
  msgid "Your <strong>TranslatePress</strong> license has expired. <br/>Please %1$sRenew Your Licence%2$s to continue receiving access to product downloads, automatic updates and support. %3$sRenew now %4$s"
298
  msgstr ""
299
 
300
- #: ../translatepress/includes/class-plugin-notices.php:374
 
 
 
 
301
  msgid "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."
302
  msgstr ""
303
 
304
- #: ../translatepress/includes/class-plugin-notices.php:390
305
  msgid "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."
306
  msgstr ""
307
 
308
- #: ../translatepress/includes/class-plugin-notices.php:417
309
- msgid "The daily quota for machine translation characters exceeded. Please check the TranslatePress -> Settings -> Advanced Settings for more information."
310
  msgstr ""
311
 
312
  #: ../translatepress/includes/class-settings.php:26
@@ -345,31 +345,31 @@ msgstr ""
345
  msgid "Top Left"
346
  msgstr ""
347
 
348
- #: ../translatepress/includes/class-settings.php:392
349
  msgid "Current Language"
350
  msgstr ""
351
 
352
- #: ../translatepress/includes/class-settings.php:433
353
  msgid "General"
354
  msgstr ""
355
 
356
- #: ../translatepress/includes/class-settings.php:438, ../translatepress/includes/class-translation-manager.php:242
357
  msgid "Translate Site"
358
  msgstr ""
359
 
360
- #: ../translatepress/includes/class-settings.php:443
361
  msgid "Addons"
362
  msgstr ""
363
 
364
- #: ../translatepress/includes/class-settings.php:451
365
  msgid "License"
366
  msgstr ""
367
 
368
- #: ../translatepress/includes/class-settings.php:479, ../translatepress/includes/class-translation-manager.php:274
369
  msgid "Settings"
370
  msgstr ""
371
 
372
- #: ../translatepress/includes/class-settings.php:483
373
  msgid "Pro Features"
374
  msgstr ""
375
 
@@ -617,11 +617,11 @@ msgstr ""
617
  msgid "Translate Page"
618
  msgstr ""
619
 
620
- #: ../translatepress/includes/class-translation-manager.php:953
621
  msgid "Security check"
622
  msgstr ""
623
 
624
- #: ../translatepress/includes/class-translation-manager.php:1027
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
 
@@ -733,6 +733,22 @@ msgstr ""
733
  msgid "<strong>TranslatePress</strong> requires <strong><a href=\"http://php.net/manual/en/book.mbstring.php\">Multibyte String PHP library</a></strong>. Please contact your server administrator to install it on your server."
734
  msgstr ""
735
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
736
  #: ../translatepress/index.php:62
737
  msgid "<strong>TranslatePress</strong> requires at least PHP version 5.6.20+ to run. It is the <a href=\"%s\">minimum requirement of the latest WordPress version</a>. Please contact your server administrator to update your PHP version."
738
  msgstr ""
@@ -762,30 +778,34 @@ msgid "These addons extend your translation plugin and are available in the Busi
762
  msgstr ""
763
 
764
  #: ../translatepress/partials/addons-settings-page.php:40
765
- msgid "Automatically redirects new visitors to their preferred language based on browser settings or IP address</br> and remembers the last visited language."
766
  msgstr ""
767
 
768
  #: ../translatepress/partials/addons-settings-page.php:48
769
- msgid "Create translator accounts for new users or allow existing users <br/>that are not administrators to translate your website."
770
  msgstr ""
771
 
772
  #: ../translatepress/partials/addons-settings-page.php:56
773
- msgid "Navigate your website just like a particular user role would. <br/>Really useful for dynamic content or hidden content that appears for particular users."
774
  msgstr ""
775
 
776
  #: ../translatepress/partials/addons-settings-page.php:64
 
 
 
 
777
  msgid "Configure different menu items for different languages."
778
  msgstr ""
779
 
780
- #: ../translatepress/partials/addons-settings-page.php:70
781
  msgid "Free Addons"
782
  msgstr ""
783
 
784
- #: ../translatepress/partials/addons-settings-page.php:71
785
  msgid "Extend your translation plugin with these free addons."
786
  msgstr ""
787
 
788
- #: ../translatepress/partials/addons-settings-page.php:79
789
  msgid "Use GET parameter to encode language in the url, replacing the language directory. </br> Your urls will look like this: www.example.com?lang=en"
790
  msgstr ""
791
 
@@ -809,6 +829,74 @@ msgstr ""
809
  msgid "If you do not have any of the <a href=\"%s\">Advanced or Pro Addons</a> activated you do not need a license key"
810
  msgstr ""
811
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
812
  #: ../translatepress/partials/main-settings-language-selector.php:59
813
  msgid "Select the language you wish to make your website available in."
814
  msgstr ""
@@ -849,10 +937,6 @@ msgstr ""
849
  msgid "Native language name"
850
  msgstr ""
851
 
852
- #: ../translatepress/partials/main-settings-page.php:40, ../translatepress/partials/main-settings-page.php:53, ../translatepress/partials/main-settings-page.php:66, ../translatepress/partials/main-settings-page.php:79
853
- msgid "No"
854
- msgstr ""
855
-
856
  #: ../translatepress/partials/main-settings-page.php:44
857
  msgid "Select Yes if you want to display languages in their native names. Otherwise, languages will be displayed in English."
858
  msgstr ""
@@ -874,82 +958,58 @@ msgid "Select Yes if you want to force custom links without language encoding to
874
  msgstr ""
875
 
876
  #: ../translatepress/partials/main-settings-page.php:76
877
- msgid "Google Translate"
878
- msgstr ""
879
-
880
- #: ../translatepress/partials/main-settings-page.php:83
881
- msgid "Enable or disable the automatic translation of the site with Google Translate. Only untranslated strings will receive a translation.<br>You can later edit these automatic translations.<br>Note: Not all languages support automatic translation. Please consult the <a href=\"https://cloud.google.com/translate/docs/languages\" target=\"_blank\" title=\"Automatic translation supported languages.\">supported languages list</a>. "
882
- msgstr ""
883
-
884
- #: ../translatepress/partials/main-settings-page.php:89
885
- msgid "Google Translate API Key"
886
- msgstr ""
887
-
888
- #: ../translatepress/partials/main-settings-page.php:92
889
- msgid "Test API key"
890
- msgstr ""
891
-
892
- #: ../translatepress/partials/main-settings-page.php:94
893
- msgid "Visit <a href=\"https://cloud.google.com/docs/authentication/api-keys\" target=\"_blank\">this link</a> to see how you can set up an API key, <strong>control API costs</strong> and set HTTP referrer restrictions."
894
- msgstr ""
895
-
896
- #: ../translatepress/partials/main-settings-page.php:95
897
- msgid "Your HTTP referrer is: %s"
898
- msgstr ""
899
-
900
- #: ../translatepress/partials/main-settings-page.php:102
901
  msgid "Language Switcher"
902
  msgstr ""
903
 
904
- #: ../translatepress/partials/main-settings-page.php:105
905
  msgid "Shortcode "
906
  msgstr ""
907
 
908
- #: ../translatepress/partials/main-settings-page.php:110
909
  msgid "Use shortcode on any page or widget."
910
  msgstr ""
911
 
912
- #: ../translatepress/partials/main-settings-page.php:114
913
  msgid "Menu item"
914
  msgstr ""
915
 
916
- #: ../translatepress/partials/main-settings-page.php:122
917
  msgid "Go to %1$s Appearance -> Menus%2$s to add languages to the Language Switcher in any menu."
918
  msgstr ""
919
 
920
- #: ../translatepress/partials/main-settings-page.php:123
921
  msgid "Learn more in our documentation."
922
  msgstr ""
923
 
924
- #: ../translatepress/partials/main-settings-page.php:127
925
  msgid "Floating language selection"
926
  msgstr ""
927
 
928
- #: ../translatepress/partials/main-settings-page.php:133
929
  msgid "Add a floating dropdown that follows the user on every page."
930
  msgstr ""
931
 
932
- #: ../translatepress/partials/test-google-key-settings-page.php:15
933
- msgid "Google API Key from settings page:"
934
  msgstr ""
935
 
936
- #: ../translatepress/partials/test-google-key-settings-page.php:17
937
  msgid "HTTP Referrer:"
938
  msgstr ""
939
 
940
- #: ../translatepress/partials/test-google-key-settings-page.php:18
941
- msgid "Use this HTTP Referrer if you want to restrict usage of the API from Google Dashboard."
942
  msgstr ""
943
 
944
- #: ../translatepress/partials/test-google-key-settings-page.php:20
945
  msgid "Response:"
946
  msgstr ""
947
 
948
- #: ../translatepress/partials/test-google-key-settings-page.php:24
949
  msgid "Response Body:"
950
  msgstr ""
951
 
952
- #: ../translatepress/partials/test-google-key-settings-page.php:29
953
  msgid "Entire Response From wp_remote_get():"
954
  msgstr ""
955
 
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
 
64
+ #: ../tp-add-on-extra-languages/class-extra-languages.php:57, ../translatepress/includes/class-settings.php:367
65
  msgid "Error! Duplicate URL slug values."
66
  msgstr ""
67
 
89
  msgid "Are you sure you want to remove this language?"
90
  msgstr ""
91
 
92
+ #: ../tp-add-on-extra-languages/partials/language-selector-pro.php:43, ../translatepress/includes/class-advanced-tab.php:333, ../translatepress/includes/class-advanced-tab.php:343, ../translatepress/partials/main-settings-language-selector.php:40
93
  msgid "Remove"
94
  msgstr ""
95
 
97
  msgid "Choose..."
98
  msgstr ""
99
 
100
+ #: ../tp-add-on-extra-languages/partials/language-selector-pro.php:58, ../translatepress/includes/class-advanced-tab.php:343, ../translatepress/partials/main-settings-language-selector.php:55
101
  msgid "Add"
102
  msgstr ""
103
 
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
 
169
  msgid "Do not translate strings that are found in html nodes matching these selectors.<br>Excludes all the children of HTML nodes matching these selectors from being translated."
170
  msgstr ""
171
 
172
+ #: ../translatepress/includes/advanced-settings/exclude-words-from-auto-translate.php:9
173
+ msgid "String"
174
+ msgstr ""
175
+
176
+ #: ../translatepress/includes/advanced-settings/exclude-words-from-auto-translate.php:11
177
+ msgid "Exclude strings from automatic translation"
178
+ msgstr ""
179
+
180
+ #: ../translatepress/includes/advanced-settings/exclude-words-from-auto-translate.php:12
181
+ msgid "Do not automatically translate these strings (ex. names, technical words...)<br>Paragraphs containing these strings will still be translated except for the specified part."
182
+ msgstr ""
183
+
184
  #: ../translatepress/includes/advanced-settings/fix-broken-html.php:8
185
  msgid "Fix broken HTML"
186
  msgstr ""
197
  msgid "Fixes attributes without spaces between them because they are not valid HTML.<br> May help fix missing or broken content from the HTML on translated pages."
198
  msgstr ""
199
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
  #: ../translatepress/includes/advanced-settings/show-dynamic-content-before-translation.php:8
201
  msgid "Fix missing dynamic content"
202
  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
 
232
+ #: ../translatepress/includes/class-advanced-tab.php:333, ../translatepress/includes/class-advanced-tab.php:343
233
  msgid "Are you sure you want to remove this item?"
234
  msgstr ""
235
 
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
+
280
+ #: ../translatepress/includes/class-plugin-notices.php:330
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 ""
283
 
284
+ #: ../translatepress/includes/class-plugin-notices.php:332, ../translatepress/includes/class-plugin-notices.php:363, ../translatepress/includes/class-plugin-notices.php:382, ../translatepress/includes/class-plugin-notices.php:396, ../translatepress/includes/class-plugin-notices.php:423
285
  msgid "Dismiss this notice."
286
  msgstr ""
287
 
288
+ #: ../translatepress/includes/class-plugin-notices.php:353
289
  msgid "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"
290
  msgstr ""
291
 
292
+ #: ../translatepress/includes/class-plugin-notices.php:355
293
  msgid "Your <strong>TranslatePress</strong> license has expired. <br/>Please %1$sRenew Your Licence%2$s to continue receiving access to product downloads, automatic updates and support. %3$sRenew now %4$s"
294
  msgstr ""
295
 
296
+ #: ../translatepress/includes/class-plugin-notices.php:357
297
+ msgid "Something went wrong, please try again."
298
+ msgstr ""
299
+
300
+ #: ../translatepress/includes/class-plugin-notices.php:378
301
  msgid "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."
302
  msgstr ""
303
 
304
+ #: ../translatepress/includes/class-plugin-notices.php:394
305
  msgid "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."
306
  msgstr ""
307
 
308
+ #: ../translatepress/includes/class-plugin-notices.php:420
309
+ msgid "The daily quota for machine translation characters exceeded. Please check the <strong>TranslatePress -> Settings -> <a href=\"%s\">Machine Translation</a></strong> page for more information."
310
  msgstr ""
311
 
312
  #: ../translatepress/includes/class-settings.php:26
345
  msgid "Top Left"
346
  msgstr ""
347
 
348
+ #: ../translatepress/includes/class-settings.php:403
349
  msgid "Current Language"
350
  msgstr ""
351
 
352
+ #: ../translatepress/includes/class-settings.php:444
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
 
360
+ #: ../translatepress/includes/class-settings.php:454
361
  msgid "Addons"
362
  msgstr ""
363
 
364
+ #: ../translatepress/includes/class-settings.php:462
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
 
372
+ #: ../translatepress/includes/class-settings.php:494
373
  msgid "Pro Features"
374
  msgstr ""
375
 
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
 
733
  msgid "<strong>TranslatePress</strong> requires <strong><a href=\"http://php.net/manual/en/book.mbstring.php\">Multibyte String PHP library</a></strong>. Please contact your server administrator to install it on your server."
734
  msgstr ""
735
 
736
+ #: ../translatepress/includes/google-translate/functions.php:5
737
+ msgid "Google Translate v2"
738
+ msgstr ""
739
+
740
+ #: ../translatepress/includes/google-translate/functions.php:17
741
+ msgid "Google Translate API Key"
742
+ msgstr ""
743
+
744
+ #: ../translatepress/includes/google-translate/functions.php:21
745
+ msgid "Visit <a href=\"https://cloud.google.com/docs/authentication/api-keys\" target=\"_blank\">this link</a> to see how you can set up an API key, <strong>control API costs</strong> and set HTTP referrer restrictions."
746
+ msgstr ""
747
+
748
+ #: ../translatepress/includes/google-translate/functions.php:22
749
+ msgid "Your HTTP referrer is: %s"
750
+ msgstr ""
751
+
752
  #: ../translatepress/index.php:62
753
  msgid "<strong>TranslatePress</strong> requires at least PHP version 5.6.20+ to run. It is the <a href=\"%s\">minimum requirement of the latest WordPress version</a>. Please contact your server administrator to update your PHP version."
754
  msgstr ""
778
  msgstr ""
779
 
780
  #: ../translatepress/partials/addons-settings-page.php:40
781
+ msgid "Automatically translate your website through the DeepL API."
782
  msgstr ""
783
 
784
  #: ../translatepress/partials/addons-settings-page.php:48
785
+ msgid "Automatically redirects new visitors to their preferred language based on browser settings or IP address</br> and remembers the last visited language."
786
  msgstr ""
787
 
788
  #: ../translatepress/partials/addons-settings-page.php:56
789
+ msgid "Create translator accounts for new users or allow existing users <br/>that are not administrators to translate your website."
790
  msgstr ""
791
 
792
  #: ../translatepress/partials/addons-settings-page.php:64
793
+ msgid "Navigate your website just like a particular user role would. <br/>Really useful for dynamic content or hidden content that appears for particular users."
794
+ msgstr ""
795
+
796
+ #: ../translatepress/partials/addons-settings-page.php:72
797
  msgid "Configure different menu items for different languages."
798
  msgstr ""
799
 
800
+ #: ../translatepress/partials/addons-settings-page.php:78
801
  msgid "Free Addons"
802
  msgstr ""
803
 
804
+ #: ../translatepress/partials/addons-settings-page.php:79
805
  msgid "Extend your translation plugin with these free addons."
806
  msgstr ""
807
 
808
+ #: ../translatepress/partials/addons-settings-page.php:87
809
  msgid "Use GET parameter to encode language in the url, replacing the language directory. </br> Your urls will look like this: www.example.com?lang=en"
810
  msgstr ""
811
 
829
  msgid "If you do not have any of the <a href=\"%s\">Advanced or Pro Addons</a> activated you do not need a license key"
830
  msgstr ""
831
 
832
+ #: ../translatepress/partials/machine-translation-settings-page.php:4
833
+ msgid "TranslatePress Automatic Translation"
834
+ msgstr ""
835
+
836
+ #: ../translatepress/partials/machine-translation-settings-page.php:9
837
+ msgid "Enable Automatic Translation"
838
+ msgstr ""
839
+
840
+ #: ../translatepress/partials/machine-translation-settings-page.php:12, ../translatepress/partials/main-settings-page.php:40, ../translatepress/partials/main-settings-page.php:53, ../translatepress/partials/main-settings-page.php:66
841
+ msgid "No"
842
+ msgstr ""
843
+
844
+ #: ../translatepress/partials/machine-translation-settings-page.php:17
845
+ msgid "Enable or disable the automatic translation of the site. Only untranslated strings will receive a translation."
846
+ msgstr ""
847
+
848
+ #: ../translatepress/partials/machine-translation-settings-page.php:23
849
+ msgid "Translation Engine"
850
+ msgstr ""
851
+
852
+ #: ../translatepress/partials/machine-translation-settings-page.php:35
853
+ msgid "Choose which engine you want to use in order to automatically translate your website."
854
+ msgstr ""
855
+
856
+ #: ../translatepress/partials/machine-translation-settings-page.php:47
857
+ msgid "<strong>DeepL</strong> automatic translation is available as a premium add-on in <a href=\"%s\" class=\"button button-primary\" target=\"_blank\" title=\"TranslatePress Pro\">TranslatePress PRO</a>"
858
+ msgstr ""
859
+
860
+ #: ../translatepress/partials/machine-translation-settings-page.php:48
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
+
900
  #: ../translatepress/partials/main-settings-language-selector.php:59
901
  msgid "Select the language you wish to make your website available in."
902
  msgstr ""
937
  msgid "Native language name"
938
  msgstr ""
939
 
 
 
 
 
940
  #: ../translatepress/partials/main-settings-page.php:44
941
  msgid "Select Yes if you want to display languages in their native names. Otherwise, languages will be displayed in English."
942
  msgstr ""
958
  msgstr ""
959
 
960
  #: ../translatepress/partials/main-settings-page.php:76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
961
  msgid "Language Switcher"
962
  msgstr ""
963
 
964
+ #: ../translatepress/partials/main-settings-page.php:79
965
  msgid "Shortcode "
966
  msgstr ""
967
 
968
+ #: ../translatepress/partials/main-settings-page.php:84
969
  msgid "Use shortcode on any page or widget."
970
  msgstr ""
971
 
972
+ #: ../translatepress/partials/main-settings-page.php:88
973
  msgid "Menu item"
974
  msgstr ""
975
 
976
+ #: ../translatepress/partials/main-settings-page.php:96
977
  msgid "Go to %1$s Appearance -> Menus%2$s to add languages to the Language Switcher in any menu."
978
  msgstr ""
979
 
980
+ #: ../translatepress/partials/main-settings-page.php:97
981
  msgid "Learn more in our documentation."
982
  msgstr ""
983
 
984
+ #: ../translatepress/partials/main-settings-page.php:101
985
  msgid "Floating language selection"
986
  msgstr ""
987
 
988
+ #: ../translatepress/partials/main-settings-page.php:107
989
  msgid "Add a floating dropdown that follows the user on every page."
990
  msgstr ""
991
 
992
+ #: ../translatepress/partials/test-api-settings-page.php:17
993
+ msgid "API Key from settings page:"
994
  msgstr ""
995
 
996
+ #: ../translatepress/partials/test-api-settings-page.php:20
997
  msgid "HTTP Referrer:"
998
  msgstr ""
999
 
1000
+ #: ../translatepress/partials/test-api-settings-page.php:21
1001
+ msgid "Use this HTTP Referrer if the API lets you restrict key usage from its Dashboard."
1002
  msgstr ""
1003
 
1004
+ #: ../translatepress/partials/test-api-settings-page.php:23
1005
  msgid "Response:"
1006
  msgstr ""
1007
 
1008
+ #: ../translatepress/partials/test-api-settings-page.php:27
1009
  msgid "Response Body:"
1010
  msgstr ""
1011
 
1012
+ #: ../translatepress/partials/test-api-settings-page.php:32
1013
  msgid "Entire Response From wp_remote_get():"
1014
  msgstr ""
1015
 
partials/addons-settings-page.php CHANGED
@@ -33,6 +33,14 @@
33
  </div>
34
  </div>
35
 
 
 
 
 
 
 
 
 
36
  <div class="grid">
37
  <div class="grid-cell" style="overflow:hidden;">
38
  <a href="https://translatepress.com/pricing/" target="_blank"><img src="<?php echo esc_url( plugins_url('../assets/images/auto-detect-language-add-on.png', __FILE__) ) ?>" alt="Automatic User Language Detection" style="float: left; margin: 0 1.5rem 1.5rem 0;"></a>
@@ -79,4 +87,4 @@
79
  <p><?php _e( 'Use GET parameter to encode language in the url, replacing the language directory. </br> Your urls will look like this: www.example.com?lang=en', 'translatepress-multilingual' );?></p>
80
  </div>
81
  </div>
82
- </div>
33
  </div>
34
  </div>
35
 
36
+ <div class="grid">
37
+ <div class="grid-cell" style="overflow:hidden;">
38
+ <a href="https://translatepress.com/pricing/" target="_blank"><img src="<?php echo esc_url( plugins_url('../assets/images/deepl-add-on.png', __FILE__) ) ?>" alt="DeepL Automatic Translation" style="float: left; margin: 0 1.5rem 1.5rem 0;"></a>
39
+ <h3><a href=" <?php echo trp_add_affiliate_id_to_link('https://translatepress.com/pricing/?utm_source=wpbackend&utm_medium=clientsite&utm_content=addons_tab&utm_campaign=tpfree') ?> " target="_blank">DeepL Automatic Translation</a></h3>
40
+ <p><?php _e( 'Automatically translate your website through the DeepL API.', 'translatepress-multilingual' );?></p>
41
+ </div>
42
+ </div>
43
+
44
  <div class="grid">
45
  <div class="grid-cell" style="overflow:hidden;">
46
  <a href="https://translatepress.com/pricing/" target="_blank"><img src="<?php echo esc_url( plugins_url('../assets/images/auto-detect-language-add-on.png', __FILE__) ) ?>" alt="Automatic User Language Detection" style="float: left; margin: 0 1.5rem 1.5rem 0;"></a>
87
  <p><?php _e( 'Use GET parameter to encode language in the url, replacing the language directory. </br> Your urls will look like this: www.example.com?lang=en', 'translatepress-multilingual' );?></p>
88
  </div>
89
  </div>
90
+ </div>
partials/language-switcher-shortcode.php CHANGED
@@ -3,27 +3,17 @@ $current_language_preference = $this->add_shortcode_preferences($shortcode_setti
3
 
4
  ?>
5
  <div class="trp-language-switcher trp-language-switcher-container" data-no-translation <?php echo ( isset( $_GET['trp-edit-translation'] ) && $_GET['trp-edit-translation'] == 'preview' ) ? 'data-trp-unpreviewable="trp-unpreviewable"' : '' ?>>
6
- <script type="application/javascript">
7
- jQuery( document ).ready(function(){
8
- // need to have the same with set from JS on both divs. Otherwise it can push stuff around in HTML
9
- jQuery('.trp-language-switcher').each(function(index, el){
10
- var trp_ls_shortcode_width = jQuery(el).find('.trp-ls-shortcode-language').width() + 5;
11
- jQuery(el).find('.trp-ls-shortcode-language').width(trp_ls_shortcode_width);
12
- jQuery(el).find('.trp-ls-shortcode-current-language').width(trp_ls_shortcode_width);
13
- // We're putting this on display: none after we have it's width.
14
- jQuery(el).find('.trp-ls-shortcode-language').hide();
15
- })
16
- })
17
- </script>
18
  <div class="trp-ls-shortcode-current-language">
19
  <a href="javascript:void(0)" class="trp-ls-shortcode-disabled-language trp-ls-disabled-language" title="<?php echo esc_attr( $current_language['name'] ); ?>">
20
  <?php echo $current_language_preference; // WPCS: ok. ?>
21
  </a>
22
  </div>
23
  <div class="trp-ls-shortcode-language">
 
24
  <a href="javascript:void(0)" class="trp-ls-shortcode-disabled-language trp-ls-disabled-language" title="<?php echo esc_attr( $current_language['name'] ); ?>">
25
  <?php echo $current_language_preference; // WPCS: ok. ?>
26
  </a>
 
27
  <?php foreach ( $other_languages as $code => $name ){
28
 
29
  $language_preference = $this->add_shortcode_preferences($shortcode_settings, $code, $name);
@@ -34,4 +24,21 @@ $current_language_preference = $this->add_shortcode_preferences($shortcode_setti
34
 
35
  <?php } ?>
36
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  </div>
3
 
4
  ?>
5
  <div class="trp-language-switcher trp-language-switcher-container" data-no-translation <?php echo ( isset( $_GET['trp-edit-translation'] ) && $_GET['trp-edit-translation'] == 'preview' ) ? 'data-trp-unpreviewable="trp-unpreviewable"' : '' ?>>
 
 
 
 
 
 
 
 
 
 
 
 
6
  <div class="trp-ls-shortcode-current-language">
7
  <a href="javascript:void(0)" class="trp-ls-shortcode-disabled-language trp-ls-disabled-language" title="<?php echo esc_attr( $current_language['name'] ); ?>">
8
  <?php echo $current_language_preference; // WPCS: ok. ?>
9
  </a>
10
  </div>
11
  <div class="trp-ls-shortcode-language">
12
+ <?php if ( apply_filters('trp_ls_shortcode_show_disabled_language', true, $current_language, $current_language_preference, $this->settings ) ){ ?>
13
  <a href="javascript:void(0)" class="trp-ls-shortcode-disabled-language trp-ls-disabled-language" title="<?php echo esc_attr( $current_language['name'] ); ?>">
14
  <?php echo $current_language_preference; // WPCS: ok. ?>
15
  </a>
16
+ <?php } ?>
17
  <?php foreach ( $other_languages as $code => $name ){
18
 
19
  $language_preference = $this->add_shortcode_preferences($shortcode_settings, $code, $name);
24
 
25
  <?php } ?>
26
  </div>
27
+ <script type="application/javascript">
28
+ // need to have the same with set from JS on both divs. Otherwise it can push stuff around in HTML
29
+ var trp_ls_shortcodes = document.querySelectorAll('.trp-language-switcher');
30
+ if ( trp_ls_shortcodes.length > 0) {
31
+ // get the last language switcher added
32
+ var trp_el = trp_ls_shortcodes[trp_ls_shortcodes.length - 1];
33
+ var trp_shortcode_language_item = trp_el.querySelector('.trp-ls-shortcode-language')
34
+
35
+ // set width
36
+ var trp_ls_shortcode_width = trp_shortcode_language_item.offsetWidth + 5;
37
+ trp_shortcode_language_item.style.width = trp_ls_shortcode_width + 'px';
38
+ trp_el.querySelector('.trp-ls-shortcode-current-language').style.width = trp_ls_shortcode_width + 'px';
39
+
40
+ // We're putting this on display: none after we have its width.
41
+ trp_shortcode_language_item.style.display = 'none';
42
+ }
43
+ </script>
44
  </div>
partials/machine-translation-settings-page.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div id="trp-main-settings" class="wrap">
2
+ <form method="post" action="options.php">
3
+ <?php settings_fields( 'trp_machine_translation_settings' ); ?>
4
+ <h1> <?php esc_html_e( 'TranslatePress Automatic Translation', 'translatepress-multilingual' );?></h1>
5
+ <?php do_action ( 'trp_settings_navigation_tabs' ); ?>
6
+
7
+ <table id="trp-options" class="form-table trp-machine-translation-options">
8
+ <tr>
9
+ <th scope="row"><?php esc_html_e( 'Enable Automatic Translation', 'translatepress-multilingual' ); ?> </th>
10
+ <td>
11
+ <select id="trp-machine-translation-enabled" name="trp_machine_translation_settings[machine-translation]" class="trp-select">
12
+ <option value="no" <?php selected( $this->settings['machine-translation'], 'no' ); ?>><?php esc_html_e( 'No', 'translatepress-multilingual') ?></option>
13
+ <option value="yes" <?php selected( $this->settings['machine-translation'], 'yes' ); ?>><?php esc_html_e( 'Yes', 'translatepress-multilingual') ?></option>
14
+ </select>
15
+
16
+ <p class="description">
17
+ <?php _e( 'Enable or disable the automatic translation of the site. Only untranslated strings will receive a translation.', 'translatepress-multilingual' ) ?>
18
+ </p>
19
+ </td>
20
+ </tr>
21
+
22
+ <tr>
23
+ <th scope="row"><?php esc_html_e( 'Translation Engine', 'translatepress-multilingual' ); ?> </th>
24
+ <td>
25
+ <?php $translation_engines = apply_filters( 'trp_machine_translation_engines', array() ); ?>
26
+
27
+ <?php foreach( $translation_engines as $engine ) : ?>
28
+ <label for="trp-translation-engine-<?= esc_attr( $engine['value'] ) ?>" style="margin-right:10px;">
29
+ <input type="radio" class="trp-translation-engine trp-radio" id="trp-translation-engine-<?= esc_attr( $engine['value'] ) ?>" name="trp_machine_translation_settings[translation-engine]" value="<?= esc_attr( $engine['value'] ) ?>" <?php checked( $this->settings['translation-engine'], $engine['value'] ); ?>>
30
+ <?= $engine['label'] ?>
31
+ </label>
32
+ <?php endforeach; ?>
33
+
34
+ <p class="description">
35
+ <?php _e( 'Choose which engine you want to use in order to automatically translate your website.', 'translatepress-multilingual' ) ?>
36
+ </p>
37
+ </td>
38
+ </tr>
39
+
40
+ <?php if( !class_exists( 'TRP_DeepL' ) ) : ?>
41
+ <tr style="display:none;">
42
+ <th scope="row"></th>
43
+ <td>
44
+ <p class="trp-upsell-multiple-languages" id="trp-upsell-deepl">
45
+ <?php
46
+ $url = trp_add_affiliate_id_to_link('https://translatepress.com/?utm_source=wpbackend&utm_medium=clientsite&utm_content=deepl_upsell&utm_campaign=tpfree');
47
+ $lnk = sprintf( wp_kses( __( '<strong>DeepL</strong> automatic translation is available as a premium add-on in <a href="%s" class="button button-primary" target="_blank" title="TranslatePress Pro">TranslatePress PRO</a>', 'translatepress-multilingual' ), array( 'strong' => array(), 'br' => array(), 'a' => array( 'href' => array(), 'title' => array(), 'target'=> array(), 'class' => array() ) ) ), esc_url( $url ) );
48
+ $lnk .= '<br/>' . __( 'By upgrading you\'ll get access to all paid add-ons, premium support and help fund the future development of TranslatePress.', 'translatepress-multilingual' );
49
+ echo $lnk;
50
+ ?>
51
+ </p>
52
+ </td>
53
+ </tr>
54
+ <?php endif; ?>
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
+
70
+ <tr>
71
+ <th scope=row><?php esc_html_e( 'Block Crawlers', 'translatepress-multilingual' ); ?></th>
72
+ <td>
73
+ <label>
74
+ <input type=checkbox name="trp_machine_translation_settings[block-crawlers]" value="yes" <?php isset( $this->settings['block-crawlers'] ) ? checked( $this->settings['block-crawlers'], 'yes' ) : checked( '', 'yes' ); ?>>
75
+ <?php _e( 'Yes' , 'translatepress-multilingual' ); ?>
76
+ </label>
77
+ <p class="description">
78
+ <?php esc_html_e( 'Block crawlers from triggering automatic translations on your website.', 'translatepress-multilingual' ); ?>
79
+ </p>
80
+ </td>
81
+ </tr>
82
+
83
+ <tr>
84
+ <th scope="row"><?php esc_html_e( 'Limit machine translation / characters per day', 'translatepress-multilingual' ); ?></th>
85
+ <td>
86
+ <label>
87
+ <input type="number" name="trp_machine_translation_settings[machine_translation_limit]" value="<?php echo isset( $this->settings['machine_translation_limit'] ) ? $this->settings['machine_translation_limit'] : 1000000; ?>">
88
+ </label>
89
+ <p class="description">
90
+ <?php esc_html_e( 'Add a limit to the number of automatically translated characters so you can better budget your project.', 'translatepress-multilingual' ); ?>
91
+ </p>
92
+ </td>
93
+ </tr>
94
+
95
+ <tr>
96
+ <th scope="row"><?php esc_html_e( 'Today\'s character count:', 'translatepress-multilingual' ); ?></th>
97
+ <td>
98
+ <strong><?php echo isset( $this->settings['machine_translation_counter'] ) ? $this->settings['machine_translation_counter'] : 0; ?></strong>
99
+ (<?php echo isset( $this->settings['machine_translation_counter_date'] ) ? $this->settings['machine_translation_counter_date'] : date('Y-m-d'); ?>)
100
+ </td>
101
+ </tr>
102
+
103
+ <tr>
104
+ <th scope=row><?php esc_html_e( 'Log machine translation queries.', 'translatepress-multilingual' ); ?></th>
105
+ <td>
106
+ <label>
107
+ <input type=checkbox name="trp_machine_translation_settings[machine_translation_log]" value="yes" <?php isset( $this->settings['machine_translation_log'] ) ? checked( $this->settings['machine_translation_log'], 'yes' ) : checked( '', 'yes' ); ?>>
108
+ <?php _e( 'Yes' , 'translatepress-multilingual' ); ?>
109
+ </label>
110
+ <p class="description">
111
+ <?php echo wp_kses( __( '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.)', 'translatepress-multilingual' ), array( 'br' => array(), 'a' => array( 'href' => array(), 'title' => array(), 'target' => array() ) ) ); ?>
112
+ </p>
113
+ </td>
114
+ </tr>
115
+
116
+ <?php do_action ( 'trp_machine_translation_extra_settings_bottom', $this->settings ); ?>
117
+ </table>
118
+
119
+ <p class="submit"><input type="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes' ); ?>" /></p>
120
+ </form>
121
+ </div>
partials/main-settings-language-selector.php CHANGED
@@ -68,4 +68,4 @@
68
  ?>
69
  </p>
70
  </td>
71
- </tr>
68
  ?>
69
  </p>
70
  </td>
71
+ </tr>
partials/main-settings-page.php CHANGED
@@ -72,32 +72,6 @@
72
  </td>
73
  </tr>
74
 
75
- <tr>
76
- <th scope="row"><?php esc_html_e( 'Google Translate', 'translatepress-multilingual' ); ?> </th>
77
- <td>
78
- <select id="trp-g-translate" name="trp_settings[g-translate]" class="trp-select">
79
- <option value="no" <?php selected( $this->settings['g-translate'], 'no' ); ?>><?php esc_html_e( 'No', 'translatepress-multilingual') ?></option>
80
- <option value="yes" <?php selected( $this->settings['g-translate'], 'yes' ); ?>><?php esc_html_e( 'Yes', 'translatepress-multilingual') ?></option>
81
- </select>
82
- <p class="description">
83
- <?php echo wp_kses( __( 'Enable or disable the automatic translation of the site with Google Translate. Only untranslated strings will receive a translation.<br>You can later edit these automatic translations.<br>Note: Not all languages support automatic translation. Please consult the <a href="https://cloud.google.com/translate/docs/languages" target="_blank" title="Automatic translation supported languages.">supported languages list</a>. ', 'translatepress-multilingual' ), [ 'a' => [ 'href' => [], 'title' => [], 'target' => [] ], 'br' => [] ] ); ?>
84
- </p>
85
- </td>
86
- </tr>
87
-
88
- <tr>
89
- <th scope="row"><?php esc_html_e( 'Google Translate API Key', 'translatepress-multilingual' ); ?> </th>
90
- <td>
91
- <input type="text" id="trp-g-translate-key" class="trp-text-input" name="trp_settings[g-translate-key]" value="<?php if( !empty( $this->settings['g-translate-key'] ) ) echo esc_attr( $this->settings['g-translate-key']);?>"/>
92
- <?php if( !empty( $this->settings['g-translate-key'] ) ) echo '<a href="'.esc_url( admin_url( 'admin.php?page=trp_test_google_key_page' ) ).'">'.esc_html__( "Test API key", 'translatepress-multilingual' ).'</a>'; ?>
93
- <p class="description">
94
- <?php echo wp_kses( __( 'Visit <a href="https://cloud.google.com/docs/authentication/api-keys" target="_blank">this link</a> to see how you can set up an API key, <strong>control API costs</strong> and set HTTP referrer restrictions.', 'translatepress-multilingual' ), [ 'a' => [ 'href' => [], 'title' => [], 'target' => [] ], 'strong' => [] ] ); ?>
95
- <br><?php echo sprintf( esc_html__( 'Your HTTP referrer is: %s', 'translatepress-multilingual' ), $gtranslate_referer ); ?>
96
- </p>
97
- </td>
98
-
99
- </tr>
100
-
101
  <tr>
102
  <th scope="row"><?php esc_html_e( 'Language Switcher', 'translatepress-multilingual' ); ?> </th>
103
  <td>
72
  </td>
73
  </tr>
74
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  <tr>
76
  <th scope="row"><?php esc_html_e( 'Language Switcher', 'translatepress-multilingual' ); ?> </th>
77
  <td>
partials/test-api-settings-page.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $trp = TRP_Translate_Press::get_trp_instance();
4
+ $machine_translator = $trp->get_component( 'machine_translator' );
5
+ $response = $machine_translator->test_request();
6
+ $api_key = $machine_translator->get_api_key();
7
+ ?>
8
+
9
+ <div id="trp-addons-page" class="wrap">
10
+
11
+ <h1> <?php esc_html_e( 'TranslatePress Settings', 'translatepress-multilingual' );?></h1>
12
+ <?php do_action ( 'trp_settings_navigation_tabs' ); ?>
13
+
14
+ <div class="grid feat-header">
15
+ <div class="grid-cell">
16
+ <?php if( $api_key != false ) : ?>
17
+ <h2><?php esc_html_e('API Key from settings page:', 'translatepress-multilingual');?> <span style="font-family:monospace"><?php echo $api_key; ?></span></h2>
18
+ <?php endif; ?>
19
+
20
+ <h2><?php esc_html_e('HTTP Referrer:', 'translatepress-multilingual');?> <span style="font-family:monospace"><?php echo esc_url( $machine_translator->get_referer() ); ?></span></h2>
21
+ <p><?php esc_html_e('Use this HTTP Referrer if the API lets you restrict key usage from its Dashboard.', 'translatepress-multilingual'); ?></p>
22
+
23
+ <h3><?php esc_html_e('Response:', 'translatepress-multilingual');?></h3>
24
+ <pre>
25
+ <?php print_r( $response["response"] ); ?>
26
+ </pre>
27
+ <h3><?php esc_html_e('Response Body:', 'translatepress-multilingual');?></h3>
28
+ <pre>
29
+ <?php print_r( esc_html( $response["body"] ) ); ?>
30
+ </pre>
31
+
32
+ <h3><?php esc_html_e('Entire Response From wp_remote_get():', 'translatepress-multilingual');?></h3>
33
+ <pre>
34
+ <?php print_r( $response ); ?>
35
+ </pre>
36
+ </div>
37
+ </div>
38
+
39
+
40
+ </div>
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: translate, translation, multilingual, automatic translation, bilingual, fr
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.8
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -64,6 +64,7 @@ TranslatePress - Multilingual has a range of [premium Add-ons](https://translate
64
  * [Browse as User Role](https://translatepress.com/docs/addons/browse-as-role/?utm_source=wp.org&utm_medium=tp-description-page&utm_campaign=TPFree) - view and translate content that is visible only to a particular user role
65
  * [Navigation Based on Language](https://translatepress.com/docs/addons/navigate-based-language/?utm_source=wp.org&utm_medium=tp-description-page&utm_campaign=TPFree) - configure and display different menu items for different languages
66
  * [Automatic User Language Detection](https://translatepress.com/docs/addons/automatic-user-language-detection/?utm_source=wp.org&utm_medium=tp-description-page&utm_campaign=TPFree) - redirect first time visitors to their preferred language based on their browser settings or IP address
 
67
 
68
  **Free Add-ons**
69
 
@@ -142,6 +143,22 @@ For more information please check out [TranslatePress - Multilingual plugin docu
142
 
143
 
144
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  = 1.5.8 =
146
  * Added machine translation limit
147
  * Added setting for translation memory limit
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
 
64
  * [Browse as User Role](https://translatepress.com/docs/addons/browse-as-role/?utm_source=wp.org&utm_medium=tp-description-page&utm_campaign=TPFree) - view and translate content that is visible only to a particular user role
65
  * [Navigation Based on Language](https://translatepress.com/docs/addons/navigate-based-language/?utm_source=wp.org&utm_medium=tp-description-page&utm_campaign=TPFree) - configure and display different menu items for different languages
66
  * [Automatic User Language Detection](https://translatepress.com/docs/addons/automatic-user-language-detection/?utm_source=wp.org&utm_medium=tp-description-page&utm_campaign=TPFree) - redirect first time visitors to their preferred language based on their browser settings or IP address
67
+ * [DeepL Automatic Translation](https://translatepress.com/docs/addons/deepl-automatic-translation/?utm_source=wp.org&utm_medium=tp-description-page&utm_campaign=TPFree) - The DeepL Automatic Translation add-on lets you automatically translate your website through the DeepL API
68
 
69
  **Free Add-ons**
70
 
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
149
+ * Compatibility with WooCommerce Checkout Add-Ons plugin
150
+ * Improved integration with WooCommerce PDF Invoices & Packing Slips by translating product name and options in invoices
151
+ * Removed possible trp-wrap tags ending up in front-end content
152
+ * Improved display of license error messages
153
+ * Corrected and added missing flags for 7 languages
154
+ * Eliminate need for jQuery in language switcher shortcode
155
+ * Fixed issue with translating admin ajax JSON strings
156
+ * Fixed issue with <text> html tags breaking HTML
157
+ * Fixed warning in when saving advanced settings
158
+ * Fixed trpst characters in WooCommerce shipping calculator
159
+ * Fixed getting translations on fallback admin-ajax
160
+ * New integration with Deepl API Automatic translation in PRO versions
161
+
162
  = 1.5.8 =
163
  * Added machine translation limit
164
  * Added setting for translation memory limit