TranslatePress can't translate URL of links

Hi,

I am using TranslatePress to translate a website we are developing. It sees everything correct except for URL’s in links.

I tried everything and can’t figure out what to do or what’s going on.

I also send a ticket to TranslatePress but thought i will also ask here since somebody might had the same issue with Pinegrow.

This is the video i send to TranslatePress to explain. It’s about 3min :wink:

Thanks
Guido

Guido,

Edit:
I might be mistaken here… I just made the link in my footer an ACF field and TranslatePress still is not letting me translate it. This leads me to believe that TranslatePress may have an issue. (I haven’t tested other translation plugins)

Original:
I suspect part of the issue might be that you are hardcoding the links into the PHP template files. If I’m not mistaken, TranslatePress can only translate links that are managed by the WordPress CMS. From the little bit I can see in your video, the template you made seems to be crafted more like a static web page that is being displayed with WordPress than a WordPress template that is using the CMS.

Here is a link that was created in the Gutenberg editor and is fully translatable:

And here is one that I hardcoded into the PHP file:

1 Like

Hi @adamslowe

Thanks for your reply. Yes i tried Gutenberg also and those links are fine. But hardcoded links in the php template files doesn’t work. The hardcoded images in the php template files work just fine. So it seems that TranslatePress has a bug. It seems to handle link tags as Gettext. In the settings of TranslatePress you can exclude Gettext strings.

If you put the text of the links in there then it works in TranslatePress. Found this workaround later. Still no answer from them. But pretty sure it is a mistake from their side. I see no reason to handle links as Gettext.

@Guido Thanks for the follow-up! It sucks that TranslatePress is behaving that way, especially since it’s my go-to translation plugin. Hopefully, they get it fixed sooner than later.

1 Like

@adamslowe

Yes i hope so too! Will send an update as soon as i hear from them. :wink:

1 Like

Hi @adamslowe

So i am not getting far with TranslatePress… Not super impressed with their support…

This is on of the most recent replies from them:
"That’s correct, it’s not detectable to be translated in the way you specified.

In your case, the content is an article uploaded as an attachment and it’s not detectable. If it was written on a page that could be translated, then its URL would have been translated automatically.

To make this work, you need to change the URL directly from your code, based on the currently displayed language. On this page you’ll find the conditional language shortcode: Conditional Shortcode Based on Language - TranslatePress but on the same page there is also a snippet that shows you how to get the current language in PHP. Try to use that and provide the correct link based on the current language."

I think i was pretty clear in my video on how it is set-up. I even explained in detail what i created and what the problem is. But this is the answer i got…

I explained it again and told them you’re example of the footer link also. And that everything else is translatable just fine. It only seems to be links where we need to change the URL. Like links to PDF’s and other docs or links to external websites.

I don’t see any other way on how i can set it up differently? And me or you with the footer link are not doing anything unique right? Seems to be just standard WordPress PHP files.

Anyway just thought i would lt you know and maybe you have another idea on how to tackle this.

Thanks
Guido

Hi @adamslowe

Latest reply from TranslatePress:
"Hello,

This is how it works at the moment, this link falls in the internal link category that we should automatically translate, but since it’s an attachment we are not able to do that.

You should be able to solve your issue using the indicated code snippet."

So adding the text to exclude gettext in the settings will work or using the shortcode/code snippet.

Guido

Not an ideal solution, but at least it’s something. At the end of the day, though, hard coding links into the theme files probably isn’t a great practice. Maybe consider using ACF fields on the relevant pages to store the URLs and retrieve them from the theme template?

1 Like

Yes that’s true. And yes will try not to hardcode links in theme files. Will use ACF or Metabox. Thanks for the link :+1:

1 Like