• Resolved fabykennedy

    (@fabykennedy)


    Hi Stéphane. I’m sorry to post all these topics but I need to test well the plugin to see if it suits my needs.

    I noticed a very annoying issue. When translating, every time I switch between text and visual panels the <p> tag disappears. This is unacceptable to me because it messes up the entire work, meaning it deletes the text formatting and therefore the text in the article isn’t displayed properly.

    Please let me know if something can be done. Thank you.

Viewing 15 replies - 1 through 15 (of 21 total)
  • Plugin Author sbouey

    (@sbouey)

    Hi,

    i will see what’s wrong normally it’s solved this the 1.3.5

    with the fileter

    
    add_filter('tiny_mce_before_init', array($this, 'tags_tinymce_fix'));
    

    and the code

    
    /**
         * keep <p> tags in Falang & Classic editor
         *
         * @from 1.3.5
         * @update 1.3.20 keep nbsp and shy
         */
        function tags_tinymce_fix($init)
        {
            $init['remove_redundant_brs'] = false;// don't remove redundant BR
            $init['wpautop'] = true;//wpautop = yes
            $init['indent'] = true;
            $init['tadv_noautop'] = true;
            $init['forced_root_block'] = false;//no p tags around the whole block
            $init['entities'] .= ',160,nbsp,173,shy'; //keep nbsp and shy
            $init['entity_encoding'] = 'named';
            $init['remove_linebreaks'] = false;
            $init['convert_newlines_to_brs'] = false;// don't convert newline characters to br tags
    
            return $init;
        }
    

    Hi,

    Just my two cents (I am a happy Falang user):

    This is not a Falang issue, it is a very old WP problem when switching between visual and text in TinyMCE (the Classic Editor), and you cannot solve it easily. Please understand that the text mode in the classic editor is NOT a fully fledged HTML editor.

    Unlike what you say, the current setup messes up nothing. It is just fine when switching between visual/text editors, even if the p tags don’t show in the text editor. It is a workaround for issues created by WP trying to be “helpful”. The current Falang setup works fine with its TinyMCE filter, because otherwise there are often unnecessary p tags around some special blocks (like images, code blocks, galleries, shortcodes, etc.) in many themes (which you would then need to remove manually). So there is nothing wrong here, the p tags are added automatically by wpautop in the frontend where they are grammatically correct (for instance after a heading).

    See these links (and you can find many more)
    https://www.greengeeks.com/tutorials/stop-wordpress-from-auto-formatting-html-in-posts-and-pages/
    https://www.ads-software.com/support/topic/tags-being-stripped-in-classic-block-content-after-wp-upgrade/

    PS
    The Block Editor (Gutenberg) has its own issues as well with the p tags and switching, since they use comments to identify blocks. Google it for lots of user problems.

    Rob

    Thread Starter fabykennedy

    (@fabykennedy)

    I can’t say the same. I’m testing Falang on my local environment and when I publish a translated article text isn’t formatted properly because of this problem. I can only see a <div> containing text, but there should be a paragraph instead… it really messes up my work.

    Hi,

    That’s strange. Did you copy the original text in Falang in text mode (both original and translation windows tabs) to the translation window before translating? That’s how I do it and it works flawlessly.

    The behaviour of not showing p tags in text mode after switching from visual and back is “normal” WP behaviour since 2003. The Falang tinymce filter just removes some unwanted additions elsewhere.

    The classic tinymce editor behaviour is this when viewing in text mode:
    In general, the editor removes
    a) plain p and br tags (they will be present in the actual sourcecode of the page, but they are hidden from view in the editor, to avoid unnecessary clutter);
    b) wrong or forbidden coding;
    c) tags that are or seem useless (for instance span tags without the style attribute).

    I would recommend that you check the code in the (original language) text mode tab of Falang to see if there are maybe some strange characters present. Then try to copy (both windows in text mode) with the button and translate in the translation window.

    If that doesn’t work, you may need to ask Stéphane to to check the behaviour on your website (with your setup, plugins and theme) or provide him with a working copy of your site.

    Hope you find what’s going on. I have not seen this problem with Falang in many themes or setups I tried.

    P.S.
    First thing I would try if I were in your shoes is to switch to another WP provided theme. Maybe it is something specific that happens with your chosen theme?

    Thread Starter fabykennedy

    (@fabykennedy)

    Hi and thank you very much for your suggestions.

    Yes, I tried to copy the text with both windows in text mode but it doesn’t change the situation… At first the <p> tag is present, but as soon as I switch to visual mode and then come back in text mode it disappears.

    It wouldn’t be a problem if once published the article “it was back” on the translated page, but unfortunately it gets completely lost.

    I don’t know it’s a theme ralated problem, but I can’t change it to make it work properly.

    Like I explained before, this is “normal” behaviour for the WP classic editor. It doesn’t show the p and br tags in text view after switching back and forth between visual and text. It has always been like that, it is the way the classic editor in WP is set up. But WP autop adds the paragraph tags wherever they are needed in the frontend. Autop (part of standard WP) just takes a best guess at proper HTML formatting. In text view p and br are not shown, always been like that. But they are there, you can check it in the frontend source code.

    I just remembered I once had a somewhat similar issue (but with another translation plugin), where it turned out to not show the translation when the article started with a shortcode. Could it be that maybe one of the (theme) plugins does that at the top of a page/post? Should be easy to check by disabling those possible plugins one by one.

    Sorry, can’t be of more help, you will have to rely on Stéphane after that…

    Thread Starter fabykennedy

    (@fabykennedy)

    Can you tell me what fronted source code is please?

    Yes I think I’ve read about someone who had my problem and discovered that it was a theme issue, so I tend to think it’s a theme problem. Honestly I don’t know where to lay my hands… but maybe Stéphane will be able to find a solution.

    I’m so sorry I’m causing him so much trouble, but I really need to check if Falang suits my needs.

    Frontend source code: I meant frontend page source, i.e. when you view a page in the frontend, right-click > View Page Source.

    It was just to illustrate how autop works, to show you that in the frontend page source the p tags are there, even if you do not see them in the Classic Editor Text View mode.

    • This reply was modified 2 years, 4 months ago by Rob de Cleen. Reason: fixed typo
    Plugin Author sbouey

    (@sbouey)

    Hi, thanks Rob for the info,
    I will release the new version of Falang today and try to find what’s happen.
    i haven’t found yesterday.

    When you use the classic editor in WordPress you can switch beween the Visual/Text without problem.
    When you are in the Falang translation page with the same editor the <p> tag are lost in the text view but are still presents in the textarea of the editor (look the source page)

    I keep you informed.

    Stéphane

    Thread Starter fabykennedy

    (@fabykennedy)

    Yes you’re right, I’ve just checked. It remains a mistery why they disappear once the article is published.

    Anyway Stéphane, any chances to implement Gutenberg editor in a future release of Falang?

    Sorry to jump in again, but this is normal behaviour in the both the Classic Editor AND in the classic block in the Block Editor.

    If I edit a post in the classic editor (stand-alone version, not the Falang interface) the behavior is exactly the same when switching between visual end text. The p tags are NOT shown in text view, ever. This is normal WP behavior. Then autop adds them when rendering in the frontend.

    https://github.com/WordPress/gutenberg/issues/4446

    For classic block, the block mimics pre-5.0 behavior, where the omission of paragraph tags has existed since 2003 (the “autop” behavior).

    The only thing the filter in Falang does extra (as far as I understand) is to remove the root block paragraph tags (the unnecessary p tags around the whole block) and to allow for soft-hyphens and non-breaking spaces to keep showing in text view.

    • This reply was modified 2 years, 4 months ago by Rob de Cleen.
    • This reply was modified 2 years, 4 months ago by Rob de Cleen.

    So, @fabykennedy, what I have been trying to say quite a few times now is this in short:
    the p tags “disappearing” is the way WP intends it to work in text view mode. They once decided to not show the p tags in text view mode, and have autop correct the html for the frontend rendering. This does not depend on the editor, the classic block in the Gutenberg editor behaves exactly the same.

    So, to my understanding, it is highly unlikely that your problem (in your words: because it messes up the entire work, meaning it deletes the text formatting) is due to this p tags fact. This works as WP intended it to work, whether we agree with it or not.

    Your issue with the text formatting is most likely caused by something else in your markup (shortcode, widget, theme, plugin), not this particular “p tag not showing in text view” thing.

    Hope you can find what’s causing it. Happy hunting!

    • This reply was modified 2 years, 4 months ago by Rob de Cleen.
    • This reply was modified 2 years, 4 months ago by Rob de Cleen.
    Thread Starter fabykennedy

    (@fabykennedy)

    Yes, I’ve perfectly understood, thank you. It’s just that using another translation plugin this doesn’t happen.

    Anyway I asked about Gutenberg editor for other reasons. For example, I wish there was the possibility to get a preview of the article or check Yoast SEO suggestions, as I always do when I write a post in my native language.

    Plugin Author sbouey

    (@sbouey)

    Hi,

    I have use tastewp to make a simple test and the result is very strange

    When i open the sample page translation in falang and use the copy button i have this result
    after copy

    You can see <p> tag are copied but not visible in the source

    if i switch from text to visual
    after swtich
    the source and target are the same visually

    perhaps having <p> in <!– /wp:paragraph –> is something not normal

    yes i want to add gutenberg editor in Falang translation page but i haven’t found yet how to make it. it’s seen not possible or very complicate to make the same system i have done with Element/Divi/WPBalery/Yootheme to translate directly each item in the page

    Stéphane

Viewing 15 replies - 1 through 15 (of 21 total)
  • The topic ‘tag disappears when switching between text and visual panels’ is closed to new replies.