• Resolved Antti Koskinen

    (@kantti)


    Hi,

    I would like to add custom text to the Submit Event Form. For example some instructions / help text under each field.

    I know I could just hardcode the text to the form template, but the site is both in English and in native language. So the custom text should be translatable.

    1) How do I add the custom text to the form so it will be also translatable?

    2) How and where do add the custom translations so that they won’t get wiped out when updating the plugin?

    —-

    Bonus: I would also like to make some tweaks to the native language translation.

    I found this,

    function change_translate_text( $translated_text ) {
    	if ( $translated_text == 'Old Text' ) {
    		$translated_text = 'New Translation';
    	}
    	return $translated_text;
    }
    add_filter( 'gettext', 'change_translate_text', 20 );

    Any idea how do I limit this to only change words in Events manager?

    regards
    kantti

    https://www.ads-software.com/plugins/events-manager/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    1-2) you can use the snippet you shared to translate text and then you can add it in your theme functions.php or using mu-plugins

    eg. https://gregrickaby.com/create-mu-plugin-for-wordpress/

    Thread Starter Antti Koskinen

    (@kantti)

    Ok, so I can use the same snippet to translate the text. But how do I add the custom text to the template file?

    Do I just add this to the template file..

    <p>My custom text under the Event name field</p>

    ..and hey presto it’s translatable?

    Or do I need to use some special tags?

    Regarding the translation tweaking with the snippet. Does it effect every instance of the word I use in the “old text” part? How can I make sure that the tweak just affects the chosen word on the submit event form and not anywhere else on the site?

    caimin_nwl

    (@caimin_nwl)

    Text for translating needs to be wrapped with the e() tag:
    https://codex.www.ads-software.com/Function_Reference/_e

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to add custom translatable text to Submit Event Form?’ is closed to new replies.