Shift+Enter Bug

Having Problems? Need Help? Post here!

Shift+Enter Bug

Postby ahackel » Fri Mar 12, 2010 9:14 am

Hi in the current qtranslate versions line breaks entered with shift+enter are converted into new paragraphs - the same break you would create when entering only enter. This is only true for the additional languages, when you type shift+enter in the default language everything is fine.

Steps to reproduce:
- go to edit post
- switch to a none-default language
- Enter a line of text, type shift+enter, enter another line of text
- Click publish
- switch to a different page
- go to edit post again
- switch to the language you used to enter the text
- now to shift+enter break has been converted into a enter-break
ahackel
 
Posts: 2
Joined: Fri Mar 12, 2010 9:04 am

Re: Shift+Enter Bug

Postby hackeman » Tue Mar 23, 2010 10:22 pm

Same problem here. Or similar I should say. In the default English language post it removes ALL line feeds, no matter if they were entered using regular Enter or Shift Enter, and in the non-default Language it INSERTS line feeds between all lines.

Even if I use HTML view and enter <br> code in the default language post these are deleted by qTranslate when post is saved. The only way to get an extra line feed where I want one now is to put a period (.) or any other character on that line.

The only way to get the translated page NOT to contain all those EXTRA line feeds inserted by qTranslate is to edit the post, remove all the line feeds, save the post and NEVER edit it again. Whenever I edit the post, qTranslates inserts the line feeds again.

Very annoying issue indeed.
hackeman
 
Posts: 3
Joined: Wed Nov 04, 2009 2:04 am

Re: Shift+Enter Bug

Postby hackeman » Tue Mar 23, 2010 10:30 pm

Btw, I've tried resetting qTranslate settings but didn't do any good.
hackeman
 
Posts: 3
Joined: Wed Nov 04, 2009 2:04 am

Re: Shift+Enter Bug

Postby janim » Fri Mar 26, 2010 12:12 pm

It seems that the bug is triggered by applying wpautop function twice to the content that is not in your default language.
Here's what I did to fix the bug:

Open qtranslate_javascript.php and replace the variable $q_config['js']['qtrans_assign'] with following:
Code: Select all
$q_config['js']['qtrans_assign'] = "

if ( typeof( switched ) == 'undefined' ) {
  switched = new Array();
  switched['".$q_config['default_language']."'] = 0;
}

qtrans_assign = function(id, text, lang) {   

  if ( typeof(switched[lang]) != 'undefined' ) {
    switched[lang] = 1;
  }
  else {
      switched[lang] = 0;
  }

  var inst = tinyMCE.get(id);
  var ta = document.getElementById(id);
  if(inst && ! inst.isHidden()) {
    if (switched[lang] == 1) {
      htm = switchEditors.wpautop(text);
    }
    else {
      htm = text;
    }

    inst.execCommand('mceSetContent', null, htm);
  } else {
    ta.value = text;
  }
}

";

Haven't tested this thoroughly yet so please do reply if you find any abnormal activities :-)
janim
 
Posts: 1
Joined: Fri Mar 26, 2010 12:04 pm

Re: Shift+Enter Bug

Postby rufti66 » Tue Dec 07, 2010 4:03 pm

I have tryed to change the the variable $q_config['js']['qtrans_assign'] as discussed before but it didn't help. Still this bug is working, no change at all, which makes the otherwise so good working plugin useless, as with every small change inside one of the language the design of the secondary languages are lost. Anyone knows what to do? Thank you.
rufti66
 
Posts: 3
Joined: Tue Dec 07, 2010 3:58 pm

Re: Shift+Enter Bug

Postby oswaldson » Sun Dec 12, 2010 8:04 am

rufti66 wrote:I have tryed to change the the variable $q_config['js']['qtrans_assign'] as discussed before but it didn't help.

janims workaround works like a charm! he only forgot to mention one little modification that is indispensable.

here is the working solution:

change in qtranslate_javascript.php:
replace the variable $q_config['js']['qtrans_assign'] with following (same as janim wrote):
Code: Select all
   $q_config['js']['qtrans_assign'] = "
      if ( typeof( switched ) == 'undefined' ) {
         switched = new Array();
         switched['".$q_config['default_language']."'] = 0;
      }

      qtrans_assign = function(id, text, lang) {

         if ( typeof(switched[lang]) != 'undefined' ) {
            switched[lang] = 1;
         }
         else {
            switched[lang] = 0;
         }

         var inst = tinyMCE.get(id);
         var ta = document.getElementById(id);
         if(inst && ! inst.isHidden()) {
            if (switched[lang] == 1) {
               htm = switchEditors.wpautop(text);
            }
            else {
               htm = text;
            }
            inst.execCommand('mceSetContent', null, htm);
         } else {
            ta.value = text;
         }
      }
      ";

additionally change the call of qtrans_assign in the last line of qtranslate_javascript.php.
replace qtrans_assign('qtrans_textarea_'+id,qtrans_use(lang,ta.value)); with:
Code: Select all
qtrans_assign('qtrans_textarea_'+id,qtrans_use(lang,ta.value),lang);
oswaldson
 
Posts: 2
Joined: Sun Dec 12, 2010 7:42 am

Re: Shift+Enter Bug

Postby jeroen1973 » Sun Dec 19, 2010 9:45 am

I have noticed the same behaviour. It seems like a small change to the code. I hope it will be in version 2.5.14.

Regards, Jeroen
jeroen1973
 
Posts: 6
Joined: Sun Dec 19, 2010 9:27 am

Re: Shift+Enter Bug

Postby robertn » Sun Dec 19, 2010 2:07 pm

I had the same annoying problem, and your solution works great for me.
Thank you very much, janim and oswaldson, for providing the patches!
Without it, I would have to consider switching from qTranslate to WPML...
I hope that Qian will integrate these patches into qTranslate.

Kind Regards, Robert N.
robertn
 
Posts: 3
Joined: Wed Nov 17, 2010 1:35 am
Location: Lodz, Poland

Re: Shift+Enter Bug

Postby rufti66 » Sat Dec 25, 2010 11:16 pm

Thank you, now with the change to "qtrans_assign('qtrans_textarea_'+id,qtrans_use(lang,ta.value),lang);" it is working. Great!

Maybe this could be standard for any update or is there any reason why not?
rufti66
 
Posts: 3
Joined: Tue Dec 07, 2010 3:58 pm

Re: Shift+Enter Bug

Postby julien.fs » Thu Jan 13, 2011 2:51 am

Bump. Since we are the 13 January 2011 and this bug still exists in the last build. Really the kind of bug that make any serious users switch to other language plugins or CMS, since a simply correction that would normally take 5sec become a presentation fight of 10min.

To janim and oswaldson, THANKS A LOT! I've been banging my head on my keyboard because of this one.
julien.fs
 
Posts: 9
Joined: Fri Oct 15, 2010 2:18 am

Next

Return to qTranslate Support Forum

Who is online

Users browsing this forum: Google [Bot] and 6 guests