• Resolved eznetmarketing

    (@eznetmarketing)


    Good morning, I wanted to ask you if it would be possible to set it up to do automatic translations of components that contain HTML tags together as one paragraph without breaking them into several parts. Because often when they are translated in chunks, it loses the sense of the sentence and does the wrong translations.

    For example:

    La <b>cucina</b> è completamente attrezzata e <b>sicura</b>

    It breaks in 4 translations:

    1. La
    2. <b>cucina</b>
    3. è completamente attrezzata e
    4. <b>sicura</b>

    But the final result of the translation in other languages is not accurate. Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Alex

    (@alexcozmoslabs)

    Hi,

    This may not work 100% due to the limitations of machine translations and how the content is created and will need manual touch-ups from time to time.
    You will need to use the arrow-up tool from Translation Editor and merge those strings into one block. In this way, the automatic engine will be notified and should translate them accordingly.
    While automatic translation is great most of the time, there are cases where manual editing is required.

    Thread Starter eznetmarketing

    (@eznetmarketing)

    Is it possible to set automatically/programmatically that each <p> or <h1/2/3> in case it cointains “<b>” inside, will be merged with the whole <p>/<h>; instead of using manually “arrow-up tool” for each?

    Thank you!

    Plugin Support Alex

    (@alexcozmoslabs)

    Hi again, Merging strings into translation can only be performed manually using the front-end script. There is no back-end equivalent that we are offering right now. But perhaps an easier way to insert your existing translations would be to do it directly on the database and not using Selenium. While some trimming and escaping is performed, the string that needs to be saved in the db to be later recognized as a translation block is pretty much the original string (My paragraph with a bold word.) with the added information that in the block_type column the value must be set to 1. (0 is for any other normal string, 1 is for translation block, 2 is for deprecated translation block). The wp_trp_original_strings and wp_trp_dictionary_lang1_lang2 need to be modified. Manually merge a translation block to have an example in the database and write a script to match the format. It might be useful to write the script in PHP so that you can make use of some trimming or escaping functions that TP uses to sanitize the saved value. You can skip these trimming and sanitizing functions If your original strings are sanitized and don’t have a lot of complex HTML.

    However, some time ago a client of ours sent us the following code with which to force the translation block for each paragraph so that manual intervention is no longer necessary. Therefore, he added the following code to its function:

    function add_custom_content_to_blocks( $block_content, $block ) {
    // Specify the blocks you want to target
    $target_blocks = array('core/paragraph', 'core/list', 'core/table');
    
    // Check if the current block is in the list of target blocks
    if ( in_array( $block['blockName'], $target_blocks ) ) {
    // Define the content you want to add before and after
    $before_content = '<div class=translation-block>';
    $after_content = '</div>';
    
    // Add the before and after content to the block content
    $block_content = $before_content . $block_content . $after_content;
    }
    
    return $block_content;
    }
    
    // Hook the above function to the 'render_block' filter
    add_filter( 'render_block', 'add_custom_content_to_blocks', 10, 2 );

    We haven’t tested it and we don’t guarantee it, but most likely you can ask a developer for help to create a custom solution in this sense.

    Thread Starter eznetmarketing

    (@eznetmarketing)

    Im using Elementor

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Translation without breaking into pieces html tags’ is closed to new replies.