There are 2 basic ways to make qTranslate work with your plugin:
- Use Gettext to filter all output. Wordpress already includes this function, so it can simply be added everywhere.
- Code: Select all
//So if you have something like this
do_someoutput("Code");
// replace it with
do_someoutput(__("Code"));
- Use qTranslates internal translation filter. This function will be faster, but you will need to check wether the function exists or not (for non-qTranslate users).
- Code: Select all
$filtered_string = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($raw_string);
My suggestion would be using Gettext for texts that are non-dynamic (Title, Error Message). As for dynamic texts (comment text, blog entry text), I suggest using qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage() instead. Use something like this:
- Code: Select all
if(function_exists('qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage')) $output = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($output);
qTranslate also modifys the WYSIWYG editor (TinyMCE) are creates a second instance with the corresponding text area (id="qtranslate_textarea_content"). So if your plugin is inserting anything to tinyMCE, you will need to check if there is such a text area and if, insert to the qTranslate text area instead of the default text area.
If you are the author of a plugin and have trouble making your plugin work with qTranslate, feel free to contact me.
