Please make sure to update to WPML to the latest and check our list of Known Issues before reporting

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

Last updated by goranF 4 years, 10 months ago.

Assigned support staff: George Botsev.

Author Posts
March 30, 2015 at 1:09 pm #590492

goranF

Hi,
Is there any way to get hard coded links, e.g. in the text on a product or a page (<a title="Contact" href="/?page_id=115" target="_blank">Contact us now</a>.) to direct to the language I use for the moment instead of the original language (115 is the id of the Swedish Contact page) without changing the url (e.g “11577&lang=en” for my English contact page) in the translation of that page?
I have translated the Swedish original pages/products into English and Spanish so far through xliff export/import and I haven’t “translated” the page id. To get it work I have modified the xliff by serch and replace in an editor before import, but I wonder is there a better way to do this in WPML?
I’m using theme Forte from Pixedelic to create my pages and woocommerce for my products.

March 31, 2015 at 5:57 pm #591644

Beda
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch ) Italian (Italiano )

Thank you for contacting us.

If you are hardcoding links in your theme and want WPML to return the proper language related objects or elements, you can use the WPML API:
https://wpml.org/documentation/support/wpml-coding-api/

This functions will be of interest for you in your case:

icl_link_to_element(ID, type, text, arguments, anchor)

https://wpml.org/documentation/support/creating-multilingual-wordpress-themes/hard-coded-theme-links/

icl_object_id(ID, type, return_original_if_missing, language_code)

https://wpml.org/documentation/support/creating-multilingual-wordpress-themes/language-dependent-ids/

If you are adding the links of translated elements in the Post/Page Editor, you might be interested in the AddOn WPML Sticky Links:
https://wpml.org/documentation/getting-started-guide/sticky-links/
It is "intelligent" enough to recognize if a certain element exists as translation and automatically adjust the links accordingly.

Please let me know if you need further help with this.

Thank you

April 1, 2015 at 11:35 am #592098

goranF

Sorry but I don´t see how to use this. I can't use your api functions in the page editor and I'm using Sticky Links plugin, I run the Search All in Sticky Links once more but things are still the same.
I attach a image from the page editor so you can see where I put my links. This is same on every product in WooCommerce.

April 1, 2015 at 3:23 pm #592278

Beda
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch ) Italian (Italiano )

Thanks for the Details

If you use a link to a page/post that already exists in your install, and it's translated, WPML Sticky Links will automatically lead/correct the URL according to your language you are viewing the Post/page with the link in it.

Please consult also the screenshot about it.

Please acknowledge that the related content (wehre the link points to) must be translated.

You will not need to run anything specific in WPML Sticky Links for this to work.
Once you activated and Run Sticky Links, this should work automatically.

On the other hand, in your case the WPML API won't help, because you are inserting the links in the post editor.
I apologize that I did not recognize you are using the Editor for this in the first instance.

Please don't hesitate to inform me in case the issue persist
In this case, could you please share your Debug Informations with me?
http://wpml.org/faq/provide-debug-information-faster-support/

Thank you

April 2, 2015 at 6:13 am #592563

goranF

Hi, sending you the debug information. This is from our test site but it is an exact copy of the live site.

Look at the page below and click on the Contact ... link. The Contact page are translated to english but I keep coming to the swedish translation.

hidden link

April 5, 2015 at 12:16 pm #593933

Beda
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch ) Italian (Italiano )

Thanks for the Details and for providing the Debug Informations

I would need to request temporary access (WP-Admin and FTP) to your site
- preferably to a test site where the problem has been replicated if possible -
in order to be of better help and check if some configurations might need to be changed

Your next answer will be private which means only you and I have access to it.

❌ Please backup your database and website ❌

✙ I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site.
This is also a reason the backup is really important

April 7, 2015 at 2:44 pm #595107

Beda
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch ) Italian (Italiano )

Thanks for the Details

I wasn't able to edit the translation of a test product I chose, due to that it' is already assigned to somebody else.

But I also think I must specify to clean out possible misunderstandings:

You must, of course, insert the contact link to both products (original and translation)
It is not enough if you just add it to the original, unless that is a Product that has been duplicated and is synced with the original, WPML can't know that you have added a link to the original product, and won't update your Translation accordingly

Since it seems you translate all your products, I think the fastest for you would be to manually (from available links) insert those links to your products.
(more correct, translate them in their translations)

Other wise you would need to overwrite all your current products, and I'm sure that is not what you want.

Please let me know if we are on the same page here.

Please also don't hesitate to inform me in case you want me to assist more on this topic.

Please let me know if you need further infos about this.

Thank you

April 8, 2015 at 7:05 am #595519

goranF

Could you please tell me if this is the way to do the translation or am I going to do something else?

I have done like this:
1. I started to create my products (and all pages) in Swedish and I put the link (hard coded) in Swedish to the Swedish contact page. (page id=115)
2. I exported my products with your xliff-export function. I translated my exported xliff-files to English and I let the link to the contact page still point at the id of the Swedish contact page (page id=115).
3. I imported the translated xliff-files. With this also the translation of the contact page in English, so now the English contact page exist (and it got the page id=3241).
4. Is this the way to do it? Should not WPML know that 115 is 3241 (with or without Sticky Links Plugin?) when I display my page in English? Or do I have to manually translate 115 to 3241 in every link in the product translations?

As far as I can see the products (the original and the translation) are synced to each other and there are links (whitch points to id=115) to the contact page in every translated product. (I have manually changed half of the translations to point to 3241, but I stoped becouse it did not feel the right way to do it, and I opend this topic).

I’m right now working with the Spanish translation so I need to know if I’m doing things correct, I have no problem to change all Spanish translated links (witch right now points at id=115) to the Spanish translation id (Spanish contact page id=11763) of the contact page before I import it but it does not feel like it would be the best way to do it.

April 8, 2015 at 2:55 pm #595903

Beda
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch ) Italian (Italiano )

Thanks for the Details

I have tested the Sticky Links Plugin extensively, and here are my findings:

1. If you insert a Link leading to a already existent and translated Page (or whatever other content) in the BODY editor of pages / posts / products, Sticky links correctly turns the Link into a Sticky link
(the link changes to a link with ID information)

2. This seems not to be so in the Short Description in the Product Editor
(the link keeps the page title and doesn't change to a ID)

3. Your approach is (one of the) correct possibility(ies)

4. Your approach worked for me in case of inks in the BODY editor, but since the link in the Short Description isn't turned to sticky, it won't work for links in the Short Description.

5. I hav escalated the issue to the 2nd Tier Support

They will be in contact with you in short here.

Please await our updates here in the forum.

For now, unfortunately it seems you should have to manually translate the Links.
I apologize any inconvenience that this may cause.

Thank you for your patience

April 20, 2015 at 2:15 pm #602573

George Botsev
Supporter

Languages: English (English )

Timezone: Europe/Sofia (GMT+02:00)

Hello, I am George from second tier support.
I have investigated the issue with sticky links that you have.
Unfortunately currently links are being converted to sticky links only in the post content or the content of widgets and other fields are not supported.
However I will escalate this to our Wishlist for future consideration from our developers and eventually if this is considered by them, possible to be implemented - they might implement it.

May 5, 2015 at 2:09 pm #612312

goranF

Not resolved, but you could not help me with this.