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.

How to make qTranslate supports Custom Post Types?

How to make qTranslate supports Custom Post Types?

add this code in

on line 303

add_filter('post_type_link','qtrans_convertURL');//fix custom post type URL


Congrats to Qian Qin for writing some easily extensible code!

Here’s a relatively simple way of adding translations your own custom taxonomies.
Assuming you’ve registered a taxonomy, ‘my_cat’, add these two lines into qtranslate_hooks.php,
near the end of the file around line 244 (search for ‘// Hooks (Actions)’ in the file).

// Custom Taxonomies
add_action(‘my_cat_add_form’, ‘qtrans_modifyTermFormFor’);
add_action(‘my_cat_edit_form’, ‘qtrans_modifyTermFormFor’);

for example i am working on theme called increase it uses custom post type called Projects i looked in the functions and found the categories name is pj-sort-categs
so i added this line to the hooks

//increase projects
add_action(‘pj-sort-categs_add_form’, ‘qtrans_modifyTermFormFor’);
add_action(‘pj-sort-categs_edit_form’, ‘qtrans_modifyTermFormFor’);

and it showed me the languages to the custom post type Categories .