(Sorry if this is already discussed. I didn't find solution with search)
I noticed qTranslate sets locale too late for other plugins to load text domain / locale correctly.
This is how you get it fixed and I hope Qian Qin makes fix to qtranslate sometime so I don't have to do this everytime updating WP:
The problem is q_config["language"] is set too late (it is set in qtrans_init() function) if qtrans_init is called with action "plugins_loaded".
Fix 1: Comment out add_action('plugins_loaded', 'qtrans_init'); from qtranslate_hooks.php and add qtrans_init(); function call to the end of qtranslate.php file.
Now q_config["language"] is set before add_filter('locale', qtrans_localeForCurrentLanguage',99); gets fired.
But wait a minute, now I can't get to wp-admin since it shows error something like "current_user_can is not defined...". The qtrans_init() function has the line
- Code: Select all
// update definitions if neccesary
if(defined('WP_ADMIN') && current_user_can('manage_categories')) qtrans_updateTermLibrary();
This is bad code i think. Why not call the qtrans_updateTermLibrary with some hook for example admin_init?
Fix 1.1:
Comment out above line from qtrans_init function and add new hook to qtranslate_hooks.php
- Code: Select all
add_action('admin_init', 'qtrans_updateTermLibrary');
You can add that capability check to qtrans_updateTermLibrary function
- Code: Select all
// change this
if(!isset($_POST['action'])) return;
// to
if(!isset($_POST['action']) || !current_user_can('manage_categories')) return;
Whow, too many fixes already but thats not all!
Fix 1 is not enough if WP loads any plugins before qtranslate. So, what you need to do is rearrange WP option "active_plugins" array which is iterated in wp-setting.php to initiate plugins so that qtranslate gets loaded first. Add this short code to your plugin:
Fix 2:
- Code: Select all
function init_qtranslate_first() {
$active_plugins = get_option('active_plugins');
// Check if qtranslate is active and not first to load
$key = array_search('qtranslate/qtranslate.php', $active_plugins);
if ($key) {
// Move to the begining of active_plugins array
$q = $active_plugins[$key];
unset($active_plugins[$key]);
array_unshift($active_plugins, $q);
// Update option
update_option('active_plugins', $active_plugins);
}
}
add_action ('your_favorite_hook_that_executes_sometimes', 'init_qtranslate_first');
Now all your other plugins get right mofile from the start!
Hope this helps!
