Skip Navigation

Resolved

Resolved in: 4.5.0

Overview of the issue

Houzez Theme uses its own custom function to call its theme options. If your site’s default language is not English, this function will conflict with WPML. The result is that translations will not be displayed in the front-end and they will be reverted to the default language in the admin.

Workaround

Before proceeding make a full backup of your site.

  1. Open /wpml-string-translation/inc/admin-texts/wpml-admin-texts.class.php.
  2. Look for line 198.
  3. Replace:
    	function icl_st_set_admin_options_filters() {
    		$option_names = $this->getOptionNames();
    
    		foreach ( $option_names as $option_key => $option ) {
    			if ( $this->is_blacklisted( $option_key ) ) {
    				unset( $option_names[ $option_key ] );
    				update_option( '_icl_admin_option_names', $option_names );
    			} elseif ( $option_key != 'theme' && $option_key != 'plugin' ) { // theme and plugin are an obsolete format before 3.2
    				add_filter( 'option_' . $option_key, array( $this, 'icl_st_translate_admin_string' ) );
    				add_action( 'update_option_' . $option_key, array( $this, 'on_update_original_value' ), 10, 3 );
    			}
    		}
    	}
    
  4. With:
    	function icl_st_set_admin_options_filters() {
    		$option_names = $this->getOptionNames();
    
    		$isAdmin = is_admin() && ! wpml_is_ajax();
    
    		foreach ( $option_names as $option_key => $option ) {
    			if ( $this->is_blacklisted( $option_key ) ) {
    				unset( $option_names[ $option_key ] );
    				update_option( '_icl_admin_option_names', $option_names );
    			} elseif ( $option_key != 'theme' && $option_key != 'plugin' ) { // theme and plugin are an obsolete format before 3.2
    				/**
    				 * We don't want to translate admin strings in admin panel because it causes a lot of confusion
    				 * when a value is displayed inside the form input.
    				 **/
    				if ( ! $isAdmin ) {
    					add_filter( 'option_' . $option_key, array( $this, 'icl_st_translate_admin_string' ) );
    				}
    				add_action( 'update_option_' . $option_key, array( $this, 'on_update_original_value' ), 10, 3 );
    			}
    		}
    	}
    

Next steps to resolve this issue

This issue will be resolved upon the release of WPML 4.5 (end of September 2021).

8 Respostas para “Houzez Theme - Translations revert when the default language is not English”

  1. I have this exact issue, but when I replace the code the site just crashes. Also, I have this line of code on line 203 and is this one:

    function icl_st_set_admin_options_filters() {
    $option_names = $this->getOptionNames();

    foreach ( $option_names as $option_key => $option ) {
    if ( $this->is_blacklisted( $option_key ) ) {
    unset( $option_names[ $option_key ] );
    update_option( ‘_icl_admin_option_names’, $option_names );
    } elseif ( $option_key != ‘theme’ && $option_key != ‘plugin’ ) { // theme and plugin are an obsolete format before 3.2
    add_filter( ‘option_’ . $option_key, array( $this, ‘icl_st_translate_admin_string’ ) );
    add_action( ‘update_option_’ . $option_key, array( $this, ‘on_update_original_value’ ), 10, 3 );
    }
    }
    }

    • Hello Sergi,
      This code should be applied on the line 198, so it’s probable that you are using a different theme version. Could you please upgrade to its latest version and try again?
      If that does not work, please open a ticket in our support forum where we will have the tools to help you better.
      Regards

      • Hello Andrés,

        Sergim is right, the code being written is on line 198. And it crashes because it has obviously deleted the last } of the original code, if it adds a third } at the end of the code you say will make replacements it will no longer crashes . Also, the problem is not solved, I do not understand how you say that it is solved while it is not solved. I have the 2.3.8 of the theme

        • Thank you very much for your insights. We are sorry for the misunderstanding but have not mentioned that this issue has been solved.
          However, we have modified both snippets in order to make it more readable, I hope it helps.
          We will update here once have any news.

              • Hi,

                I want to create a bilingual page so that the main language is Croatian and the secondary English.
                I use the latest Version 2.5.2 themes Houzez and WordPress
                Version 5.9.3. I checked for that code in /wpml-string-translation/inc/admin-texts/wpml-admin-texts.class.php.
                That code is built in, but it doesn’t solve the problem.

                Strings in general options do not show in the secondary (EN) language (Common, Searches, Grid, List, Card & Preview, Property Detail Page, Add New Property
                Buttons and links, Dashboard Menu, Email Management). I translated those strings into WPML String translation from Croatian to English and it worked with a few words, and later the English translation was lost. I have reset the theme 2 times already and all plugins (reset according to instructions by Darrel Wilson).
                Also, I don’t understand how to translate strings from CRM Settings and Inquiry form.

                Now, I have the impression that WPML can only translate Houzez into one language (to be the default language, not English).

                I would like to get an honest answer not to waste time.

                I see that user @alxV has been waiting for a year and I don’t know that he solved the problem according to the instructions from Diego Pereira. https://wpml.org/forums/topic/rehouzez-theme-translation-option-issue/
                I’m interested in whether you tested the method with deleting strings.
                Please feedback and if you can help.

                Kind Regards

                • Hello there,
                  Yes, this fix was released with WPML 4.5.0 and it should be solved now. Regarding the ticket you mentioned, the user never replied so it was closed automatically for the system. However deleting the strings should have helped in that case.
                  If you are experiencing any issue, please open a ticket in our support forum, where we have the right tools to help you.
                  Regards