Jump to content

Copy button for multilingual content


Juergen
 Share

Recommended Posts

It would be great to add a copy button for content fields on multilingual site.

F.e.:

You have written a complex text with images, tables and so on in your body field in your default language (fe English). After that you want to translate the content to other languages (German, French). Therefore you have copy all the content.

If there will be a copy button to copy the whole content of the default language body field to all the other language body fields with only one click. You will only have to translate the content. There will be no need to insert all the elements once more by copy and paste.

This would be a great addition to make working with multilingual sites much more comfortable.

Best regards

  • Like 2
Link to comment
Share on other sites

With great power comes great responsivity :) Perhaps the risk could be minified adding some kind of confirmation, or requiring a checkbox to overwrite existing content.

  • Like 1
Link to comment
Share on other sites

Copying the source code is necessary at the moment. Anyway. It could be a useful feature to copy content via clicking a button and maybe it could be integrated easily without a lot of effort.

But this is not a real important feature. It was only a thought of mine to improve the workflow.

Best regards

Link to comment
Share on other sites

My goal was not to copy only one field. The body field was only an example. It would be great to copy all multilingual fields in the template with only one click. Imagine you have more textareas or editor fields in a template. One click and you have copied all your fields at once.

Link to comment
Share on other sites

  • 2 months later...

I wrote a short script which searches all language fields and call an update statement to copy the content to another language

<?php

include(__DIR__."/index.php"); 

$field_db_names = array();

foreach($wire->wire('fields')->find("type=FieldtypeTextareaLanguage|FieldtypeTextLanguage") as $key => $field) {
   $field_db_names[] = strtolower($field->name);
}

$languageMap = array(
    'data' => 'data1017'
);

$db = $wire->wire('database');

foreach ($field_db_names as $field) {
    
    echo "processing field ".$field."\n";
    
    foreach ($languageMap as $from => $to) {
        
        echo "copy $from to $to \n";
    
        $sql = sprintf("UPDATE field_%s SET %s = %s WHERE %s = '';",$field,$to,$from,$to);
        $db->query($sql);        
    
    }
    
}

$languageMap contains the information what field is used to fetch the content. so in this example data is copied to data1017 if it is still empty (so nothing is overwritten).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...