Skip Navigation

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.

Tagged: 

This topic contains 9 replies, has 2 voices.

Last updated by Long Nguyen 1 year, 5 months ago.

Assisted by: Long Nguyen.

Author Posts
November 8, 2023 at 6:02 pm #14760083

Michael Briel

> Tell us what you are trying to do?

Short:

Use individual shortcodes and/or custom Gutenberg blocks depending on the selected language and hope there's another way besides using the WordPress-Editor or writing my own workaround

Long: Okay.

Hi! 🙂 I'm the webmaster/builder/admin of hidden link - a page constantly changing somehow. For several years the page ran on Polylang, but since more languages are about to be added the Executive decision was made to switch to WPML instead, because it's Advanced translation interface and similar features.

Aaaand now I'm the guy who has to make it all work. 😀 So right now I'm doing so on our Dev-Server.

Transferring the Contents from Polylang worked fine and I am quite happy with the plugin too. BUT...

The reason for my superiors to use WPML now instead of Polylang was, as I said, the Advanced Translation interface.

... which, I just learned, can't be used to give an individual shortcode for each language (for example for a text slider). Or for Custom Gutenberg Blocks that need translated tests too, of course. Or the plugin "SOGO Add Script Header Footer" that we Use to load individual CSS Files and .js files on each page... It seems that WPML ignores those all - even when I tell it to use a WPML duplicate of the page as translation.

Now - I have already googled around to see if, perhaps, I have missed some option, but it doesn't seem that way. Please tell me I'm wrong! 🙂

Also: I do have a few ideas for workarounds for pretty much all of the problems - and I believe they'll work... But they need additional work I hope to avoid:

1. The plugin for the header/footer script used for CSS and Java Files on each page can, I'm sure, be replaced with Advanced Custom Fields (also in use on the page) - I'd just need to slightly modify the page template files for that to work. If I understand right, then THOSE should then be manageable through WPML and also will be copied in a Duplicate of the page, correct? Which would mean I need to open every single page (including a whole bunch of custom post type stuff) and copy-paste the content from the plugin-fields to the ACF Fields instead.

2. It should be possible to modify the custom Gutenberg-Blocks to have each field in all languages and then output only the version with the selected language. That'll also require me then to manually adjust all the pages that have those in use...

3. The shortcode problem can be fixed in the same fashion using a new, custom, Gutenberg-Block that has all the different shortcodes and also only will output the correct one.

From what I've seen these workarounds sure SHOULD work. Whether the "Deciders" like the fact that I'll need a bunch more time to write them and implement the changes needed on each page or post I can't say now, I'll have to wait until tomorrow for that. Buuuut maybe a workaround isn't required, because I have missed something...

> Is there any documentation that you are following?

Oh, I HOPE there is one and I'm just not finding it! But it seems there isn't...

> Is there a similar example that we can see?

hidden link - Scroll to the bottom of the page, there's four pictures with Text and button. Each of them is a custom Gutenberg-Block, because they're used all over the place and with the custom block it's easier for the authors to set them up without my (admin) help. The block comes with fields for the image, text, Link URL, Link text, Button colour and height.

A whole bunch of other blocks like these is in use too... Then several pages have sliders, added with shortcode, that need to be different depending on language. And since basically every second page gets new elements by the designers that would create one HUGE Css file if I had them all in one file each page or sometimes group of pages has it's own css and sometimes Javascript files that also need to be handled.

> What is the link to your site?

See above. ^^

Let's see if you can help me. If not, then I'll have to see whether the Execs will sanction doing all the needed workaround work. If not then we'll probably have to stick with Polylang after all...

Kind regards - Michael Briel

November 9, 2023 at 3:28 am #14761965

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi Michel,

Thank you for contacting WPML support, I'd be happy to help you with this issue.

If you want to use the WPML Advanced Translation Editor, that means you should translate content on the page: texts, images, URLs ... and not the layout or HTML structure. WPML attempts to translate content on the page as much as possible. If you are using a custom block, you can follow the documentation below to register it for translation
https://wpml.org/documentation/support/language-configuration-files/#gutenberg-blocks
With the custom block from Lazy Blocks, it is compatible with WPML hidden link

If you want to have a different layout or different blocks on the translation page, you should use the WordPress editor. Please follow the documentation
https://wpml.org/documentation/translating-your-contents/using-different-translation-editors-for-different-pages/

For the CSS and JS code, you can create the code for a specific page and use the selector html[lang="de-DE"] to select the element in the second language.

Look forward to your reply.
Thanks

November 12, 2023 at 4:24 pm #14784341

Michael Briel

Hello again!

YOu are right - Lazy blocks actually have a Button for wpml translations now, I didn't see that before!

Buuuuuuut even so I still have problems with fields not turning up:

I have one block "landingpagesinfoblock" that has, amongst others, a field for a link, a text field for the link text and a wysiwyg field (running the classic editor) for the rest of the copy. Those three fields are set to be translateable, but in the advanced translator only the "button-text"-Field shows up, the URL Field and the WYSIWYG fields don't show.

(I haven't even started to check all the other Blocks in use - I hope that, when we get this one fixed I then can do the rest following the example).

I JUST have noticed: When I misstype the URL to say https//google.de (without the ":") then suddenly the field shows up for translation!

The WYSIWYG Field still keeps NoShow, though.

If you want I can give you access to the DEV page for you to have a look around?

November 13, 2023 at 4:18 am #14785285

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

By default, the URL is hidden in the Advanced Translation Editor (ATE). You can search for this with the keyword "http" (for example) and translate it. Please follow the documentation https://wpml.org/faq/how-to-translate-urls-shortcodes-and-html-attributes-using-the-advanced-translation-editor/

Regarding the WYSIWYG field, can you please help me to replicate the issue on a clean installation? It could be a compatibility issue when only this field value is not available in ATE. You can login directly to the admin area with this link
hidden link

Look forward to your reply.
Thanks

November 13, 2023 at 10:10 am #14787049

Michael Briel

Okay - I installed Lazy Blocks, did a basic WPML configuration and copied the Lazy Blocks from our page, so you indeed get 100% the same blocks.

And - indeed - the error also appears on the test page, as you can see. The Classic Editor WYSIWYG Field "Copy" isn't offered for translation. Actually now even the buttontext isn't in there - and I can't find the URL now searching for https (that worked before, when I tried).

Something is really effed up here, but it's good to see it's not because of all the other plugins on the page, apparently

November 14, 2023 at 1:45 am #14793119

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

When editing the Lazy Block, you can enable the option "WPML translation" for each block in the tab Content Controls. Then the field value is available in Advanced Translation Editor to translate. Please check screenshots below.

Look forward to your reply.
Thanks

Edit Post “LandingpageInfoblock” ‹ Sandbox — WordPress 2023-11-14 08-41-05.png
Advanced Translation Editor - WPML [Staging] 2023-11-14 08-40-47.png
November 14, 2023 at 9:44 am #14795913

Michael Briel

Hello there. Yes, I know this switch, it didn't work for the fields in that Lazy Block, just as you saw on the demo page.

But I found the apparent problem now on our DEV Server:

<p><?php echo $attributes['copy']; ?></p> <- That's how the field was output in the Block's template, and apparently WPML doesn't like html code with too many tags in it?

When I replaced the <p> with <span> instead it works. I'll now check all the other elements in use...

November 15, 2023 at 1:15 am #14803465

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

Maybe there is an issue with the output PHP code on your site. On the sandbox site, I see you use the <p> tag and it works properly.
Also, I'm focusing on the translatable of the field, not how it's displayed. If you see all fields are translatable and available in ATE, that means the issue is resolved.

Let me know if you have any questions.

November 15, 2023 at 9:46 am #14806773

Michael Briel

Well, it now works for that one block. And yes, this was all about the translatability of fields, not the way they're displayed.

I guess I won't bother you with the other problems I have with blocks then and think of something else. I mean... You asked me to replicate the problem, I did so and then next you tell me I have to activate the translation for fields... AFTER it should've been quite clear that this was about fields not showing up for translation even though that switch was flipped.

And yes, it works now with the P -tag on the sandbox, apparently, but looking at the Lazy Block you tried some weird stuff there with now two fields called "copy" - one WYSIWYG and one textfield. I tried that too on our DEV server and there it doesn't work.

But it's fine... I'm going to replace the blocks in question with pure html code now, that will make a whole lot more work for me, but at least it then will work.

Cheerio

November 16, 2023 at 1:13 am #14821443

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

I will mark this ticket as Resolved. Feel free to create a new ticket if you have any questions.

Thanks and have a good day.