Resolved

Reported for: WPML Multilingual CMS 3.3.6

Symptoms

When setting the admin language to a non-active language, WPML String Translation may throw a fatal error.

Example:

  1. Activate WPML with only “English” as default language, and “Italian” other language
  2. In WPML->Languages select French as default admin language
  3. You get either a white page or a message showing the fatal error

Workaround

The next version of String Translation will contain the fix to this issue.

Meanwhile, you can follow the following steps to fix it in your installation.

Before doing that, make sure to make a copy of the edited file before editing it, and a backup of your site.

  • Open this file: wpml-string-translation/inc/wpml-string-translation.class.php
  • Look for the line which contains function init_active_languages() { .
  • Change the whole function from this:
    function init_active_languages() {
       global $sitepress;
       $this->active_languages = array_keys( $sitepress->get_active_languages() );
    }
  • To that:
    function init_active_languages() {
       $this->active_languages = array_keys( $this->sitepress->get_languages() );
    }
  • Save the file

12 Responses to “Fatal error when changing the default admin language to a non installed language”

    • Peter, I see the forum thread is still active and that Dat is assigned to it.
      Please let’s keep the conversation there, to not mix information.

    • Could you post about this in our support forum? Our supporters will need debug information to see what’s wrong and help you with it.

  1. Hi, I have the same problem.
    For me, after installation in production only, it is always the same issue but on line 59.
    The problem is about $lang_of_domain.
    Can’t we write this variable value instead of the function?
    I’ve tried this:
    if ( $source_lang == ” ) {
    //$lang_of_domain = new WPML_Language_Of_Domain( $this->sitepress );
    //$domain_lang = $lang_of_domain->get_language( $domain );
    //$source_lang = $domain_lang ? $domain_lang
    //: ( strpos( $domain, ‘admin_texts_’ ) === 0
    // || $name === ‘Tagline’ || $name === ‘Blog Title’
    //? $this->sitepress->get_user_admin_language( get_current_user_id() ) : ‘en’ );
    //$source_lang = $source_lang ? $source_lang : ‘en’;
    $source_lang = ‘en’;
    }
    Plugins page works again, WPML works again but String translation still not working.
    Is there a way to fix this ?

    Best regards

    • Hello Cedric,

      Could you please post the issue in the support forum?

      There you will get faster and better support we can’t provide through the comments.

      Thanks.

  2. I have same issue with (wpml-string-translation.2.3.6.1)
    So, i install the old one ( wpml-string-translation.2.0.14) which i keep in my files. and it works fine ( even i get RED warning-request for update, but will wait till you fix this new v.)