Custom Field trasnlation with Polylang Pro

Support General Custom Field trasnlation with Polylang Pro

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #49098
    webdevwebdev
    Participant

    Hi,
    I have the following code to register custom fields for translation (copied directly from the MetaBox code generator):

    <?php
    add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' );
    
    function your_prefix_register_meta_boxes( $meta_boxes ) {
        $prefix = '';
    
        $meta_boxes[] = [
            'post_types'  => ['chart-mapping'],
            'translation' => 'advanced',
            'title'       => __( 'test mapping fields', 'your-text-domain' ),
            'id'          => 'test-mapping-fields',
            'fields'      => [
                [
                    'type'        => 'textarea',
                    'id'          => $prefix . 'translateable',
                    'name'        => __( 'translateable', 'your-text-domain' ),
                    'translation' => 'translate',
                ],
                [
                    'type'        => 'text',
                    'id'          => $prefix . 'untranslateable',
                    'name'        => __( 'untranslateable', 'your-text-domain' ),
                    'translation' => 'copy',
                ],
            ],
        ];
    
        return $meta_boxes;
    }

    The option 'translation' => 'translate' does not work correctly in the textarea field, and always behaves in the same way as a 'copy'.
    Note this is the same if the top-level option is set to 'translation => 'translate' instead of 'advanced' as well.

    Is this a bug or am I doing something wrong?

    #49110
    PeterPeter
    Moderator

    Hello,

    The option 'translation' => 'translate' does not work correctly in the textarea field, and always behaves in the same way as a 'copy'.
    

    When you create or edit a translation post, if you add the translation field value, difference from the original field, after saving the post do you see the same value as the original?

    #49118
    webdevwebdev
    Participant

    I have text in the field, eg:

    'My text in language 1'

    I create a translation:

    The text in the field reads:

    'My text in language 1' <-- this is correct so far

    I change the text in the translation to:

    'My text in language 2' <-- create a translation

    Save the translation.

    When I go back to the original, it reads:

    'My text in language 2' <-- showing the translated text where it should show the original

    If I change it back to the original text then the translation also changes, ie both the translation and the original are always the same (as in a 'copy')

    #49123
    PeterPeter
    Moderator

    Hello,

    For the text field with copy setting, I see it works properly. The copy action means this field value is synchronized between the original post and its translation. It doesn't mean only copying from the original post.

    #49126
    webdevwebdev
    Participant

    Yes, correct, the 'copy' setting behaves like that... but the 'translate' setting behaved exactly the same...
    As it happens, I've uninstalled Polylang for this project and am using WPML, as there were some errors showing up in Settings forms, so I won't be able to test any more anyway...

    #49130
    PeterPeter
    Moderator

    Hello,

    I don't see the issue with "translate" setting on my site, please check this screen record https://drive.google.com/file/d/1gKr9ZbJAi2LWQ8J56Qe5Xv19Sef6NHfM/view?usp=sharing

    Let me know if you have any questions when using Polylang with Meta Box.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.