qtranslate / qtranslate-xt

qTranslate-XT (eXTended) - reviving qTranslate-X multilingual plugin for WordPress. A new community-driven plugin soon. Built-in modules for WooCommerce, ACF, slugs and others.
GNU General Public License v2.0
545 stars 103 forks source link

Qtranslate Language Switcher Stuck - Chrome #1382

Open Pbalazs89 opened 9 months ago

Pbalazs89 commented 9 months ago

The issue is with the language switcher. On the homepage (the hungarian version loads for me) if I click on the english flag - /en/ gets added to the URL, which is great! But if I try to switch back to hungarian, it keeps redirecting to the /en/ version.

I tried turning off the qtranslate language switcher cookie, but it does the same behavior without it as well (although I noticed, that if I don't manually delete it when it is turned on, it will not update when I switch back to hungarian either)

Steps to reproduce the behavior:

  1. Go to page https://solinfo.hu/
  2. Click on another language
  3. Try to switch back to original language.
  4. Scratch head
  5. See error

Weird part is that no development was done on the website, and the client reported this out of the blue. I asked hosting if anything was updated and they do not know about it either.

Screenshots

https://www.loom.com/share/ccc9ac28e8e94181b209f9c6cdd55355

Debug info { "configuration": { "default_language": "hu", "enabled_languages": [ "hu", "en" ], "flag_location": "plugins/qtranslate-xt/flags/", "language_name": { "hu": "Magyar", "en": "English" }, "locale": { "hu": "hu_HU", "en": "en_US" }, "locale_html": { "hu": "", "en": "" }, "not_available": { "hu": "Sajnos ennek a bejegyzésnek csak %LANG:, : és % nyelvű változata van.", "en": "Sorry, this entry is only available in %LANG:, : and %." }, "date_format": { "hu": "%Y %B %e, %A", "en": "%A %B %e%q, %Y" }, "time_format": { "hu": "%H:%M", "en": "%I:%M %p" }, "flag": { "hu": "hu.png", "en": "gb.png" }, "url_mode": 2, "use_strftime": 3, "filter_options_mode": 0, "language_name_case": 0, "detect_browser_language": true, "hide_untranslated": false, "show_displayed_language_prefix": true, "show_alternative_content": false, "hide_default_language": true, "use_secure_cookie": false, "header_css_on": true, "header_css": ".qtranxs_flag_hu {background-image: url(https://solinfo.hu/wp-content/plugins/qtranslate-xt/flags/hu.png); background-repeat: no-repeat;}\n.qtranxs_flag_en {background-image: url(https://solinfo.hu/wp-content/plugins/qtranslate-xt/flags/gb.png); background-repeat: no-repeat;}\n", "text_field_filters": [], "front_config": { "all-pages": { "filters": { "text": { "widget_title": "20", "widget_text": "20", "the_title": "20", "category_description": "20", "list_cats": "20", "wp_dropdown_cats": "20", "term_name": "20", "get_comment_author": "20", "the_author": "20", "tml_title": "20", "term_description": "20" }, "term": { "cat_row": "0", "cat_rows": "0", "wp_get_object_terms": "0", "single_cat_title": "0", "single_tag_title": "0", "single_term_title": "0", "the_category": "0", "get_term": "0", "get_terms": "0", "get_category": "0" }, "url": { "author_feed_link": "10", "author_link": "10", "get_comment_author_url_link": "10", "post_comments_feed_link": "10", "day_link": "10", "month_link": "10", "year_link": "10", "page_link": "10", "post_link": "10", "category_link": "10", "category_feed_link": "10", "tag_link": "10", "term_link": "10", "the_permalink": "10", "feed_link": "10", "tag_feed_link": "10" } } } }, "term_name": { "Magazin": { "hu": "Magazin", "en": "" }, "Kategória 1": { "hu": "Kategória 1", "en": "" }, "Kategória 2": { "hu": "Kategória 2", "en": "" }, "Hotel": { "hu": "Hotel", "en": "Hotel" }, "Étterem": { "hu": "Étterem", "en": "Restaurant" }, "Világítás": { "hu": "Világítás", "en": "Lighting" }, "Bútor": { "hu": "Bútor", "en": "Furniture" }, "Kiegészítő": { "hu": "Kiegészítő", "en": "Accessories" }, "Privát": { "hu": "Privát", "en": "Private" }, "Kórház": { "hu": "Kórház", "en": "Hospital" }, "Iroda": { "hu": "Iroda", "en": "Office" }, "Bár": { "hu": "Bár", "en": "Bar" }, "Inspiráció": { "hu": "Inspiráció", "en": "Inspiration" }, "Események": { "hu": "Események", "en": "Events" }, "Pályázatok és Díjak": { "hu": "Pályázatok és Díjak", "en": "Awards" }, "Egyéb": { "hu": "Egyéb", "en": "Other" }, "Design Sztorik": { "hu": "Design Sztorik", "en": "Design Stories" }, "Üzlet": { "hu": "Üzlet", "en": "Retail" } }, "disable_client_cookies": false, "ignore_file_types": [ "gif", "jpg", "jpeg", "png", "svg", "pdf", "swf", "tif", "rar", "zip", "7z", "mpg", "divx", "mpeg", "avi", "css", "js", "mp3", "mp4", "apk" ], "url_info": { "cookie_enabled": true, "cookie_lang_admin": "hu", "pagenow": "admin-ajax.php", "REQUEST_METHOD": "GET", "WP_ADMIN": true, "DOING_AJAX_POST": [], "scheme": "https", "host": "solinfo.hu", "path": "/wp-admin/admin-ajax.php", "query": "action=admin_debug_info", "path-base": "", "path-base-length": 0, "wp-path": "/wp-admin/admin-ajax.php", "language_neutral_path": true, "http_referer": "https://solinfo.hu/wp-admin/options-general.php?page=qtranslate-xt", "referer_admin": true, "doing_front_end": false, "lang_cookie_admin": "hu", "lang_admin": "hu", "language": "hu", "set_cookie": false, "page_referer": "options-general.php" }, "language": "hu", "editor_mode": 0, "highlight_mode": 1, "auto_update_mo": true, "hide_lsb_copy_content": false, "lsb_style": "Simple_Buttons.css", "config_files": [ "./i18n-config.json" ], "admin_config": { "post": { "pages": { "post.php": "", "post-new.php": "" }, "anchors": { "post-body-content": { "where": "first last" } }, "forms": { "post": { "fields": { "title": [], "excerpt": [], "attachment_caption": [], "attachment_alt": [], "view-post-btn": { "encode": "display" }, "wp-editor-area": { "jquery": ".wp-editor-area" }, "gallery-caption": { "jquery": ".gallery-caption", "encode": "none" }, "wp-caption-text": { "jquery": ".wp-caption-text", "encode": "display" }, "img-alt": { "jquery": "img", "attrs": [ "alt" ], "encode": "display" } } }, "wpbody-content": { "fields": { "wrap-h1": { "jquery": ".wrap h1", "encode": "display" }, "wrap-h2": { "jquery": ".wrap h2", "encode": "display" } } } }, "js-exec": { "post-exec": { "src": "./admin/js/post-exec.min.js" } } }, "options-general": { "preg_delimiter": "#", "pages": { "options-general.php": "^(?!.page=[^=&]+).$" }, "forms": { "options": { "fields": { "blogname": [], "blogdescription": [], "head-title": { "jquery": "head title", "encode": "display" } } } } }, "widgets": { "pages": { "widgets.php": "" }, "anchors": { "widgets-right": { "where": "before after" } }, "forms": { "widgets-right": { "fields": { "widget-title": { "jquery": "input[id^='widget-'][id$='-title']" }, "widget-text-text": { "jquery": "textarea[id^='widget-text-'][id$='-text']" }, "in-widget-title": { "jquery": "span.in-widget-title", "encode": "display" } } } }, "js-exec": { "widgets-exec": { "src": "./admin/js/widgets-exec.min.js" } } }, "edit-term": { "pages": { "term.php": "", "edit-tags.php": "action=edit" }, "forms": { "edittag": { "fields": { "name": [], "description": [], "parent": { "encode": "display" } } } } }, "edit-tags": { "preg_delimiter": "#", "pages": { "edit-tags.php": "^(?!.action=edit).$" }, "anchors": { "posts-filter": { "where": "before after" } }, "forms": { "addtag": { "fields": { "tag-name": [], "tag-description": [], "parent": { "encode": "display" } } }, "col-left": { "fields": { "tagcloud": { "jquery": ".tagcloud > a", "encode": "display" } } }, "the-list": { "fields": { "row-title": { "jquery": ".row-title", "encode": "display" }, "description": { "jquery": ".description", "encode": "display" } } } }, "js-exec": { "edit-tags-exec": { "src": "./admin/js/edit-tags-exec.min.js" } } }, "nav-menus": { "pages": { "nav-menus.php": "action=edit|menu=\d+|^$" }, "anchors": { "menu-to-edit": { "where": "before after" } }, "forms": { "update-nav-menu": { "fields": { "title": { "jquery": "[id^=edit-menu-item-title-]" }, "attr-title": { "jquery": "[id^=edit-menu-item-attr-title-]" }, "description": { "jquery": "[id^=edit-menu-item-description-]" }, "span.title": { "jquery": "span.menu-item-title", "encode": "display" }, "link-to-original": { "jquery": ".link-to-original >a", "encode": "display" } } }, "side-sortables": { "fields": { "label.title": { "jquery": "label.menu-item-title", "encode": "display" }, "accordion-section-title": { "jquery": "h3.accordion-section-title", "encode": "display" } } } }, "js-exec": { "nav-menus-exec": { "src": "./admin/js/nav-menus-exec.min.js" } } }, "all-pages": { "filters": { "text": { "admin_title": "20" } } } }, "custom_i18n_config": [], "custom_fields": [], "custom_field_classes": [], "post_type_excluded": [], "translator": {}, "qtrans_compatibility": false, "i18n-cache": { "admin_page_configs": { "": { "filters": { "text": { "admin_title": "20" } } } } } }, "versions": { "PHP_VERSION": "7.4.33", "WP_VERSION": "5.7", "QTX_VERSION": "3.7.0" } }

{ "cookies": [], "navigator": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36" }

Versions 3.7.0
Configuration WP 6.3.1
Browser Chrome
Pbalazs89 commented 7 months ago

Hi, Any news perhaps regarding this issue?

What I realized is that the issue happens in Chrome, but works fine in Safari. Any ideas as to how to fix?

Komarovski commented 7 months ago

Do you use some caching plugins?

If you use litespeed caching plugin, you need to create "vary" for qtranslate cookie. Here's the code for .htaccess file that you need to add:

# BEGIN LITESPEED LANGUAGE COOKIE VARY
<IfModule LiteSpeed>
RewriteEngine On
RewriteRule .? - [E=Cache-Vary:qtrans_front_language]
</IfModule>
# BEGIN LITESPEED LANGUAGE COOKIE VARY

If you use some other caching plugins you need to search documentation, on how to add variable for "qtrans_front_language" cookie, so plugin could serve different caches based on "qtrans_front_language" value.

Komarovski commented 7 months ago

One more thing, if you will use this php function to implement language switcher in your theme: the_widget('qTranslateXWidget', array('widget-css-off'=>true, 'hide-title'=>true, 'type'=>'text'));

Everything's gonna work fine, but in this case the switcher will have links for default language with lang prefix, even if you checked "hide_default_language" as "true".

Pbalazs89 commented 7 months ago

Hi there, no caching on the server, here's the htaccess attached

php_value max_execution_time 300 php_value max_input_vars 10000

#RewriteEngine On #RewriteCond %{REMOTE_ADDR} !^80\.98\.193\.65 #RewriteCond %{REMOTE_ADDR} !^80\.99\.46\.218 #RewriteCond %{REQUEST_URI} !^/karbantartas.html$ #RewriteRule ^(.*)$ https://solinfo.hu/karbantartas.html [L]

RewriteEngine On RedirectMatch 301 /en/garazsvasar /hu/garazsvasar/ RewriteCond %{HTTP_HOST} ^shop.solinfo.hu$ [OR] RewriteCond %{HTTP_HOST} ^www.shop.solinfo.hu$ RewriteRule ^/?$ "https://solinfo.hu/uzleteink/solinfo-shop/" [R=301,L]

RewriteBase / RewriteRule ^index.php$ - [L]

add a trailing slash to /wp-admin

RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^(wp-(content|admin|includes).) $1 [L] RewriteRule ^(..php)$ $1 [L] RewriteRule . index.php [L]

This works: the_widget('qTranslateXWidget', array('widget-css-off'=>true, 'hide-title'=>true, 'type'=>'text'));

However, I can't format this as you said. Any ideas aside from caching perhaps?