Skip Navigation

[Resolved] Translate Toolset form messages and apply to all forms

This support ticket is created 2 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 1 reply, has 2 voices.

Last updated by Waqar 2 years, 11 months ago.

Assisted by: Waqar.

Author
Posts
#2309385
Screenshot 2022-03-06 at 9.52.35 AM.png

Dear Sir/Madam,

I want to translate all toolset form messages but I don't want to do that one by one, I don't expect to do it by Translation plugins lik WPML as my site is non-English website. How can I do it once and apply to all forms? It is fine to do it with custom code.

Best regards,

Kelvin,.

#2309985

Hi Kelvin,

Thank you for contacting us and I'd be happy to assist.

To translate/customize the form messages for all forms, you can use the filter 'cred_translate_action_message'.

For example:


function custom_callback_form_messages( $string ) {
    switch ( $string ) {
        case 'Post Saved' :
            $string = 'New message for Post Saved';
        break;
        case 'The post was not saved because of the following problem:' :
            $string = 'New message for The post was not saved because of the following problem:';
        break;
        
    }
    return $string;
}
add_filter( 'cred_translate_action_message', 'custom_callback_form_messages' );

The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.

In this example snippet, I've translated/customized the first two form messages and you can add more cases for the rest of the form messages, the same way.

regards,
Waqar