TranslatePress – Translate Multilingual sites - Version 2.3.0

Version Description

  • Added compatibility with Elementor Containers for exclude/include in certain language
  • Added Advanced option to change html lang attribute to a region independent form
  • Fixed issue with ACF plugin when saving metabox fields
  • Fixed issue with the option to Exclude strings from automatic translation when the excluded text is a substring of another excluded text
  • Fixed notice in PHP 8+ versions about passing null variables being deprecated
Download this release

Release Info

Developer razvan.mo
Plugin Icon 128x128 TranslatePress – Translate Multilingual sites
Version 2.3.0
Comparing to
See all releases

Code changes from version 2.2.9 to 2.3.0

class-translate-press.php CHANGED
@@ -60,7 +60,7 @@ class TRP_Translate_Press{
60
  define( 'TRP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
61
  define( 'TRP_PLUGIN_BASE', plugin_basename( __DIR__ . '/index.php' ) );
62
  define( 'TRP_PLUGIN_SLUG', 'translatepress-multilingual' );
63
- define( 'TRP_PLUGIN_VERSION', '2.2.9' );
64
 
65
  wp_cache_add_non_persistent_groups(array('trp'));
66
 
@@ -344,6 +344,7 @@ class TRP_Translate_Press{
344
  $this->loader->add_filter( 'language_attributes', $this->url_converter, 'change_lang_attr_in_html_tag', 10, 1 );
345
  $this->loader->add_filter('trp_is_file', $this->url_converter, 'does_url_contains_array', 10, 2);
346
  $this->loader->add_filter('trp_hreflang', $this->url_converter, 'replace_iso_2_with_iso_3_for_hreflang', 10, 2);
 
347
 
348
 
349
  $this->loader->add_filter( 'widget_text', null, 'do_shortcode', 11 );
60
  define( 'TRP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
61
  define( 'TRP_PLUGIN_BASE', plugin_basename( __DIR__ . '/index.php' ) );
62
  define( 'TRP_PLUGIN_SLUG', 'translatepress-multilingual' );
63
+ define( 'TRP_PLUGIN_VERSION', '2.3.0' );
64
 
65
  wp_cache_add_non_persistent_groups(array('trp'));
66
 
344
  $this->loader->add_filter( 'language_attributes', $this->url_converter, 'change_lang_attr_in_html_tag', 10, 1 );
345
  $this->loader->add_filter('trp_is_file', $this->url_converter, 'does_url_contains_array', 10, 2);
346
  $this->loader->add_filter('trp_hreflang', $this->url_converter, 'replace_iso_2_with_iso_3_for_hreflang', 10, 2);
347
+ $this->loader->add_filter('wp_footer', $this->url_converter, 'add_tp_language_lang_attribute', 1);
348
 
349
 
350
  $this->loader->add_filter( 'widget_text', null, 'do_shortcode', 11 );
includes/advanced-settings/html-lang-remove-locale.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ add_filter( 'trp_register_advanced_settings', 'trp_register_html_lang_attribute', 1001 );
4
+ function trp_register_html_lang_attribute( $settings_array ){
5
+ $settings_array[] = array(
6
+ 'name' => 'html_lang_remove_locale',
7
+ 'type' => 'radio',
8
+ 'options' => array( 'default', 'regional' ),
9
+ 'default' => 'default',
10
+ 'labels' => array( esc_html__( 'Default (example: en-US, fr-CA, etc.)', 'translatepress-multilingual' ), esc_html__( 'Regional (example: en, fr, es, etc.)', 'translatepress-multilingual' ) ),
11
+ 'label' => esc_html__( 'HTML Lang Attribute Format', 'translatepress-multilingual' ),
12
+ 'description' => wp_kses( __( 'Change lang attribute of the html tag to a format that includes country regional or not. <br>In HTML, the lang attribute (<html lang="en-US">) should be used to specify the language of text content so that the browser can correctly display or process your content (eg. for hyphenation, styling, spell checking, etc).', 'translatepress-multilingual' ), array( 'br' => array() ) ),
13
+ );
14
+ return $settings_array;
15
+ }
16
+
17
+ add_filter( 'trp_add_default_lang_tags', 'trp_display_default_lang_tag' );
18
+ function trp_display_default_lang_tag( $display ){
19
+ $option = get_option( 'trp_advanced_settings', true );
20
+ if ( isset( $option['html_lang_remove_locale'] ) && $option['html_lang_remove_locale'] === 'default' ) {
21
+ return true;
22
+ }
23
+ return false;
24
+ }
25
+
26
+ add_filter( 'trp_add_regional_lang_tags', 'trp_display_regional_lang_tag' );
27
+ function trp_display_regional_lang_tag( $display ){
28
+
29
+ $option = get_option( 'trp_advanced_settings', true );
30
+ if ( isset( $option['html_lang_remove_locale'] ) && $option['html_lang_remove_locale'] === 'regional' ) {
31
+ return true;
32
+ }
33
+ return false;
34
+ }
includes/class-advanced-tab.php CHANGED
@@ -232,6 +232,7 @@ class TRP_Advanced_Tab {
232
  include_once (TRP_PLUGIN_DIR . 'includes/advanced-settings/opposite-flag-shortcode.php');
233
  include_once (TRP_PLUGIN_DIR . 'includes/advanced-settings/open-language-switcher-shortcode-on-click.php');
234
  include_once(TRP_PLUGIN_DIR . 'includes/advanced-settings/hreflang-remove-locale.php');
 
235
  }
236
 
237
  /*
232
  include_once (TRP_PLUGIN_DIR . 'includes/advanced-settings/opposite-flag-shortcode.php');
233
  include_once (TRP_PLUGIN_DIR . 'includes/advanced-settings/open-language-switcher-shortcode-on-click.php');
234
  include_once(TRP_PLUGIN_DIR . 'includes/advanced-settings/hreflang-remove-locale.php');
235
+ include_once(TRP_PLUGIN_DIR . 'includes/advanced-settings/html-lang-remove-locale.php');
236
  }
237
 
238
  /*
includes/class-elementor-language-for-blocks.php CHANGED
@@ -15,6 +15,10 @@ class TRP_Elementor {
15
  array(
16
  'element' => 'section',
17
  'action' => 'section_advanced',
 
 
 
 
18
  )
19
  );
20
  public $section_name_show = 'trp_section_show';
@@ -37,6 +41,9 @@ class TRP_Elementor {
37
  // Filter sections display & add custom messages
38
  add_action( 'elementor/frontend/section/should_render', array( $this, 'section_render' ), 10, 2 );
39
 
 
 
 
40
  // Add data-no-translation to elements that are restricted to a particular language
41
  add_action( 'elementor/element/after_add_attributes', array( $this, 'add_attributes' ) );
42
 
15
  array(
16
  'element' => 'section',
17
  'action' => 'section_advanced',
18
+ ),
19
+ array(
20
+ 'element' => 'container',
21
+ 'action' => 'section_layout',
22
  )
23
  );
24
  public $section_name_show = 'trp_section_show';
41
  // Filter sections display & add custom messages
42
  add_action( 'elementor/frontend/section/should_render', array( $this, 'section_render' ), 10, 2 );
43
 
44
+ // Filter container display
45
+ add_action( 'elementor/frontend/container/should_render', array( $this, 'section_render' ), 10, 2 );
46
+
47
  // Add data-no-translation to elements that are restricted to a particular language
48
  add_action( 'elementor/element/after_add_attributes', array( $this, 'add_attributes' ) );
49
 
includes/class-machine-translator.php CHANGED
@@ -29,6 +29,7 @@ class TRP_Machine_Translator {
29
  $this->trp_languages = $trp->get_component('languages');
30
  }
31
  $this->machine_translation_codes = $this->trp_languages->get_iso_codes($this->settings['translation-languages']);
 
32
  }
33
 
34
  /**
@@ -322,10 +323,12 @@ class TRP_Machine_Translator {
322
 
323
  $strings = array_unique($strings);
324
  $original_strings = $strings;
 
325
  foreach ($strings as $key => $string) {
326
  /* html_entity_decode is needed before replacing the character "#" from the list because characters like &#8220; (8220 utf8)
327
  * will get an extra space after '&' which will break the character, rendering it like this: & #8220;
328
  */
 
329
  $strings[$key] = str_replace($trp_exclude_words_from_automatic_translation, $placeholders, html_entity_decode( $string ));
330
  $strings[$key] = trp_do_these_shortcodes( $strings[$key], $shortcode_tags_to_execute );
331
  }
@@ -349,6 +352,24 @@ class TRP_Machine_Translator {
349
  }
350
  }
351
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
352
 
353
  public function test_request(){}
354
 
29
  $this->trp_languages = $trp->get_component('languages');
30
  }
31
  $this->machine_translation_codes = $this->trp_languages->get_iso_codes($this->settings['translation-languages']);
32
+ add_filter( 'trp_exclude_words_from_automatic_translation', array( $this,'sort_exclude_words_from_automatic_translation_array'), 99999, 1);
33
  }
34
 
35
  /**
323
 
324
  $strings = array_unique($strings);
325
  $original_strings = $strings;
326
+
327
  foreach ($strings as $key => $string) {
328
  /* html_entity_decode is needed before replacing the character "#" from the list because characters like &#8220; (8220 utf8)
329
  * will get an extra space after '&' which will break the character, rendering it like this: & #8220;
330
  */
331
+
332
  $strings[$key] = str_replace($trp_exclude_words_from_automatic_translation, $placeholders, html_entity_decode( $string ));
333
  $strings[$key] = trp_do_these_shortcodes( $strings[$key], $shortcode_tags_to_execute );
334
  }
352
  }
353
  }
354
 
355
+ /**
356
+ * @param $trp_exclude_words_from_automatic_translation
357
+ * @return mixed
358
+ *
359
+ * We need to sort the $trp_exclude_words_from_automatic_translation array descending because we risk to not translate excluded multiple words when one
360
+ * is repeated ( example: Facebook, Facebook Store, Facebook View, because Facebook was the first one in the array it was replaced with a code and the
361
+ * other words group ( Store, View) were translated)
362
+ */
363
+ public function sort_exclude_words_from_automatic_translation_array($trp_exclude_words_from_automatic_translation){
364
+ usort($trp_exclude_words_from_automatic_translation, array($this,"sort_array"));
365
+
366
+ return $trp_exclude_words_from_automatic_translation;
367
+ }
368
+
369
+ public function sort_array($a, $b){
370
+ return strlen($b)-strlen($a);
371
+ }
372
+
373
 
374
  public function test_request(){}
375
 
includes/class-translation-manager.php CHANGED
@@ -666,6 +666,22 @@ class TRP_Translation_Manager
666
  remove_action( 'trp_call_gettext_filters', array( $this, 'verify_locale_of_loaded_textdomain' ) );
667
  }
668
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
669
  /**
670
  * Function that determines if an ajax request came from the frontend
671
  * @return bool
666
  remove_action( 'trp_call_gettext_filters', array( $this, 'verify_locale_of_loaded_textdomain' ) );
667
  }
668
 
669
+ /**
670
+ * Function that determines if a request is a rest api request based on the URL.
671
+ * @return bool
672
+ */
673
+ static function is_rest_api_request() {
674
+ if ( empty( $_SERVER['REQUEST_URI'] ) ) {
675
+ // Probably a CLI request
676
+ return false;
677
+ }
678
+
679
+ $rest_prefix = trailingslashit( rest_get_url_prefix() );
680
+ $is_rest_api_request = strpos( $_SERVER['REQUEST_URI'], $rest_prefix ) !== false; /* phpcs:ignore */
681
+
682
+ return apply_filters( 'trp_is_rest_api_request', $is_rest_api_request );
683
+ }
684
+
685
  /**
686
  * Function that determines if an ajax request came from the frontend
687
  * @return bool
includes/class-url-converter.php CHANGED
@@ -236,12 +236,31 @@ class TRP_Url_Converter {
236
  global $TRP_LANGUAGE;
237
  $lang = get_bloginfo('language');
238
  if ( $lang && !empty($TRP_LANGUAGE) ) {
239
- $output = str_replace( 'lang="'. $lang .'"', 'lang="'. str_replace('_', '-', $TRP_LANGUAGE ) .'"', $output );
 
 
 
 
 
 
 
240
  }
241
 
242
  return $output;
243
  }
244
 
 
 
 
 
 
 
 
 
 
 
 
 
245
  /**
246
  * Returns language-specific url for given language.
247
  *
@@ -692,7 +711,18 @@ class TRP_Url_Converter {
692
  if ($abs_home_url_obj->getPath() == "/"){
693
  $abs_home_url_obj->setPath('');
694
  }
695
- $possible_path = str_replace( $abs_home_url_obj->getPath(), '', $url_obj->getPath() );
 
 
 
 
 
 
 
 
 
 
 
696
  $lang = ltrim( $possible_path,'/' );
697
  $lang = explode('/', $lang);
698
  if( $lang == false ){
@@ -732,13 +762,21 @@ class TRP_Url_Converter {
732
 
733
  $req_uri = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( $_SERVER['REQUEST_URI'] ) : '';
734
 
735
- $home_path = trim( parse_url( $this->get_abs_home(), PHP_URL_PATH ), '/' );
 
 
 
 
 
 
 
 
736
  $home_path_regex = sprintf( '|^%s|i', preg_quote( $home_path, '|' ) );
737
 
738
  // Trim path info from the end and the leading home path from the front.
739
  $req_uri = ltrim($req_uri, '/');
740
  $req_uri = preg_replace( $home_path_regex, '', $req_uri );
741
- $req_uri = trim($this->get_abs_home(), '/') . '/' . ltrim( $req_uri, '/' );
742
 
743
 
744
  if ( function_exists('apply_filters') ) $req_uri = apply_filters('trp_curpageurl', $req_uri);
236
  global $TRP_LANGUAGE;
237
  $lang = get_bloginfo('language');
238
  if ( $lang && !empty($TRP_LANGUAGE) ) {
239
+ if ( apply_filters( 'trp_add_default_lang_tags', true ) ) {
240
+ $output = str_replace( 'lang="' . $lang . '"', 'lang="' . str_replace( '_', '-', $TRP_LANGUAGE ) . '"', $output );
241
+ }
242
+ if ( apply_filters( 'trp_add_regional_lang_tags', true ) ) {
243
+ $language = strtok($TRP_LANGUAGE, '_');
244
+ $output = str_replace( 'lang="' . $lang . '"', 'lang="' . $language . '"', $output );
245
+
246
+ }
247
  }
248
 
249
  return $output;
250
  }
251
 
252
+ /**
253
+ * @param $output
254
+ * @return $output
255
+ *
256
+ * adds a new attribute in footer, tp_language_lang, for Automatic User Language Detection to rely on for finding the current language
257
+ */
258
+ public function add_tp_language_lang_attribute(){
259
+ global $TRP_LANGUAGE;
260
+ $html ='<template id="tp-language" lang="'. esc_attr($TRP_LANGUAGE) . '"></template>';
261
+ echo $html; /* phpcs:ignore *///ignored because the html is constructed by us
262
+ }
263
+
264
  /**
265
  * Returns language-specific url for given language.
266
  *
711
  if ($abs_home_url_obj->getPath() == "/"){
712
  $abs_home_url_obj->setPath('');
713
  }
714
+
715
+ $abs_home = $abs_home_url_obj->getPath();
716
+
717
+ //in some cases $abs_home_url_obj->getPath() can be null and this causes a PHP 8 notice
718
+ if ($abs_home !== null) {
719
+ $abs_home = $abs_home_url_obj->getPath();
720
+ }else{
721
+ $abs_home = '';
722
+ }
723
+ //we make sure that the path is the actual path and not a folder
724
+ $possible_path = str_replace( $abs_home, '', $url_obj->getPath() );
725
+
726
  $lang = ltrim( $possible_path,'/' );
727
  $lang = explode('/', $lang);
728
  if( $lang == false ){
762
 
763
  $req_uri = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( $_SERVER['REQUEST_URI'] ) : '';
764
 
765
+ //in some cases $this->get_abs_home() can be null and this causes a PHP 8 notice
766
+ $abs_home = $this->get_abs_home();
767
+ if ( $this->get_abs_home() !== null) {
768
+ $abs_home = $this->get_abs_home();
769
+ }else{
770
+ $abs_home = '';
771
+ }
772
+
773
+ $home_path = trim( parse_url( $abs_home, PHP_URL_PATH ), '/' );
774
  $home_path_regex = sprintf( '|^%s|i', preg_quote( $home_path, '|' ) );
775
 
776
  // Trim path info from the end and the leading home path from the front.
777
  $req_uri = ltrim($req_uri, '/');
778
  $req_uri = preg_replace( $home_path_regex, '', $req_uri );
779
+ $req_uri = trim($abs_home, '/') . '/' . ltrim( $req_uri, '/' );
780
 
781
 
782
  if ( function_exists('apply_filters') ) $req_uri = apply_filters('trp_curpageurl', $req_uri);
index.php CHANGED
@@ -3,14 +3,14 @@
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: 2.2.9
7
  Author: Cozmoslabs, Razvan Mocanu, Madalin Ungureanu, Cristophor Hurduban
8
  Author URI: https://cozmoslabs.com/
9
  Text Domain: translatepress-multilingual
10
  Domain Path: /languages
11
  License: GPL2
12
  WC requires at least: 2.5.0
13
- WC tested up to: 6.5.1
14
 
15
  == Copyright ==
16
  Copyright 2017 Cozmoslabs (www.cozmoslabs.com)
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: 2.3.0
7
  Author: Cozmoslabs, Razvan Mocanu, Madalin Ungureanu, Cristophor Hurduban
8
  Author URI: https://cozmoslabs.com/
9
  Text Domain: translatepress-multilingual
10
  Domain Path: /languages
11
  License: GPL2
12
  WC requires at least: 2.5.0
13
+ WC tested up to: 6.6.1
14
 
15
  == Copyright ==
16
  Copyright 2017 Cozmoslabs (www.cozmoslabs.com)
languages/translatepress-multilingual.catalog.php CHANGED
@@ -289,7 +289,7 @@
289
  <?php __("Add a limit to the number of automatically translated characters so you can better budget your project.", "translatepress-multilingual"); ?>
290
  <?php __("Today's character count:", "translatepress-multilingual"); ?>
291
  <?php __("Log machine translation queries.", "translatepress-multilingual"); ?>
292
- <?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"); ?>
293
  <?php __("All Languages", "translatepress-multilingual"); ?>
294
  <?php __("Language", "translatepress-multilingual"); ?>
295
  <?php __("Formality", "translatepress-multilingual"); ?>
@@ -301,7 +301,7 @@
301
  <?php __("Are you sure you want to remove this language?", "translatepress-multilingual"); ?>
302
  <?php __("Choose...", "translatepress-multilingual"); ?>
303
  <?php __("Custom Languages", "translatepress-multilingual"); ?>
304
- <?php __("Select the languages you wish to make your website available in.<br>The Formality field is used by Automatic Translation to decide whether the translated text should lean towards formal or informal language. For now, it is supported only for a few languages and only by <a href=\"%s\">DeepL</a>.", "translatepress-multilingual"); ?>
305
  <?php __("To add <strong>more than two languages</strong> and support for SEO Title, Description, Slug and more check out <a href=\"%1$s\" target=\"_blank\" title=\"%2$s\">%2$s</a>.", "translatepress-multilingual"); ?>
306
  <?php __("TranslatePress Advanced Add-ons", "translatepress-multilingual"); ?>
307
  <?php __("Not only are you getting extra features and premium support, but you also help fund the future development of TranslatePress.", "translatepress-multilingual"); ?>
@@ -409,6 +409,10 @@
409
  <?php __("Remove Region Independent Locale", "translatepress-multilingual"); ?>
410
  <?php __("Remove duplicate hreflang", "translatepress-multilingual"); ?>
411
  <?php __("Choose which hreflang tags will appear on your website.<br/>We recommend showing both types of hreflang tags as indicated by <a href=\"https://developers.google.com/search/docs/advanced/crawling/localized-versions\" title=\"Google Crawling\" target=\"_blank\">Google documentation</a>.<br/>Removing Country Locale when having multiple Country Locales of the same language (ex. English UK and English US) will result in showing one hreflang tag with link to just one of the region locales for that language.", "translatepress-multilingual"); ?>
 
 
 
 
412
  <?php __("Open language switcher only on click", "translatepress-multilingual"); ?>
413
  <?php __("Open the language switcher shortcode by clicking on it instead of hovering.<br> Close it by clicking on it, anywhere else on the screen or by pressing the escape key. This will affect only the shortcode language switcher.", "translatepress-multilingual"); ?>
414
  <?php __("Show opposite language in the language switcher", "translatepress-multilingual"); ?>
289
  <?php __("Add a limit to the number of automatically translated characters so you can better budget your project.", "translatepress-multilingual"); ?>
290
  <?php __("Today's character count:", "translatepress-multilingual"); ?>
291
  <?php __("Log machine translation queries.", "translatepress-multilingual"); ?>
292
+ <?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/\" target=\"_blank\">WP Data Access</a> to browse the logs or directly from your database manager (PHPMyAdmin, etc.)", "translatepress-multilingual"); ?>
293
  <?php __("All Languages", "translatepress-multilingual"); ?>
294
  <?php __("Language", "translatepress-multilingual"); ?>
295
  <?php __("Formality", "translatepress-multilingual"); ?>
301
  <?php __("Are you sure you want to remove this language?", "translatepress-multilingual"); ?>
302
  <?php __("Choose...", "translatepress-multilingual"); ?>
303
  <?php __("Custom Languages", "translatepress-multilingual"); ?>
304
+ <?php __("Select the languages you wish to make your website available in.<br>The Formality field is used by Automatic Translation to decide whether the translated text should lean towards formal or informal language. For now, it is supported only for a few languages and only by <a href=\"%s\" target=\"_blank\">DeepL</a>.", "translatepress-multilingual"); ?>
305
  <?php __("To add <strong>more than two languages</strong> and support for SEO Title, Description, Slug and more check out <a href=\"%1$s\" target=\"_blank\" title=\"%2$s\">%2$s</a>.", "translatepress-multilingual"); ?>
306
  <?php __("TranslatePress Advanced Add-ons", "translatepress-multilingual"); ?>
307
  <?php __("Not only are you getting extra features and premium support, but you also help fund the future development of TranslatePress.", "translatepress-multilingual"); ?>
409
  <?php __("Remove Region Independent Locale", "translatepress-multilingual"); ?>
410
  <?php __("Remove duplicate hreflang", "translatepress-multilingual"); ?>
411
  <?php __("Choose which hreflang tags will appear on your website.<br/>We recommend showing both types of hreflang tags as indicated by <a href=\"https://developers.google.com/search/docs/advanced/crawling/localized-versions\" title=\"Google Crawling\" target=\"_blank\">Google documentation</a>.<br/>Removing Country Locale when having multiple Country Locales of the same language (ex. English UK and English US) will result in showing one hreflang tag with link to just one of the region locales for that language.", "translatepress-multilingual"); ?>
412
+ <?php __("Default (example: en-US, fr-CA, etc.)", "translatepress-multilingual"); ?>
413
+ <?php __("Regional (example: en, fr, es, etc.)", "translatepress-multilingual"); ?>
414
+ <?php __("HTML Lang Attribute Format", "translatepress-multilingual"); ?>
415
+ <?php __("Change lang attribute of the html tag to a format that includes country regional or not. <br>In HTML, the lang attribute (<html lang=\"en-US\">) should be used to specify the language of text content so that the browser can correctly display or process your content (eg. for hyphenation, styling, spell checking, etc).", "translatepress-multilingual"); ?>
416
  <?php __("Open language switcher only on click", "translatepress-multilingual"); ?>
417
  <?php __("Open the language switcher shortcode by clicking on it instead of hovering.<br> Close it by clicking on it, anywhere else on the screen or by pressing the escape key. This will affect only the shortcode language switcher.", "translatepress-multilingual"); ?>
418
  <?php __("Show opposite language in the language switcher", "translatepress-multilingual"); ?>
languages/translatepress-multilingual.pot CHANGED
@@ -49,23 +49,23 @@ msgstr ""
49
  msgid "Settings saved."
50
  msgstr ""
51
 
52
- #: includes/class-advanced-tab.php:318, includes/class-error-manager.php:172, partials/machine-translation-settings-page.php:17, partials/machine-translation-settings-page.php:121, partials/machine-translation-settings-page.php:141, partials/machine-translation-settings-page.php:192, partials/main-settings-page.php:42, partials/main-settings-page.php:55, partials/main-settings-page.php:68
53
  msgid "Yes"
54
  msgstr ""
55
 
56
- #: includes/class-advanced-tab.php:528, includes/class-advanced-tab.php:539, includes/class-advanced-tab.php:633, includes/class-advanced-tab.php:664
57
  msgid "Are you sure you want to remove this item?"
58
  msgstr ""
59
 
60
- #: includes/class-advanced-tab.php:528, includes/class-advanced-tab.php:539, includes/class-advanced-tab.php:633, includes/class-advanced-tab.php:664, partials/main-settings-language-selector.php:60, add-ons-advanced/extra-languages/partials/language-selector-pro.php:62
61
  msgid "Remove"
62
  msgstr ""
63
 
64
- #: includes/class-advanced-tab.php:539, includes/class-advanced-tab.php:664, partials/main-settings-language-selector.php:102, add-ons-advanced/extra-languages/partials/language-selector-pro.php:103
65
  msgid "Add"
66
  msgstr ""
67
 
68
- #: includes/class-advanced-tab.php:617, includes/class-advanced-tab.php:651
69
  msgid "Select..."
70
  msgstr ""
71
 
@@ -121,59 +121,59 @@ msgstr ""
121
  msgid "Others"
122
  msgstr ""
123
 
124
- #: includes/class-elementor-language-for-blocks.php:91
125
  msgid "Restrict by Language"
126
  msgstr ""
127
 
128
- #: includes/class-elementor-language-for-blocks.php:109, includes/class-wp-bakery-language-for-blocks.php:138
129
  msgid "Exclude from Language"
130
  msgstr ""
131
 
132
- #: includes/class-elementor-language-for-blocks.php:124, includes/class-wp-bakery-language-for-blocks.php:98
133
  msgid "Restrict element to language"
134
  msgstr ""
135
 
136
- #: includes/class-elementor-language-for-blocks.php:126, includes/class-wp-bakery-language-for-blocks.php:101
137
  msgid "Show this element only in one language."
138
  msgstr ""
139
 
140
- #: includes/class-elementor-language-for-blocks.php:132
141
  msgid "Enable translation"
142
  msgstr ""
143
 
144
- #: includes/class-elementor-language-for-blocks.php:134
145
  msgid "Allow translation to the corresponding language only if the content is written in the default language."
146
  msgstr ""
147
 
148
- #: includes/class-elementor-language-for-blocks.php:140, includes/class-wp-bakery-language-for-blocks.php:106
149
  msgid "Select language"
150
  msgstr ""
151
 
152
- #: includes/class-elementor-language-for-blocks.php:157, includes/class-wp-bakery-language-for-blocks.php:110
153
  msgid "Choose in which language to show this element."
154
  msgstr ""
155
 
156
- #: includes/class-elementor-language-for-blocks.php:169
157
  msgid "Exclude element from language"
158
  msgstr ""
159
 
160
- #: includes/class-elementor-language-for-blocks.php:171, includes/class-wp-bakery-language-for-blocks.php:141
161
  msgid "Exclude this element from specific languages."
162
  msgstr ""
163
 
164
- #: includes/class-elementor-language-for-blocks.php:177, includes/class-wp-bakery-language-for-blocks.php:158
165
  msgid "Select languages"
166
  msgstr ""
167
 
168
- #: includes/class-elementor-language-for-blocks.php:195, includes/class-wp-bakery-language-for-blocks.php:162
169
  msgid "Choose from which languages to exclude this element."
170
  msgstr ""
171
 
172
- #: includes/class-elementor-language-for-blocks.php:199, includes/class-wp-bakery-language-for-blocks.php:146
173
  msgid "This element will still be visible when you are translating your website through the Translation Editor."
174
  msgstr ""
175
 
176
- #: includes/class-elementor-language-for-blocks.php:200, includes/class-wp-bakery-language-for-blocks.php:153
177
  msgid "The content of this element should be written in the default language."
178
  msgstr ""
179
 
@@ -297,11 +297,11 @@ msgstr ""
297
  msgid "(last checked on %s)"
298
  msgstr ""
299
 
300
- #: includes/class-machine-translator.php:136, includes/google-translate/class-google-translate-v2-machine-translator.php:181
301
  msgid "Please enter your Google Translate key."
302
  msgstr ""
303
 
304
- #: includes/class-machine-translator.php:151, add-ons-pro/deepl/includes/class-deepl-machine-translator.php:286
305
  msgid "Please enter your DeepL API key."
306
  msgstr ""
307
 
@@ -725,11 +725,11 @@ msgstr ""
725
  msgid "Translate Page"
726
  msgstr ""
727
 
728
- #: includes/class-translation-manager.php:1283
729
  msgid "Security check"
730
  msgstr ""
731
 
732
- #: includes/class-translation-manager.php:1357
733
  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."
734
  msgstr ""
735
 
@@ -1177,7 +1177,7 @@ msgid "Log machine translation queries."
1177
  msgstr ""
1178
 
1179
  #: partials/machine-translation-settings-page.php:195
1180
- 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.)"
1181
  msgstr ""
1182
 
1183
  #: partials/main-settings-language-selector.php:2, add-ons-pro/navigation-based-on-language/class-navigation-based-on-language.php:81, add-ons-advanced/extra-languages/partials/language-selector-pro.php:2
@@ -1225,7 +1225,7 @@ msgid "Custom Languages"
1225
  msgstr ""
1226
 
1227
  #: partials/main-settings-language-selector.php:105, add-ons-advanced/extra-languages/partials/language-selector-pro.php:106
1228
- msgid "Select the languages you wish to make your website available in.<br>The Formality field is used by Automatic Translation to decide whether the translated text should lean towards formal or informal language. For now, it is supported only for a few languages and only by <a href=\"%s\">DeepL</a>."
1229
  msgstr ""
1230
 
1231
  #. translators: %1$s is the URL to the add-ons. %2$2 is for the TranslatePress add-on verbiage.
@@ -1659,6 +1659,22 @@ msgstr ""
1659
  msgid "Choose which hreflang tags will appear on your website.<br/>We recommend showing both types of hreflang tags as indicated by <a href=\"https://developers.google.com/search/docs/advanced/crawling/localized-versions\" title=\"Google Crawling\" target=\"_blank\">Google documentation</a>.<br/>Removing Country Locale when having multiple Country Locales of the same language (ex. English UK and English US) will result in showing one hreflang tag with link to just one of the region locales for that language."
1660
  msgstr ""
1661
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1662
  #: includes/advanced-settings/open-language-switcher-shortcode-on-click.php:8
1663
  msgid "Open language switcher only on click"
1664
  msgstr ""
49
  msgid "Settings saved."
50
  msgstr ""
51
 
52
+ #: includes/class-advanced-tab.php:319, includes/class-error-manager.php:172, partials/machine-translation-settings-page.php:17, partials/machine-translation-settings-page.php:121, partials/machine-translation-settings-page.php:141, partials/machine-translation-settings-page.php:192, partials/main-settings-page.php:42, partials/main-settings-page.php:55, partials/main-settings-page.php:68
53
  msgid "Yes"
54
  msgstr ""
55
 
56
+ #: includes/class-advanced-tab.php:529, includes/class-advanced-tab.php:540, includes/class-advanced-tab.php:634, includes/class-advanced-tab.php:665
57
  msgid "Are you sure you want to remove this item?"
58
  msgstr ""
59
 
60
+ #: includes/class-advanced-tab.php:529, includes/class-advanced-tab.php:540, includes/class-advanced-tab.php:634, includes/class-advanced-tab.php:665, partials/main-settings-language-selector.php:60, add-ons-advanced/extra-languages/partials/language-selector-pro.php:62
61
  msgid "Remove"
62
  msgstr ""
63
 
64
+ #: includes/class-advanced-tab.php:540, includes/class-advanced-tab.php:665, partials/main-settings-language-selector.php:102, add-ons-advanced/extra-languages/partials/language-selector-pro.php:103
65
  msgid "Add"
66
  msgstr ""
67
 
68
+ #: includes/class-advanced-tab.php:618, includes/class-advanced-tab.php:652
69
  msgid "Select..."
70
  msgstr ""
71
 
121
  msgid "Others"
122
  msgstr ""
123
 
124
+ #: includes/class-elementor-language-for-blocks.php:98
125
  msgid "Restrict by Language"
126
  msgstr ""
127
 
128
+ #: includes/class-elementor-language-for-blocks.php:116, includes/class-wp-bakery-language-for-blocks.php:138
129
  msgid "Exclude from Language"
130
  msgstr ""
131
 
132
+ #: includes/class-elementor-language-for-blocks.php:131, includes/class-wp-bakery-language-for-blocks.php:98
133
  msgid "Restrict element to language"
134
  msgstr ""
135
 
136
+ #: includes/class-elementor-language-for-blocks.php:133, includes/class-wp-bakery-language-for-blocks.php:101
137
  msgid "Show this element only in one language."
138
  msgstr ""
139
 
140
+ #: includes/class-elementor-language-for-blocks.php:139
141
  msgid "Enable translation"
142
  msgstr ""
143
 
144
+ #: includes/class-elementor-language-for-blocks.php:141
145
  msgid "Allow translation to the corresponding language only if the content is written in the default language."
146
  msgstr ""
147
 
148
+ #: includes/class-elementor-language-for-blocks.php:147, includes/class-wp-bakery-language-for-blocks.php:106
149
  msgid "Select language"
150
  msgstr ""
151
 
152
+ #: includes/class-elementor-language-for-blocks.php:164, includes/class-wp-bakery-language-for-blocks.php:110
153
  msgid "Choose in which language to show this element."
154
  msgstr ""
155
 
156
+ #: includes/class-elementor-language-for-blocks.php:176
157
  msgid "Exclude element from language"
158
  msgstr ""
159
 
160
+ #: includes/class-elementor-language-for-blocks.php:178, includes/class-wp-bakery-language-for-blocks.php:141
161
  msgid "Exclude this element from specific languages."
162
  msgstr ""
163
 
164
+ #: includes/class-elementor-language-for-blocks.php:184, includes/class-wp-bakery-language-for-blocks.php:158
165
  msgid "Select languages"
166
  msgstr ""
167
 
168
+ #: includes/class-elementor-language-for-blocks.php:202, includes/class-wp-bakery-language-for-blocks.php:162
169
  msgid "Choose from which languages to exclude this element."
170
  msgstr ""
171
 
172
+ #: includes/class-elementor-language-for-blocks.php:206, includes/class-wp-bakery-language-for-blocks.php:146
173
  msgid "This element will still be visible when you are translating your website through the Translation Editor."
174
  msgstr ""
175
 
176
+ #: includes/class-elementor-language-for-blocks.php:207, includes/class-wp-bakery-language-for-blocks.php:153
177
  msgid "The content of this element should be written in the default language."
178
  msgstr ""
179
 
297
  msgid "(last checked on %s)"
298
  msgstr ""
299
 
300
+ #: includes/class-machine-translator.php:137, includes/google-translate/class-google-translate-v2-machine-translator.php:181
301
  msgid "Please enter your Google Translate key."
302
  msgstr ""
303
 
304
+ #: includes/class-machine-translator.php:152, add-ons-pro/deepl/includes/class-deepl-machine-translator.php:286
305
  msgid "Please enter your DeepL API key."
306
  msgstr ""
307
 
725
  msgid "Translate Page"
726
  msgstr ""
727
 
728
+ #: includes/class-translation-manager.php:1299
729
  msgid "Security check"
730
  msgstr ""
731
 
732
+ #: includes/class-translation-manager.php:1373
733
  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."
734
  msgstr ""
735
 
1177
  msgstr ""
1178
 
1179
  #: partials/machine-translation-settings-page.php:195
1180
+ 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/\" target=\"_blank\">WP Data Access</a> to browse the logs or directly from your database manager (PHPMyAdmin, etc.)"
1181
  msgstr ""
1182
 
1183
  #: partials/main-settings-language-selector.php:2, add-ons-pro/navigation-based-on-language/class-navigation-based-on-language.php:81, add-ons-advanced/extra-languages/partials/language-selector-pro.php:2
1225
  msgstr ""
1226
 
1227
  #: partials/main-settings-language-selector.php:105, add-ons-advanced/extra-languages/partials/language-selector-pro.php:106
1228
+ msgid "Select the languages you wish to make your website available in.<br>The Formality field is used by Automatic Translation to decide whether the translated text should lean towards formal or informal language. For now, it is supported only for a few languages and only by <a href=\"%s\" target=\"_blank\">DeepL</a>."
1229
  msgstr ""
1230
 
1231
  #. translators: %1$s is the URL to the add-ons. %2$2 is for the TranslatePress add-on verbiage.
1659
  msgid "Choose which hreflang tags will appear on your website.<br/>We recommend showing both types of hreflang tags as indicated by <a href=\"https://developers.google.com/search/docs/advanced/crawling/localized-versions\" title=\"Google Crawling\" target=\"_blank\">Google documentation</a>.<br/>Removing Country Locale when having multiple Country Locales of the same language (ex. English UK and English US) will result in showing one hreflang tag with link to just one of the region locales for that language."
1660
  msgstr ""
1661
 
1662
+ #: includes/advanced-settings/html-lang-remove-locale.php:10
1663
+ msgid "Default (example: en-US, fr-CA, etc.)"
1664
+ msgstr ""
1665
+
1666
+ #: includes/advanced-settings/html-lang-remove-locale.php:10
1667
+ msgid "Regional (example: en, fr, es, etc.)"
1668
+ msgstr ""
1669
+
1670
+ #: includes/advanced-settings/html-lang-remove-locale.php:11
1671
+ msgid "HTML Lang Attribute Format"
1672
+ msgstr ""
1673
+
1674
+ #: includes/advanced-settings/html-lang-remove-locale.php:12
1675
+ msgid "Change lang attribute of the html tag to a format that includes country regional or not. <br>In HTML, the lang attribute (<html lang=\"en-US\">) should be used to specify the language of text content so that the browser can correctly display or process your content (eg. for hyphenation, styling, spell checking, etc)."
1676
+ msgstr ""
1677
+
1678
  #: includes/advanced-settings/open-language-switcher-shortcode-on-click.php:8
1679
  msgid "Open language switcher only on click"
1680
  msgstr ""
partials/machine-translation-settings-page.php CHANGED
@@ -192,7 +192,7 @@
192
  <?php esc_html_e( 'Yes' , 'translatepress-multilingual' ); ?>
193
  </label>
194
  <p class="description">
195
- <?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() ) ) ); ?>
196
  </p>
197
  </td>
198
  </tr>
192
  <?php esc_html_e( 'Yes' , 'translatepress-multilingual' ); ?>
193
  </label>
194
  <p class="description">
195
+ <?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/" target="_blank">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() ) ) ); ?>
196
  </p>
197
  </td>
198
  </tr>
partials/main-settings-language-selector.php CHANGED
@@ -102,7 +102,7 @@
102
  <button type="button" id="trp-add-language" class="button-secondary"><?php esc_html_e( 'Add', 'translatepress-multilingual' );?></button>
103
  </div>
104
  <p class="description">
105
- <?php echo wp_kses ( sprintf(__( 'Select the languages you wish to make your website available in.<br>The Formality field is used by Automatic Translation to decide whether the translated text should lean towards formal or informal language. For now, it is supported only for a few languages and only by <a href="%s">DeepL</a>.', 'translatepress-multilingual' ), esc_url('https://www.deepl.com/docs-api/translating-text/') ), array('a' => array('href' => array(), 'title' => array()), 'br' => array()) ); ?>
106
  </p>
107
  <p class="trp-upsell-multiple-languages" style="display: none;">
108
  <?php
102
  <button type="button" id="trp-add-language" class="button-secondary"><?php esc_html_e( 'Add', 'translatepress-multilingual' );?></button>
103
  </div>
104
  <p class="description">
105
+ <?php echo wp_kses ( sprintf(__( 'Select the languages you wish to make your website available in.<br>The Formality field is used by Automatic Translation to decide whether the translated text should lean towards formal or informal language. For now, it is supported only for a few languages and only by <a href="%s" target="_blank">DeepL</a>.', 'translatepress-multilingual' ), esc_url('https://www.deepl.com/docs-api/translating-text/') ), array('a' => array('href' => array(), 'target' =>array(),'title' => array()), 'br' => array()) ); ?>
106
  </p>
107
  <p class="trp-upsell-multiple-languages" style="display: none;">
108
  <?php
partials/main-settings-page.php CHANGED
@@ -95,7 +95,7 @@
95
  $link_start = '<a href="' . esc_url( admin_url( 'nav-menus.php' ) ) .'">';
96
  $link_end = '</a>';
97
  printf( wp_kses( __( 'Go to %1$s Appearance -> Menus%2$s to add languages to the Language Switcher in any menu.', 'translatepress-multilingual' ), [ 'a' => [ 'href' => [] ] ] ), $link_start, $link_end ); //phpcs:ignore ?>
98
- <a href="https://translatepress.com/docs/settings/#language-switcher"><?php esc_html_e( 'Learn more in our documentation.', 'translatepress-multilingual' ); ?></a>
99
  </p>
100
  </div>
101
  <div class="trp-ls-type">
95
  $link_start = '<a href="' . esc_url( admin_url( 'nav-menus.php' ) ) .'">';
96
  $link_end = '</a>';
97
  printf( wp_kses( __( 'Go to %1$s Appearance -> Menus%2$s to add languages to the Language Switcher in any menu.', 'translatepress-multilingual' ), [ 'a' => [ 'href' => [] ] ] ), $link_start, $link_end ); //phpcs:ignore ?>
98
+ <a href="https://translatepress.com/docs/settings/#language-switcher" target="_blank"><?php esc_html_e( 'Learn more in our documentation.', 'translatepress-multilingual' ); ?></a>
99
  </p>
100
  </div>
101
  <div class="trp-ls-type">
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: 6.0
7
  Requires PHP: 5.6.20
8
- Stable tag: 2.2.9
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -140,6 +140,13 @@ For more information please check out our [documentation](https://translatepress
140
 
141
 
142
  == Changelog ==
 
 
 
 
 
 
 
143
  = 2.2.9 =
144
  * Fix: compatibility issue between translation interface and Thrive Architect
145
  * Fix: make sure processed links are stripped of extra tags
5
  Requires at least: 3.1.0
6
  Tested up to: 6.0
7
  Requires PHP: 5.6.20
8
+ Stable tag: 2.3.0
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
140
 
141
 
142
  == Changelog ==
143
+ = 2.3.0 =
144
+ * Added compatibility with Elementor Containers for exclude/include in certain language
145
+ * Added Advanced option to change html lang attribute to a region independent form
146
+ * Fixed issue with ACF plugin when saving metabox fields
147
+ * Fixed issue with the option to Exclude strings from automatic translation when the excluded text is a substring of another excluded text
148
+ * Fixed notice in PHP 8+ versions about passing null variables being deprecated
149
+
150
  = 2.2.9 =
151
  * Fix: compatibility issue between translation interface and Thrive Architect
152
  * Fix: make sure processed links are stripped of extra tags