qTranslate – Notice: Undefined index
-
I have this WP_DEBUG errors when change true instead false:
define(‘WP_DEBUG’, true)Notice: Undefined index: language in public_html/wp-content/plugins/qtranslate/qtranslate_hooks.php on line 111
How can i solve this errors?
I found patch here but I don’t know how should I use it.
Thanks!
-
Hi Ruson,
Patch is a command-line utility: http://en.wikipedia.org/wiki/Patch_%28Unix%29
I do not use patch from the command line, so I cannot help you with that. You can use this patch by just looking at the code changes it makes in the actual text of the patch (compare the + and – lines). Or you could use a text-editor with patch capabilities. I use Eclipse to this end.
The patch you mentioned does have a minor flaw: the function should return $locale and in the patched version it does not.
I have added a different patch to address the notice you found:Index: htdocs/wp-content/plugins/qtranslate/qtranslate_hooks.php
===================================================================
— htdocs/wp-content/plugins/qtranslate/qtranslate_hooks.php (revision 823892)
+++ htdocs/wp-content/plugins/qtranslate/qtranslate_hooks.php (working copy)
@@ -48,17 +48,19 @@
global $q_config;
// try to figure out the correct locale
$locale = array();
– $locale[] = $q_config[‘locale’][$q_config[‘language’]].”.utf8″;
– $locale[] = $q_config[‘locale’][$q_config[‘language’]].”@euro”;
– $locale[] = $q_config[‘locale’][$q_config[‘language’]];
– $locale[] = $q_config[‘windows_locale’][$q_config[‘language’]];
– $locale[] = $q_config[‘language’];
–
– // return the correct locale and most importantly set it (wordpress doesn’t, which is bad)
– // only set LC_TIME as everyhing else doesn’t seem to work with windows
– setlocale(LC_TIME, $locale);
–
– return $q_config[‘locale’][$q_config[‘language’]];
+ if ( isset( $q_config[‘language’] ) ) {
+ $locale[] = $q_config[‘locale’][$q_config[‘language’]].”.utf8″;
+ $locale[] = $q_config[‘locale’][$q_config[‘language’]].”@euro”;
+ $locale[] = $q_config[‘locale’][$q_config[‘language’]];
+ $locale[] = $q_config[‘windows_locale’][$q_config[‘language’]];
+ $locale[] = $q_config[‘language’];
+
+ // return the correct locale and most importantly set it (wordpress doesn’t, which is bad)
+ // only set LC_TIME as everyhing else doesn’t seem to work with windows
+ setlocale(LC_TIME, $locale);
+ return $q_config[‘locale’][$q_config[‘language’]];
+ }
+ return $locale;
}function qtrans_optionFilter($do=’enable’) {
Does not help!
Notice: Undefined index: language in wp-content/plugins/qtranslate/qtranslate_hooks.php on line 148
I think the other parts of the patch you mentioned earlier needs to be applied too. I had a quick look at those and thought they were OK.
This problem was because of plugin W3C total cache, when i deleted it everything ok.
After installing WP Super cache the same problem =(
This is a strange issue; I had qtranslate working for some months. Today I disabled the plugin temporarily and when re-activating the plugin the mentioned “undefined index” notices start to pop up…
My solution/suggestion is to modify the qtranslate_hooks.php and call qtrans_init() when required. Like this:
(Starting at line 104)
function qtrans_useCurrentLanguageIfNotFoundShowAvailable($content) { global $q_config; // Add the following line: if( !isset($q_config['language']) ) qtrans_init(); return qtrans_use($q_config['language'], $content, true); } function qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($content) { global $q_config; // Add the following line: if( !isset($q_config['language']) ) qtrans_init(); return qtrans_use($q_config['language'], $content, false); }
Reason:
This warning occurs, when another plugin calls any of the filters that are hooked toqtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage
before theplugins_loaded
action is called (like a plugin calling the bloginfo() function when it is loaded)
There should be no problem with the fix I post above, since the qtrans_init method will only execute the first time is is calledafter adding this code just white screen and
Fatal error: Cannot redeclare qtrans_useCurrentLanguageIfNotFoundShowAvailable() (previously declared in /home/domains/public_html/wp-content/plugins/qtranslate/qtranslate_hooks.php:104) in /home/domains/public_html/wp-content/themes/evroluxe/functions.php on line 334
Ruson: The functions already exist, what I did mean is to only add this one line inside the both functions:
if( !isset($q_config['language']) ) qtrans_init();
(The rest of the code is just to tell you where to add this line)
Oh yeah, you are right, but I got another problem after adding the code…
Fatal error: Call to undefined function wp_get_current_user() in /home/evroluxe/domains/evroluxe.com/public_html/wp-includes/capabilities.php on line 1342
Hi all,
I have problems translating content on pages (edit page). It won’t update what I am translating? I don’t have any problems when it is a post I want to translate.
I blame my lack of experience working with WP. Tried debugging all day until this post.
FYI I have the latest updates of both qtranslate and WP.
Thanks
This was extremely helpful, cheers guys. Wish this issue would be fixed in the plugin update.
- The topic ‘qTranslate – Notice: Undefined index’ is closed to new replies.