This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 11 replies, has 2 voices.

Last updated by Andreas W. 5 months ago.

Assigned support staff: Andreas W..

Author Posts
March 15, 2019 at 1:55 pm

jeffreyS-12

I am trying to: Allow admin to permanent select content language they are editing

Link to a page where the issue can be seen: dev-air-bart-test.pantheonsite.io

I expected to see:
As and admin if i switch from English to Spanish from top admin bar in admin area i want to see content in Spanish language
As and admin i want to se content in selected language as long as i do not switch it to another one. For example: if i go to Posts, switch from English to Spanish and then go to Pages i still want to have Spanish selected.

Instead, I got:
As and admin when im using admin panel, each click on admin menu on the left, switch content language back to default.

Additional information:
WP version: 5.1.1
WPML Multilingual CMS: 4.2.4.1

Clean WP installation, no additional plugins, default Twenty Nineteen theme.

Message:
Hi!
Im using WPML Multilingual CMS on my production site (registered WPML version). Unfortunately i noticed the bug described above. To be sure that this is not an issue caused by other plugins, theme or anything else i have crated new, clean WP instance with WPML only (link to this test, clean instal above).

I noticed that after language switch, the admin menu links do not have '?lang' param. So if im on 'wp-admin/edit.php?lang=es' page (Posts) and then click on Pages, the '?lang' param is missing.

Unfortunately this forces admins and editors to constantly switch content language when they are using WP admin panel which is very inconvenient.

March 16, 2019 at 3:19 am #3358435

Andreas W.
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

Thank you for contacting WPML Support.

You are able to set the admin language for each user individually and declare the admin language as editing language inside of the user profile.
(See screenshot)

Usually, this setting on the screenshot should exactly fulfill your request. Leave the language on default and mark the checkbox for set admin language as editing language.

Let me know if this solved the issue.

Kind regards
Andreas

March 19, 2019 at 8:29 am #3376345

jeffreyS-12

Hello,
Thank you for your response, unfortunately it is not resolving described issue.
WP admin area strings are indeed translated to selected language, but it still fall back to default language when you click around admin panel. Please try to log in to test env that i provided.

Here are steps to reproduce:
- log in as admin
- default language is set to Soanish (this is correct)
- from menu on the left go to Posts ( Entradas )
- all visible posts are in spanish language (this is correct)
- use language switcher on top bar and switch to English
- all visible posts are now in english language (this is correct)
- from menu on the left go to Pages
- all pages are now in SPANISH language, content language fall back to its default instead of stay in english as i selected before

March 19, 2019 at 6:06 pm #3382331

Andreas W.
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

Sorry for the misunderstanding. The option Set admin language as editing language. has to be unmarked.

Please take a look at this test site with a new installation of WordPress 5.1.1 und WPML 4.2.4.1.

hidden link

I am not able to experience this issue on a new installation.

I am not able to say why it is not working as expected on your install. Did you apply any custom coding to the template or on WordPress Core?

Kind regards
Andreas

March 20, 2019 at 11:37 am #3388017

jeffreyS-12

Hello,

No custom coding on test env that i provided.
Its clean WP install with WPML only, and default Twenty Nineteen theme.
Even WP and WPML versions are exactly the same as on sandbox that you provided.

March 20, 2019 at 2:18 pm #3389015

Andreas W.
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

Please enable the WP Debug feature and provide me the results of the debug.log file.

Detailed information about how to activate WP Debug and how to obtain the debug.log you will find here:
https://wpml.org/documentation/support/debugging-wpml/

Kind regards
Andreas

March 21, 2019 at 1:53 pm #3405991

jeffreyS-12

Hello,

I just identified the issue. It's hosting settings, Pantheon use Varnish for cache. Following this: hidden link cookies used by WPML will never be read. They need 'wp-' prefix in name to be able to work.

I modified WPML core WPML_Backend_Request::get_cookie_name and everything starts working fine.

However, changing WPML core files is not the best idea. Is there any chance that you will consider changing cookie name in next versions of WPML or provide a hook that will allow developers to change cookie name in cases like that?

March 21, 2019 at 2:21 pm #3407115

jeffreyS-12

Just created working workaround for this issue, for anyone with similar issue. However still, please consider my request above.

class WpmlCookieHack extends \WPML_Backend_Request {

    private $cookie_prefix = 'wp-';
    private $hack_cookie_name   = null;
    private $wpml_cookie_name   = null;

    public function __construct() {
        $this->hack_cookie_name = $this->get_hack_cookie_name();
        $this->wpml_cookie_name = $this->get_cookie_name();
        add_action( 'init', array( $this, 'set_wpml_lang_cookie') );
        add_action( 'wpml_language_cookie_added', array( $this, 'set_hack_lang_cookie' ), 10, 1 );
    }

    public function set_wpml_lang_cookie() {
        $hack_cookie_value = $this->get_custom_lang_cookie();

        if ( ! $hack_cookie_value ) {
            return;
        }

        $_COOKIE[ $this->wpml_cookie_name ] = $hack_cookie_value;
    }

    public function set_hack_lang_cookie( $lang ) {
        $_COOKIE[ $this->hack_cookie_name ] = $lang;
        setcookie( $this->hack_cookie_name, $lang, 0, '/' );
    }

    public function get_custom_lang_cookie() {
        return (
            isset( $_COOKIE[ $this->hack_cookie_name ] ) && 
            ! empty( $_COOKIE[ $this->hack_cookie_name ] ) 
        ) ? $_COOKIE[ $this->hack_cookie_name ] : null;
    }
    
    public function get_hack_cookie_name() {
        return $this->cookie_prefix . $this->get_cookie_name();
    }
    
}
March 21, 2019 at 3:03 pm #3408967

Andreas W.
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

Thank you for your message.

For now I would advise you to disable the server side caching.

I have contacted our second tier about this issue and I will contact you as soon I receive feedback.

Kind regards
Andreas

March 21, 2019 at 3:31 pm #3409999

jeffreyS-12

Unfortunately disabling cache is not an option here.

Anyway, thank you for your assist, and im waiting for feedback.

March 22, 2019 at 10:03 pm #3444355

Andreas W.
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

I have taken a Duplicator Package from your site and I am looking for a way to recreate the issue and I am waiting for a response from our second tier.

I will contact you on Monday as soon I received feedback.

Kind regards
Andreas

May 14, 2019 at 11:05 pm #3811017

Andreas W.
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

Thank you for your patience.

I have consulted our second tier support and sadly until now WPML does not offer any filter for renaming filters but we would kindly like to invite you to submit your feature request here:

https://wpml.org/suggest-a-new-feature-for-wpml/

Thank you!

Kind regards
Andreas