Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
In WPBakery Page Builder (Visual Composer) translated grid are not being used.

Solution:
We have analyzed the issue and waiting for the author to include our fix new version.
Meanwhile please follow this workaround:-

#1 Create a complete backup of site files and DB (Just a good practice)

#2 You have to go to the folder for the visual composer grid items in
wp-content/plugins/js_composer/include/params/vc_grid_item/

There you open the file "class-vc-grid-item.php" and on Line 176 onwards you will see this function:

public function setTemplateById( $id ) {
       require_once vc_path_dir( 'PARAMS_DIR', 'vc_grid_item/templates.php' );
       if ( 0 === strlen( $id ) ) {
           return false;
       }
       if ( preg_match( '/^\d+$/', $id ) ) {
           $post = get_post( (int) $id );
           $post && $this->setTemplate( $post->post_content, $post->ID );
 
           return true;
       } elseif ( false !== ( $predefined_template = $this->predefinedTemplate( $id ) ) ) {
           $this->setTemplate( $predefined_template['template'], $id );
 
           return true;
       }
 
       return false;
   }

#3 Once you have found this, there is one line that needs to be changed. In our version it was line 182:
You have to replace the existing:

$post = get_post( (int) $id );

with this:

$post = get_post( (int) apply_filters( 'wpml_object_id', $id, 'vc_grid_item', true ) );

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 33 replies, has 3 voices.

Last updated by andreyO 2 years, 4 months ago.

Assigned support staff: Sumit.

Author Posts
March 19, 2018 at 8:23 am #1549230

andreyO

I'm using WPBackery page builder for my site.
On some pages I use Post Grid with particular Item-Template, which I created with Grid Builder.

I translated Grid Builder into some languages (e.g. more button from German to English), but I still have in English version german words on the main page hidden link. But it work fine on hidden link

March 20, 2018 at 6:35 pm #1551441

Cristina

Hello Andrey,

thanks for contacting and sorry for the delays.

If you are using a custom made Template you may have to register the "read more" or "mehr lesen" String also for that template separately.

You can try this to find and register the correct string:

Rename the string to something that you can recognize and distinguish from the rest of "mehr" Strings (using instead "weiter") and save this . This will be just temporary.

Then search in String Translation for this string you just renamed.

If you find it please translate it just there and save. Now check in an updated page if the string shows correctly.

If you don't find it there please go to the bottom of that page and follow the link "translate admin strings". You will get to a page with the administrative strings for the site, where you can search for your text. If you find it there you can add it to String Translation.

If it does appear correctly you can rename the "weiter" again to "mehr" and look this up to save the translation to that too.

If the string is translated but does not show online, you have to register that field in the language configuration file.

For this you first need to look up the name of the text-domain and the field that contains the "read more" tag in String Translation and then configure the shortcode for that.

An example would be this model:

<wpml-config>
    <shortcodes>
        <shortcode>
            <tag>the name of the shortcode</tag>
            <attributes>
                <attribute>what appears as field name</attribute>
            </attributes>
        </shortcode>
</wpml-config>

Then you can paste that in the XML Configuration Tab of WPML > Translation Management oder add the content of the shortcode to the language configuration file wpml-config.xml that is located in your theme folder.

Here is some documentation that might be useful for you:
https://wpml.org/documentation/translating-your-contents/page-builders/
https://wpml.org/documentation/support/wpml-integration-with-page-builders-that-use-shortcodes/
https://wpml.org/documentation/support/language-configuration-files/

If you want me to have a look at the site, I can also enable the private reply box for your next response. You can paste access credentials for a temporary admin in the private fields.

Kind regards,
Cristina

March 20, 2018 at 10:45 pm #1551623

andreyO

Hello Christina,

I've created a new page with postgrid, which uses newly created template. Template can be translated directly in Grid Builder Interface and if I search for strings I find those (button) text, which seems to be already translated.

Anyway, the translated page still doesn't use correct translation.

BR,
Andrey

March 21, 2018 at 9:09 am #1551910

Cristina

Hello Andrey,

if the button as such is ok, maybe that is a temporary issue for that specific page.

Could you update and save the original page and do the same with the translations, clearing all cache including the minified stylesheets and scripts for these pages?

Maybe that was just stored in a cache.
If that does not help you could redo he grid part for that page to see if the correct button strings are then used.

If that still does not help please look at the homepage settings. If the homepage is built with some customizer or theme options page that can be defined separately for each language this may be the way to handle that page.

In case this does not help I can have a look at it, if you want. I enable the private reply box for that.

Kind regards,
Cristina

March 21, 2018 at 9:17 am #1551921

andreyO

Hello Cristina,

I created completely new pages abd completely new grid templates.
So this is not an issue with cache.

BR,
Andrey

March 21, 2018 at 12:07 pm #1552103

Cristina

Hello Andrey,

if this works in one page but not in the homepage, there must be a difference between those two pages or the elements used there, otherwise it would react the same way.

If that difference is not a cache issue on the homepage because you have updated the homepage and the translated page, after changing or translating the grid template button, it must be something affecting only that page's module.

I just checked on a test page with the composer grid modules and the only thing that I can think of now that could be happening for that page is that you did not set the translated grid version when selecting the Grid element template in the Item Design option of that translated page.

If the Grids are translated you have to choose the translated template to show.

If the Grids are not translated the strings can be translated in String Translation but they may not show in the frontend then. As your grid is showing correctly in another page the most probably problem is that you have to set the translated grid for the translated homepage.

Could you check that please?

If that is set correctly, I would need more information to see if there could be any bug or if that is a specific problem of your homepage settings.

Kind regards,
Cristina

March 21, 2018 at 12:28 pm #1552125

andreyO

Hello Cristina,

the difference is, that page, where it works, was translated directly, without using translation manager (there I could select translated template for item design).

On all other pages, which are translated with translation manager it doesn't work. Here I don't have the possibility to choose another template, but I suppose it's not required, since WPML should choose translated template automatically, shouldn't it?

BR,
Andrey

March 21, 2018 at 1:04 pm #1552186

Cristina

Hello Andrey,

thanks for explaining this, now it is clear.

The Translation Editor does not use the translated version of the custom grid template.

So it used the template that is used in the original language, because it assumes that the templates are the same for each language. That is usually the case for most site, so it is defined that way.

So you have to change this manually.

The translation management has an option to "not sync the page templates", but this would lead to a not very user friendly text field in the Translation Editor, where you would see the html code for the post grid and would have to add the desired module id manually.

The most comfortable option to set the correct template is this:

- Save the translated page 100% in the translation editor to ensure you have all texts there.
- Then from the original page change the language in the top admin bar, so you get the manual mode to edit the post grid. You will get a warning that you are changing the mode, so you can click on "edit anyway".
- Select the correct translated grid template and save the module.
- Now update the translation. You can change to the translation editor window following the warning and save the page there. As you already changed the template that is save also.

After that you may be redirected to the translation dashboard again, but the page is saved with the correct translated grid. So this works, though it takes a few more clicks, but the module will show the correct button texts.

Kind regards,
Cristina

March 21, 2018 at 1:31 pm #1552221

andreyO

What is the purpose of Template translation?
I can create templates for each language also without it.

Anyway, if I update page in origianal language (lets assume on the homepage there is a new text), and then send it to translator, which has only access to translation management interface, all my previous changes regarding setting translated template will be gone.

As far as I understood mixing two methods of translation can lead to unexpected results.

BR,
Andrey

March 21, 2018 at 2:13 pm #1552280

Cristina

Hello Andrey,

the template translation is a commodity, as you can reuse an existing template and just change the element you need. But in this case you could also use two different templates as well, and it would not make any difference.

In general, what you save in the translation editor is saved to the WPML tables and to the WordPress tables. But what you save in the manual translation mode is only saved to the WordPress tables.

So if you save a translation and it is stored correctly, when you update manually the original page and then change to the translation editor, the editor will show the new field to insert a translation, but it will use the template of the original page.

In your case it would be better to use the manual translation mode to prevent overwriting the chosen templates after each update.

As that will probably happen when you update the original page and then try to update the translation.

This is a specific usage for this site, so here the manual translation mode will be better for you.

Kind regards,
Cristina

March 21, 2018 at 2:40 pm #1552321

andreyO

The problem is, that translators are using Translation Editor mode.
We disabled manual mode for them, in order they are not able to change layout and other stuff.

And generally, it's highly uncomfortable to use two modes, when you have to maintain so many languages as in our case.

The main frustration is, that I have chosen WPML and paid money for that, because there is a "Tranlation Management" feature.

And now already for the third time I'm offered to use Manual Mode (this case, the case with post grid+IDs as source, case with contact form).

With your proposal I have to maintain always growing list of "exceptions", which is pretty uncomfortable.

BR,
Andrey

March 21, 2018 at 7:17 pm #1552905

Cristina

Hallo Andrey,

I see that you have already opened a bunch of tickets with different issues, so there seem to be several compatibility issues here with the Translation Editor.

I understand your position as this is not a desirable situation.

As the custom grid template element does not seem to work with the Translation Editor, I could escalate this to the second level support or the compatibility team so check if there is a way to work together with the plugin author to make this compatible.

The problem with this is that if the underlying problem is more complex than it seems at first sight it can take a bit to solve. This means that the time required to make this feature compatible with WPML depends on the availability and willingness of the authors to work with our team.

I only explain this so that you can plan accordingly.

Would that be ok for you?

Kind regards,
Cristina

March 23, 2018 at 9:50 am #1554792

andreyO

Hello Christina,

it seems I don't have currently another option.
Thank you anyway for your support.

BR,
Andrey

March 29, 2018 at 11:20 am #1559965

Cristina

Hello Andrey,

I am keeping this open, as this is escalated. As soon as I get any feedback I will update you on that.

Kind regards,
Cristina

April 10, 2018 at 3:22 pm #1583633

Cristina

Hello Andrey,

the devs have found a workaround for this that lets the Translation Editor make use of a custom grid item, if it is translated.

For this to work, you would need to change a line in the code of a file inside the Visual Composer plugin:

You have to go to the folder for the visual composer grid items in
wp-content/plugins/js_composer/include/params/vc_grid_item/

There you open the file "class-vc-grid-item.php" and on Line 176 onwards you will see this function:

 public function setTemplateById( $id ) {
        require_once vc_path_dir( 'PARAMS_DIR', 'vc_grid_item/templates.php' );
        if ( 0 === strlen( $id ) ) {
            return false;
        }
        if ( preg_match( '/^\d+$/', $id ) ) {
            $post = get_post( (int) $id );
            $post && $this->setTemplate( $post->post_content, $post->ID );

            return true;
        } elseif ( false !== ( $predefined_template = $this->predefinedTemplate( $id ) ) ) {
            $this->setTemplate( $predefined_template['template'], $id );

            return true;
        }

        return false;
    }

Once you have found this, there is one line that needs to be changed. In our version it was line 182:

You have to replace the existing:

$post = get_post( (int) $id );

with this:

$post = get_post( (int) apply_filters( 'wpml_object_id', $id, 'vc_grid_item', true ) );

This change will let the Translation Editor find the translated ID of the custom item.
For this to work, the custom item has to be translated first.

Could you check if that also works on your site and lets you use the custom grid items with the Translation Editor?

We are already updating the plugin author with this findings, so he can include that in a future version or take the idea to include this option.

Kind regards,
Cristina