make anything works with qtranslate

add this


qTranslate tries to modify every String it can get its hand on, but unfortunately, custom Plugins often don’t supply filters nor use Gettext for their Strings, so it is impossible for qTranslate to filter out the correct language. You can fix it by yourself if you have some PHP knowledge, if not, you will need to ask the author of the other plugin to take a look at this page, as I don’t have the possibilty to modify their plugins.

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.
    //So if you have something like this
    // replace it with
  • 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).
    $filtered_string = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($raw_string);

Notice: __(‘””); will output meta information of the .mo file if called with an empty string! So you should make sure that it is only called with an non-empty 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:

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.


2 thoughts on “make anything works with qtranslate

Leave a Reply :)

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s