Closed mayeenulislam closed 7 years ago
My opinion: we can implement filter hook for each of the tooltips. But on first thought, wouldn't that be too messy? Let me check some trends.
We've discussed your demand with my mentors to find a viable solution. We found that, gettext
filter is your key to change any translation strings from our plugin (and from any WordPress product).
But before proceeding, please consider the risk factor — quoting Rarst:
In practice it can fire thousands of times and if you just hook into it unreservedly it will quickly slow down complex site to a halt.
So we provided you a demo function filtering the specific tooltip text of that specific page only. So the filtering works only on that page and only to that specific string. You can place such function to your theme's functions.php
, and it'll do the job. Follow the inline comments for further explanation.
/**
* Change the submit ticket Tooltip text.
*
* @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
*/
function my_theme_change_submit_ticket_tooltip_text( $translated_text, $text, $domain ) {
// Get the NanoSupport Settings from Database
$ns_general_settings = get_option( 'nanosupport_settings' );
// Submit Ticket page
$submit_ticket_page_id = $ns_general_settings['submit_page'];
// String to change, exactly copied from NanoSupport v0.3.0
$target_string = 'Write down your issue in details... At least %s characters is a must.';
// Proceed to change the text if it's in submit ticket page only
if ( is_page($submit_ticket_page_id) && $target_string === $translated_text ) {
// ’ = ' (single quote)
$translated_text = __( 'Explain your request. The more details the better. Don’t forget to include your credentials so we can log in to your site', 'theme_text_domain' );
}
// return all the modified text along with your changed one
return $translated_text;
}
add_filter( 'gettext', 'my_theme_change_submit_ticket_tooltip_text', 20, 3 );
PS Please note, gettext
filter hook can be used for all the translation functions where __()
, _e()
etc. is used. But if you find any _x()
declaration, then you will need to use gettext_with_context
filter hook.
Pardon my uneducated comment... Is there no way to add a language file for this plugin for translations?
@gwmbox You got the point wrong. The plugin is completely translatable like any other translation-ready plugin.
If you have the automatic translation for your language, it's fine. If not, you can translate and put the files as mentioned here...
As Dustin asked for: