TranslatePress – Translate Multilingual sites - Version 1.1.6

Version Description

  • Added support for translating Contact Form 7 alert messages
  • Fixed issue with some strings containing special characters not being translated (i.e. "")
  • Fixed bug with switching languages in Editor when viewing as Logged out
  • Fixed issue with broken homepage links in some themes
  • Added support for RTL languages in translation editor
Download this release

Release Info

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

Code changes from version 1.1.5 to 1.1.6

assets/css/trp-editor-style.css CHANGED
@@ -125,6 +125,11 @@ body{
125
  height: 100%;
126
  }
127
 
 
 
 
 
 
128
  iframe#trp-preview-iframe {
129
  position: absolute;
130
  height: 100%;
@@ -219,7 +224,7 @@ span.select2-container{
219
 
220
  .trp-language-text{
221
  padding-right: 9px;
222
- padding-bottom: 12px;
223
  }
224
 
225
  .trp-language-text textarea{
125
  height: 100%;
126
  }
127
 
128
+ html[dir="rtl"] #trp-preview{
129
+ left: 350px !important;
130
+ right: 0px !important;
131
+ }
132
+
133
  iframe#trp-preview-iframe {
134
  position: absolute;
135
  height: 100%;
224
 
225
  .trp-language-text{
226
  padding-right: 9px;
227
+ padding-bottom: 15px;
228
  }
229
 
230
  .trp-language-text textarea{
assets/js/trp-editor-script.js CHANGED
@@ -40,7 +40,7 @@ function TRP_Editor(){
40
  link = _this.update_query_string('trp-view-as', trp_view_as, link );
41
 
42
  var trp_view_as_nonce = currentUrl.searchParams.get("trp-view-as-nonce");
43
- link = _this.update_query_string('trp-view-as-nonce', trp_view_as, link );
44
  }
45
  link = _this.update_query_string('trp-edit-translation', 'true', link );
46
  window.location.href = link;
@@ -185,6 +185,9 @@ function TRP_Editor(){
185
  * @param response The Ajax response message.
186
  */
187
  this.populate_strings = function( response ){
 
 
 
188
  for ( var key in response ) {
189
  if ( response.hasOwnProperty( key ) ) {
190
  if ( response[key]['default-language'] == true ){
@@ -576,10 +579,19 @@ function TRP_Dictionary( language_code ){
576
  this.set_strings = function( strings_object ){
577
  for ( var s in _this.strings ){
578
  for ( var i in strings_object ){
579
- if ( _this.strings[s].id == strings_object[i].id || ( ( _this.strings[s].original ) && _this.strings[s].original.trim() == strings_object[i].original.trim() ) ){
 
 
 
 
 
 
 
580
  strings_object[i].set = true;
581
  _this.strings[s].set_string( strings_object[i] );
582
  break;
 
 
583
  }
584
  }
585
  }
@@ -681,7 +693,7 @@ function TRP_String( language, array_index ){
681
  this.status = null;
682
  this.node_type = 'Dynamic Added Strings';
683
  this.node_description = '';
684
- var jquery_object = null;
685
  this.language = language;
686
  this.index = array_index;
687
  this.slug = false;
@@ -728,9 +740,9 @@ function TRP_String( language, array_index ){
728
  _this.id = ( new_settings.hasOwnProperty ( 'id' ) ) ? new_settings.id : _this.id;
729
  _this.original = ( new_settings.hasOwnProperty ( 'original' ) ) ? new_settings.original : _this.original;
730
  _this.original = decode_html( _this.original );
731
- jquery_object = ( new_settings.hasOwnProperty ( 'jquery_object' ) ) ? new_settings.jquery_object : jquery_object;
732
 
733
- if ( jquery_object ){
734
  if ( trp_language == trp_on_screen_language ) {
735
  var text_to_set = null;
736
  if (new_settings.hasOwnProperty('translated') && new_settings.translated != _this.translated) {
@@ -741,23 +753,22 @@ function TRP_String( language, array_index ){
741
  }
742
  _this.wrap_special_html_elements();
743
  if (text_to_set) {
744
- var initial_value = jquery_object.text();
745
  text_to_set = initial_value.replace(initial_value.trim(), text_to_set);
746
- if ( jquery_object.attr( 'data-trp-attr' ) ){
747
- jquery_object.children().attr( jquery_object.attr('data-trp-attr'), text_to_set );
748
- }else if( jquery_object.attr( 'data-trp-button' ) ){
749
- jquery_object.children('button').text(text_to_set);
750
  }else {
751
- jquery_object.html( text_to_set );
752
  }
753
  }
754
  }
755
 
756
- jquery_object.on( 'mouseenter', '', _this.highlight );
757
- jquery_object.on( 'mouseleave', '', _this.unhighlight );
758
  }
759
 
760
-
761
  _this.status = ( new_settings.hasOwnProperty( 'status' ) ) ? new_settings.status : _this.status;
762
  _this.translated = ( new_settings.hasOwnProperty( 'translated' ) ) ? decode_html ( new_settings.translated ) : _this.translated;
763
  };
@@ -766,20 +777,20 @@ function TRP_String( language, array_index ){
766
  * Wrap buttons and placeholders so that we can display the pencil button and also replace with translation.
767
  */
768
  this.wrap_special_html_elements = function(){
769
- if( jquery_object.is('button') ){
770
- jquery_object.unwrap('trp-highlight');
771
- jquery_object.wrap('<trp-highlight data-trp-button="true"></trp-highlight>');
772
- jquery_object = jquery_object.parent();
773
  }
774
- else if ( jquery_object.attr( 'type' ) == 'submit' || jquery_object.attr( 'type' ) == 'button' ) {
775
- jquery_object.unwrap('trp-highlight');
776
- jquery_object.wrap('<trp-highlight data-trp-attr="value"></trp-highlight>');
777
- jquery_object = jquery_object.parent();
778
  }
779
- else if ( ( jquery_object.attr( 'type' ) == 'text' || jquery_object.attr( 'type' ) == 'search' ) && ( typeof jquery_object.attr( 'placeholder' ) != 'undefined' ) ) {
780
- jquery_object.unwrap('trp-highlight');
781
- jquery_object.wrap('<trp-highlight data-trp-attr="placeholder"></trp-highlight>');
782
- jquery_object = jquery_object.parent();
783
  }
784
  };
785
 
@@ -788,15 +799,15 @@ function TRP_String( language, array_index ){
788
  */
789
  this.highlight = function (){
790
  if ( ! trpEditor.edit_translation_button ){
791
- jquery_object.prepend( '<span class="trp-edit-translation"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M13.89 3.39l2.71 2.72c.46.46.42 1.24.03 1.64l-8.01 8.02-5.56 1.16 1.16-5.58s7.6-7.63 7.99-8.03c.39-.39 1.22-.39 1.68.07zm-2.73 2.79l-5.59 5.61 1.11 1.11 5.54-5.65zm-2.97 8.23l5.58-5.6-1.07-1.08-5.59 5.6z"></path></svg></span>' );
792
- trpEditor.edit_translation_button = jquery_object.children('.trp-edit-translation');
793
  }else{
794
  _this.wrap_special_html_elements();
795
  trpEditor.maybe_overflow_fix(trpEditor.edit_translation_button);
796
- jquery_object.prepend(trpEditor.edit_translation_button);
797
  }
798
 
799
- trpEditor.make_sure_pencil_icon_is_inside_view( jquery_object[0] );
800
 
801
  trpEditor.edit_translation_button.off( 'click' );
802
  trpEditor.edit_translation_button.on( 'click', function(e){
@@ -844,19 +855,19 @@ function TRP_String( language, array_index ){
844
  * @param raw_string
845
  */
846
  this.set_raw_string = function( raw_string ){
847
- jquery_object = jQuery( raw_string );
848
- var translation_id_attribute = jquery_object.attr( TRP_TRANSLATION_ID );
849
  if ( translation_id_attribute ){
850
  _this.id = translation_id_attribute;
851
- _this.node_type = jquery_object.attr( TRP_NODE_TYPE );
852
- _this.node_description = jquery_object.attr( TRP_NODE_DESCRIPTION );
853
- if ( jquery_object.attr( 'name' ) == 'trp-slug' ){
854
  _this.slug = true;
855
- _this.slug_post_id = jquery_object.attr( 'post-id' );
856
- _this.original = jquery_object.attr( 'content' );
857
  }
858
  }else{
859
- _this.original = jquery_object.text();
860
  }
861
  };
862
 
40
  link = _this.update_query_string('trp-view-as', trp_view_as, link );
41
 
42
  var trp_view_as_nonce = currentUrl.searchParams.get("trp-view-as-nonce");
43
+ link = _this.update_query_string('trp-view-as-nonce', trp_view_as_nonce, link );
44
  }
45
  link = _this.update_query_string('trp-edit-translation', 'true', link );
46
  window.location.href = link;
185
  * @param response The Ajax response message.
186
  */
187
  this.populate_strings = function( response ){
188
+ if ( typeof dictionaries == 'undefined' ){
189
+ dictionaries = [];
190
+ }
191
  for ( var key in response ) {
192
  if ( response.hasOwnProperty( key ) ) {
193
  if ( response[key]['default-language'] == true ){
579
  this.set_strings = function( strings_object ){
580
  for ( var s in _this.strings ){
581
  for ( var i in strings_object ){
582
+ if ( ( _this.strings[s].id == strings_object[i].id || ( ( _this.strings[s].original ) && _this.strings[s].original.trim() == strings_object[i].original.trim() ) )
583
+ && (
584
+ ( _this.strings[s].jquery_object == null ) ||
585
+ ( typeof _this.strings[s].jquery_object == 'undefined' ) ||
586
+ ( _this.strings[s].jquery_object != null && strings_object[i].jquery_object == null ) ||
587
+ ( strings_object[i].jquery_object ==_this.strings[s].jquery_object )
588
+ )
589
+ ) {
590
  strings_object[i].set = true;
591
  _this.strings[s].set_string( strings_object[i] );
592
  break;
593
+ }else{
594
+ strings_object[i].set = false;
595
  }
596
  }
597
  }
693
  this.status = null;
694
  this.node_type = 'Dynamic Added Strings';
695
  this.node_description = '';
696
+ this.jquery_object = null;
697
  this.language = language;
698
  this.index = array_index;
699
  this.slug = false;
740
  _this.id = ( new_settings.hasOwnProperty ( 'id' ) ) ? new_settings.id : _this.id;
741
  _this.original = ( new_settings.hasOwnProperty ( 'original' ) ) ? new_settings.original : _this.original;
742
  _this.original = decode_html( _this.original );
743
+ _this.jquery_object = ( new_settings.hasOwnProperty ( 'jquery_object' ) ) ? new_settings.jquery_object : _this.jquery_object;
744
 
745
+ if ( _this.jquery_object ){
746
  if ( trp_language == trp_on_screen_language ) {
747
  var text_to_set = null;
748
  if (new_settings.hasOwnProperty('translated') && new_settings.translated != _this.translated) {
753
  }
754
  _this.wrap_special_html_elements();
755
  if (text_to_set) {
756
+ var initial_value = _this.jquery_object.text();
757
  text_to_set = initial_value.replace(initial_value.trim(), text_to_set);
758
+ if ( _this.jquery_object.attr( 'data-trp-attr' ) ){
759
+ _this.jquery_object.children().attr( _this.jquery_object.attr('data-trp-attr'), text_to_set );
760
+ }else if( _this.jquery_object.attr( 'data-trp-button' ) ){
761
+ _this.jquery_object.children('button').text(text_to_set);
762
  }else {
763
+ _this.jquery_object.html( text_to_set );
764
  }
765
  }
766
  }
767
 
768
+ _this.jquery_object.on( 'mouseenter', '', _this.highlight );
769
+ _this.jquery_object.on( 'mouseleave', '', _this.unhighlight );
770
  }
771
 
 
772
  _this.status = ( new_settings.hasOwnProperty( 'status' ) ) ? new_settings.status : _this.status;
773
  _this.translated = ( new_settings.hasOwnProperty( 'translated' ) ) ? decode_html ( new_settings.translated ) : _this.translated;
774
  };
777
  * Wrap buttons and placeholders so that we can display the pencil button and also replace with translation.
778
  */
779
  this.wrap_special_html_elements = function(){
780
+ if( _this.jquery_object.is('button') ){
781
+ _this.jquery_object.unwrap('trp-highlight');
782
+ _this.jquery_object.wrap('<trp-highlight data-trp-button="true"></trp-highlight>');
783
+ _this.jquery_object = _this.jquery_object.parent();
784
  }
785
+ else if ( _this.jquery_object.attr( 'type' ) == 'submit' || _this.jquery_object.attr( 'type' ) == 'button' ) {
786
+ _this.jquery_object.unwrap('trp-highlight');
787
+ _this.jquery_object.wrap('<trp-highlight data-trp-attr="value"></trp-highlight>');
788
+ _this.jquery_object = _this.jquery_object.parent();
789
  }
790
+ else if ( ( _this.jquery_object.attr( 'type' ) == 'text' || _this.jquery_object.attr( 'type' ) == 'search' ) && ( typeof _this.jquery_object.attr( 'placeholder' ) != 'undefined' ) ) {
791
+ _this.jquery_object.unwrap('trp-highlight');
792
+ _this.jquery_object.wrap('<trp-highlight data-trp-attr="placeholder"></trp-highlight>');
793
+ _this.jquery_object = _this.jquery_object.parent();
794
  }
795
  };
796
 
799
  */
800
  this.highlight = function (){
801
  if ( ! trpEditor.edit_translation_button ){
802
+ _this.jquery_object.prepend( '<span class="trp-edit-translation"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M13.89 3.39l2.71 2.72c.46.46.42 1.24.03 1.64l-8.01 8.02-5.56 1.16 1.16-5.58s7.6-7.63 7.99-8.03c.39-.39 1.22-.39 1.68.07zm-2.73 2.79l-5.59 5.61 1.11 1.11 5.54-5.65zm-2.97 8.23l5.58-5.6-1.07-1.08-5.59 5.6z"></path></svg></span>' );
803
+ trpEditor.edit_translation_button = _this.jquery_object.children('.trp-edit-translation');
804
  }else{
805
  _this.wrap_special_html_elements();
806
  trpEditor.maybe_overflow_fix(trpEditor.edit_translation_button);
807
+ _this.jquery_object.prepend(trpEditor.edit_translation_button);
808
  }
809
 
810
+ trpEditor.make_sure_pencil_icon_is_inside_view( _this.jquery_object[0] );
811
 
812
  trpEditor.edit_translation_button.off( 'click' );
813
  trpEditor.edit_translation_button.on( 'click', function(e){
855
  * @param raw_string
856
  */
857
  this.set_raw_string = function( raw_string ){
858
+ _this.jquery_object = jQuery( raw_string );
859
+ var translation_id_attribute = _this.jquery_object.attr( TRP_TRANSLATION_ID );
860
  if ( translation_id_attribute ){
861
  _this.id = translation_id_attribute;
862
+ _this.node_type = _this.jquery_object.attr( TRP_NODE_TYPE );
863
+ _this.node_description = _this.jquery_object.attr( TRP_NODE_DESCRIPTION );
864
+ if ( _this.jquery_object.attr( 'name' ) == 'trp-slug' ){
865
  _this.slug = true;
866
+ _this.slug_post_id = _this.jquery_object.attr( 'post-id' );
867
+ _this.original = _this.jquery_object.attr( 'content' );
868
  }
869
  }else{
870
+ _this.original = _this.jquery_object.text();
871
  }
872
  };
873
 
assets/js/trp-translate-dom-changes.js CHANGED
@@ -98,8 +98,9 @@ function TRP_Translator(){
98
  var strings = [];
99
  mutations.forEach( function (mutation) {
100
  for (var i = 0; i < mutation.addedNodes.length; i++) {
101
- if ( mutation.addedNodes[i].innerText && _this.trim( mutation.addedNodes[i].innerText.trim(), except_characters ) != '' ) {
102
  var node = jQuery( mutation.addedNodes[i] );
 
103
  var noTranslation = node.attr( 'data-no-translation' );
104
  if ( (typeof noTranslation !== typeof undefined && noTranslation !== false) || node.parents( '[data-no-translation]').length > 0 ){
105
  continue;
@@ -119,23 +120,31 @@ function TRP_Translator(){
119
  if ( typeof parent.trpEditor !== 'undefined' ) {
120
  jQuery(mutation.addedNodes[i]).find('a').context.href = _this.update_query_string('trp-edit-translation', 'preview', jQuery(mutation.addedNodes[i]).find('a').context.href);
121
  }
 
 
 
 
 
 
 
122
 
123
- var all_nodes = jQuery( mutation.addedNodes[i]).find( '*').addBack();
124
- var all_strings = all_nodes.contents().filter(function(){
125
- if( this.nodeType === 3 && /\S/.test(this.nodeValue) ){
126
- if ( jQuery(this).closest( '[data-trpgettextoriginal]').length == 0 && jQuery(this).closest( '[data-trp-translate-id]').length == 0 ){
127
- return this;
128
  }
129
  }
130
- });
131
- if ( typeof parent.trpEditor !== 'undefined' ) {
132
- all_strings.wrap('<translate-press></translate-press>');
133
- }
134
- var all_strings_length = all_strings.length;
135
- for (var j = 0; j < all_strings_length; j++ ) {
136
- if ( _this.trim( all_strings[j].textContent, except_characters ) != '' ) {
137
- strings.push({node: all_strings[j], original: _this.trim( all_strings[j].textContent, trim_characters )});
138
- all_strings[j].textContent = '';
 
 
 
139
  }
140
  }
141
  }
@@ -147,6 +156,17 @@ function TRP_Translator(){
147
  }
148
  };
149
 
 
 
 
 
 
 
 
 
 
 
 
150
  //function that cleans the gettext wrappers
151
  this.cleanup_gettext_wrapper = function(){
152
  jQuery('trp-gettext').contents().unwrap();
@@ -213,7 +233,8 @@ function TRP_Translator(){
213
 
214
  jQuery( document ).ajaxComplete(function( event, request, settings ) {
215
  if( window.parent.jQuery('#trp-preview-iframe').length != 0 ) {
216
- if( typeof settings.data == 'undefined' || settings.data.indexOf('action=trp_') === -1 ) {
 
217
  window.parent.jQuery('#trp-preview-iframe').trigger('load');
218
  }
219
  }
98
  var strings = [];
99
  mutations.forEach( function (mutation) {
100
  for (var i = 0; i < mutation.addedNodes.length; i++) {
101
+ if ( mutation.addedNodes[i].textContent && _this.trim( mutation.addedNodes[i].textContent.trim(), except_characters ) != '' ) {
102
  var node = jQuery( mutation.addedNodes[i] );
103
+
104
  var noTranslation = node.attr( 'data-no-translation' );
105
  if ( (typeof noTranslation !== typeof undefined && noTranslation !== false) || node.parents( '[data-no-translation]').length > 0 ){
106
  continue;
120
  if ( typeof parent.trpEditor !== 'undefined' ) {
121
  jQuery(mutation.addedNodes[i]).find('a').context.href = _this.update_query_string('trp-edit-translation', 'preview', jQuery(mutation.addedNodes[i]).find('a').context.href);
122
  }
123
+ var direct_string = get_string_from_node( mutation.addedNodes[i] );
124
+ if ( direct_string ) {
125
+ if ( _this.trim( direct_string.textContent, except_characters ) != '' ) {
126
+ strings.push({
127
+ node: mutation.addedNodes[i],
128
+ original: _this.trim(direct_string.textContent, trim_characters)
129
+ });
130
 
131
+ direct_string.textContent = '';
132
+ if (typeof parent.trpEditor !== 'undefined') {
133
+ jQuery(mutation.addedNodes[i]).wrap('<translate-press></translate-press>');
 
 
134
  }
135
  }
136
+ }else{
137
+ var all_nodes = jQuery( mutation.addedNodes[i]).find( '*').addBack();
138
+ var all_strings = all_nodes.contents().filter(get_string_from_node);
139
+ if ( typeof parent.trpEditor !== 'undefined' ) {
140
+ all_strings.wrap('<translate-press></translate-press>');
141
+ }
142
+ var all_strings_length = all_strings.length;
143
+ for (var j = 0; j < all_strings_length; j++ ) {
144
+ if ( _this.trim( all_strings[j].textContent, except_characters ) != '' ) {
145
+ strings.push({node: all_strings[j], original: _this.trim( all_strings[j].textContent, trim_characters )});
146
+ all_strings[j].textContent = '';
147
+ }
148
  }
149
  }
150
  }
156
  }
157
  };
158
 
159
+ function get_string_from_node( node ){
160
+ if ( node == false ){
161
+ node = this;
162
+ }
163
+ if( node.nodeType === 3 && /\S/.test(node.nodeValue) ){
164
+ if ( jQuery(node).closest( '[data-trpgettextoriginal]').length == 0 && jQuery(node).closest( '[data-trp-translate-id]').length == 0 ){
165
+ return node;
166
+ }
167
+ }
168
+ }
169
+
170
  //function that cleans the gettext wrappers
171
  this.cleanup_gettext_wrapper = function(){
172
  jQuery('trp-gettext').contents().unwrap();
233
 
234
  jQuery( document ).ajaxComplete(function( event, request, settings ) {
235
  if( window.parent.jQuery('#trp-preview-iframe').length != 0 ) {
236
+ var settingsdata = "" + settings.data;
237
+ if( typeof settings.data == 'undefined' || jQuery.isEmptyObject( settings.data ) || settingsdata.indexOf('action=trp_') === -1 ) {
238
  window.parent.jQuery('#trp-preview-iframe').trigger('load');
239
  }
240
  }
class-translate-press.php CHANGED
@@ -39,7 +39,7 @@ class TRP_Translate_Press{
39
  define( 'TRP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
40
  define( 'TRP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
41
  define( 'TRP_PLUGIN_SLUG', 'translatepress-multilingual' );
42
- define( 'TRP_PLUGIN_VERSION', '1.1.5' );
43
 
44
  $this->load_dependencies();
45
  $this->initialize_components();
39
  define( 'TRP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
40
  define( 'TRP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
41
  define( 'TRP_PLUGIN_SLUG', 'translatepress-multilingual' );
42
+ define( 'TRP_PLUGIN_VERSION', '1.1.6' );
43
 
44
  $this->load_dependencies();
45
  $this->initialize_components();
includes/class-query.php CHANGED
@@ -11,6 +11,7 @@ class TRP_Query{
11
  protected $table_name;
12
  protected $db;
13
  protected $settings;
 
14
 
15
  const NOT_TRANSLATED = 0;
16
  const MACHINE_TRANSLATED = 1;
@@ -29,19 +30,16 @@ class TRP_Query{
29
  /**
30
  * Trim unwanted characters from string.
31
  *
32
- * @param string $word String to trim.
33
  * @return string Trimmed string.
34
  */
35
- protected function full_trim( $word ) {
36
- /* apparently the � char in the trim function turns some strings in an empty string so they can't be translated but I don't really know if we should remove it completely */
37
- //$word = trim($word," \t\n\r\0\x0B\xA0�" );
38
- $word = trim($word," \t\n\r\0\x0B\xA0" );
39
-
40
- // make sure to skip weird characters
41
- if ( htmlentities( $word ) == "" ){
42
- $word = '';
43
- }
44
- return $word;
45
  }
46
 
47
  /**
11
  protected $table_name;
12
  protected $db;
13
  protected $settings;
14
+ protected $translation_render;
15
 
16
  const NOT_TRANSLATED = 0;
17
  const MACHINE_TRANSLATED = 1;
30
  /**
31
  * Trim unwanted characters from string.
32
  *
33
+ * @param string $string String to trim.
34
  * @return string Trimmed string.
35
  */
36
+ protected function full_trim( $string ) {
37
+ $trp = TRP_Translate_Press::get_trp_instance();
38
+ if ( ! $this->translation_render ) {
39
+ $this->translation_render = $trp->get_component( 'translation_render' );
40
+ }
41
+
42
+ return $this->translation_render->full_trim( $string );
 
 
 
43
  }
44
 
45
  /**
includes/class-translation-render.php CHANGED
@@ -92,18 +92,34 @@ class TRP_Translation_Render{
92
  /**
93
  * Trim strings.
94
  *
95
- * @param string $word Raw string.
96
  * @return string Trimmed string.
97
  */
98
- public function full_trim( $word ) {
99
- /* apparently the � char in the trim function turns some strings in an empty string so they can't be translated but I don't really know if we should remove it completely */
 
 
100
  //$word = trim($word," \t\n\r\0\x0B\xA0�".chr( 194 ) . chr( 160 ) );
101
- $word = trim($word," \t\n\r\0\x0B\xA0".chr( 194 ) . chr( 160 ) );
102
- if ( htmlentities( $word ) == "" || strip_tags( $word ) == "" || trim ($word, " \t\n\r\0\x0B\xA0�.,/`~!@#\$€£%^&*():;-_=+[]{}\\|?/<>1234567890'\"" ) == '' ){
103
- $word = '';
104
- }
105
 
106
- return $word;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  }
108
 
109
  /**
92
  /**
93
  * Trim strings.
94
  *
95
+ * @param string $string Raw string.
96
  * @return string Trimmed string.
97
  */
98
+ public function full_trim( $string ) {
99
+ /* Apparently the � char in the trim function turns some strings in an empty string so they can't be translated but I don't really know if we should remove it completely
100
+ Removed chr( 194 ) . chr( 160 ) because it altered some special characters (¿¡)
101
+ Also removed \xA0 (the same as chr(160) for altering special characters */
102
  //$word = trim($word," \t\n\r\0\x0B\xA0�".chr( 194 ) . chr( 160 ) );
 
 
 
 
103
 
104
+ /* Solution to replace the chr(194).chr(160) from trim function, in order to escape the whitespace character ( \xc2\xa0 ), an old bug that couldn't be replicated anymore. */
105
+ $prefix = "\xc2\xa0";
106
+ $prefix_length = strlen($prefix);
107
+ do{
108
+ $previous_iteration_string = $string;
109
+ $string = trim( $string," \t\n\r\0\x0B");
110
+ if ( substr( $string, 0, $prefix_length ) == $prefix ) {
111
+ $string = substr( $string, $prefix_length );
112
+ }
113
+ if ( substr( $string, - $prefix_length, $prefix_length ) == $prefix ) {
114
+ $string = substr( $string, 0, - $prefix_length );
115
+ }
116
+ }while( $string != $previous_iteration_string );
117
+
118
+ if ( strip_tags( $string ) == "" || trim ($string, " \t\n\r\0\x0B\xA0�.,/`~!@#\$€£%^&*():;-_=+[]{}\\|?/<>1234567890'\"" ) == '' ){
119
+ $string = '';
120
+ }
121
+
122
+ return $string;
123
  }
124
 
125
  /**
includes/class-url-converter.php CHANGED
@@ -172,16 +172,6 @@ class TRP_Url_Converter {
172
  $language = $TRP_LANGUAGE;
173
  }
174
 
175
- // if we have the homepage, we replace it with the filtered homepage that contains the language url.
176
- if( ( trailingslashit( $this->cur_page_url() ) == trailingslashit($this->get_abs_home()) )||
177
- ( trailingslashit( $this->cur_page_url() ) == (trailingslashit($this->get_abs_home()) . $this->get_url_slug( $TRP_LANGUAGE ) . '/')) ){
178
-
179
- $TRP_LANGUAGE = $language;
180
- $new_url = home_url();
181
- $TRP_LANGUAGE = $trp_language_copy;
182
- return $new_url . $trp_link_is_processed;
183
- }
184
-
185
  // make sure we have the original query
186
  wp_reset_query();
187
 
172
  $language = $TRP_LANGUAGE;
173
  }
174
 
 
 
 
 
 
 
 
 
 
 
175
  // make sure we have the original query
176
  wp_reset_query();
177
 
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, with full support for WooCommerce and site builders.
6
- Version: 1.1.5
7
  Author: Cozmoslabs, Razvan Mocanu, Madalin Ungureanu, Cristophor Hurduban
8
  Author URI: https://cozmoslabs.com/
9
  License: GPL2
3
  Plugin Name: TranslatePress - Multilingual
4
  Plugin URI: https://translatepress.com/
5
  Description: Experience a better way of translating your WordPress site, with full support for WooCommerce and site builders.
6
+ Version: 1.1.6
7
  Author: Cozmoslabs, Razvan Mocanu, Madalin Ungureanu, Cristophor Hurduban
8
  Author URI: https://cozmoslabs.com/
9
  License: GPL2
partials/main-settings-page.php CHANGED
@@ -59,7 +59,7 @@
59
  <option value="yes" <?php selected( $this->settings['force-language-to-custom-links'], 'yes' ); ?>><?php _e( 'Yes', 'translatepress-multilingual') ?></option>
60
  </select>
61
  <p class="description">
62
- <?php _e( 'Select Yes if you want to force custom links without language encoding to add the subdirectory in the url for the default language.', 'translatepress-multilingual' ); ?>
63
  </p>
64
  </td>
65
  </tr>
59
  <option value="yes" <?php selected( $this->settings['force-language-to-custom-links'], 'yes' ); ?>><?php _e( 'Yes', 'translatepress-multilingual') ?></option>
60
  </select>
61
  <p class="description">
62
+ <?php _e( 'Select Yes if you want to force custom links without language encoding to keep the currently selected language.', 'translatepress-multilingual' ); ?>
63
  </p>
64
  </td>
65
  </tr>
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.cozmoslabs.com/
4
  Tags: translate, translation, multilingual, automatic translation, front-end translation, google translate, bilingual
5
  Requires at least: 3.1.0
6
  Tested up to: 4.9.4
7
- Stable tag: 1.1.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -26,6 +26,7 @@ Built the WordPress way, TranslatePress - Multilingual is a GPL and self hosted
26
  * Support for both manual and automatic translation (via Google Translate)
27
  * Ability to translate dynamic strings (gettext) added by WordPress, plugins and themes.
28
  * Integrates with Google Translate, allowing you to set up Automatic Translation using your own Google API key.
 
29
  * Place language switchers anywhere using shortcode **[language-switcher]**, WP menu item or as a floating dropdown.
30
  * Editorial control allowing you to publish your language only when all your translations are done
31
  * Conditional display content shortcode based on language [trp_language language="en_US"] English content only [/trp_language]
@@ -112,14 +113,21 @@ For more information please check out [TranslatePress documentation](https://tra
112
  6. Menu Language Switcher
113
 
114
  == Changelog ==
 
 
 
 
 
 
 
115
  = 1.1.5 =
116
- Added support for translation blocks using the css class .translation-block.
117
- Added possibility to choose a different language as default language seen by website visitors.
118
- Updated add-ons settings page with the missing add-ons, added Language by GET parameter addon
119
- Fixed issue with the [language-switcher] in a post or page that broke saving the page when Yoast SEO plugin is active
120
- Added a plugin notification class and a notification for pretty permalinks
121
- Added WooCommerce compatibility tag
122
- Small css improvements
123
 
124
  = 1.1.4 =
125
  * Filter to allow adding new language: 'trp_wp_languages'
4
  Tags: translate, translation, multilingual, automatic translation, front-end translation, google translate, bilingual
5
  Requires at least: 3.1.0
6
  Tested up to: 4.9.4
7
+ Stable tag: 1.1.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
26
  * Support for both manual and automatic translation (via Google Translate)
27
  * Ability to translate dynamic strings (gettext) added by WordPress, plugins and themes.
28
  * Integrates with Google Translate, allowing you to set up Automatic Translation using your own Google API key.
29
+ * Translate larger html blocks using the css class **translation-block**. `<p class="translation-block">Translate <em>everything</em> inside</p>`
30
  * Place language switchers anywhere using shortcode **[language-switcher]**, WP menu item or as a floating dropdown.
31
  * Editorial control allowing you to publish your language only when all your translations are done
32
  * Conditional display content shortcode based on language [trp_language language="en_US"] English content only [/trp_language]
113
  6. Menu Language Switcher
114
 
115
  == Changelog ==
116
+ = 1.1.6 =
117
+ * Added support for translating Contact Form 7 alert messages
118
+ * Fixed issue with some strings containing special characters not being translated (i.e. "¿¡")
119
+ * Fixed bug with switching languages in Editor when viewing as Logged out
120
+ * Fixed issue with broken homepage links in some themes
121
+ * Added support for RTL languages in translation editor
122
+
123
  = 1.1.5 =
124
+ * Added support for translation blocks using the css class .translation-block.
125
+ * Added possibility to choose a different language as default language seen by website visitors.
126
+ * Updated add-ons settings page with the missing add-ons, added Language by GET parameter addon
127
+ * Fixed issue with the [language-switcher] in a post or page that broke saving the page when Yoast SEO plugin is active
128
+ * Added a plugin notification class and a notification for pretty permalinks
129
+ * Added WooCommerce compatibility tag
130
+ * Small css improvements
131
 
132
  = 1.1.4 =
133
  * Filter to allow adding new language: 'trp_wp_languages'