• Resolved Jan-Philipp

    (@pogstar)


    Hi Marco,

    I am trying to make the user input fields of the tabs on the Tabify settings page translatable with WPML, so that I can register the Input text as translation strings. I wonder if you can help to understand this whole process, since I fail to register the fields.

    So f.e. i have a CPT “Product” with a tab like “Produkt Description” and I want to translate it to the German “Produktbeschreibung”.

    WPML offers the posibility to register and output translations from plugin input fields. Here is the link to the WPML site: Translating user input texts from plugins and themes
    .

    Here it says by using following code, I can register those texts from the input fields.
    do_action( 'wpml_register_single_string', string $context, string $name, string $value )

    F.e. for a custom widget it would look like that:

    function update($new_instance, $old_instance){
        $instance = $old_instance;
        $instance['custom_input']   = strip_tags($new_instance['custom_input']);
    
        //WMPL
        /**
         * register strings for translation
         */
        do_action( 'wpml_register_single_string', 'Widgets', 'Custom Widget - input field', $instance['custom_input'] );
        //WMPL
    
        return $instance;
    }

    I tried to register my first tab like that, but it did not work:

    function update($new_instance, $old_instance){
        $instance = $old_instance;
    
        $instance['tabify[posttypes][product][tabs][0][title]']   = strip_tags($new_instance['tabify[posttypes][product][tabs][0][title]']);
    
        //WMPL
        /**
         * register strings for translation
         */
        do_action( 'wpml_register_single_string', 'Tabify edit screen', 'Tab 1', $instance['tabify[posttypes][product][tabs][0][title]'] );
    
        //WMPL
    
        return $instance;}

    In this WPML document it says I have to apply filters to make a things happen. I wonder what that means in the context of your plugin. And if that is the reason for why I do not get the input field registered.

    Any help would be much appriciated. Thank you in advance.

    Jan-Philipp

    https://www.ads-software.com/plugins/tabify-edit-screen/

Viewing 1 replies (of 1 total)
  • Plugin Author Marko Heijnen

    (@markoheijnen)

    Hey Jan-Philipp,

    Sorry for the delay. The information you posted is for when you deal with the edit screens for posts, pages or custom post types. The way I store the data isn’t really a way to get it translated easily.

    Currently the only way you could translate them is by code trough the filter “tabify_tabs”. In the next days I also will release a new update which has a new filter called ‘tabify_tabs_tab_title’. You could then use that one for translating it by code.

    I don’t think I will ever add specific code for plugins like WPML. I will wait till WordPress core has support for it.

    Best,
    Marko

Viewing 1 replies (of 1 total)
  • The topic ‘WPML support of user Input fields on settings page’ is closed to new replies.