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.

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

Tagged: 

This topic contains 5 replies, has 2 voices.

Last updated by Bruno 1 day, 17 hours ago.

Assigned support staff: Bruno.

Author Posts
March 18, 2020 at 12:04 pm #5710327

nicolasL-12

I'm developing dynamics ( eg virtual ) multilingual pages using the following code

add_rewrite_rule(
'^motor-(?:ö|o)l-analyse(?:/([^/]+))?(?:/([^/]+))?/?','index.php?virtual=analyse&mylang=de&oil_analysis=$matches[1]&analysis_detail=$matches[2]', 
'top' );

After "catching" those urls, I'm calling a specific template

Can't find which API Hooks to use to tell WPML in which languages such pages exists - I want the WPML language switcher to be shown as usual on the website menu for all the available languages this specific virtual page is translated to
Hence I want the reverse of the "wpml_active_languages" hook to SET these languages

Or is it any other way to do it ?

two examples url :
hidden link
hidden link

March 18, 2020 at 6:53 pm #5713723

Bruno
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Thank you for contacting us. I would be very happy to help you but I didn't fully understand what is the issue.

Do you want to know what languages a page exists in? If so, you are right using the "wpml_active_languages" hook. This is the correct way to know if a page is translated into secondary languages.

If this is not what you are asking, can you please elaborate a little more so I can better understand?

Thank you.

March 19, 2020 at 2:08 pm #5720673

nicolasL-12

Hello Bruno,

When dealing with regular Posts / Pages / Media etc…, I've the choice to translate them and hence WPML knows which translations is available or not. Hence when on such page :
hidden link
the wpm menu switcher is shown and one get go the the translated pages :
hidden link
hidden link
etc…

however in the above case ( original post ), if the template is a wordpress one, all dynamical content ( eg translations ) come from another system and WPML is unaware of anything => I wan't to "prime" WPML in letting it know on any such "virtual pages", which translations are available and what are the associated URLs

Thus what I'm looking for is pretty much a hook like "wpml_active_languages" but to set it ( or wpml_browser_redirect_language_params… but not triggered on browser redirect but before menu switcher display )

hope it's clearer

thanks

March 24, 2020 at 8:26 pm #5754787

Bruno
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hi,

My sincere apologies for the delay. I think the best option, in this case, is, after knowing that the content is translated on the third-party service, to create and popularize the translation using these WPML hooks.

The problem is that, in any case, it would be necessary to add these other routes with the languages. Otherwise, page 404 will be displayed.

As I understand it, the translations are being returned from another URL, correct? If so, you can populate your WordPress using the "wp_insert_post" function (https://developer.wordpress.org/reference/functions/wp_insert_post/) and then the "wpml_set_element_language_details" hook (https://wpml.org/wpml-hook/wpml_set_element_language_details/) to make the connection between the original content and the translation.

Another solution, which I don't know if it should be useful in this case, is for you to use the "fallback" feature (https://wpml.org/documentation/translating-your-contents/displaying-untranslated-content-on-pages-in-secondary-languages/) so that the original content is displayed in all languages that are not translated. This way, the language selector should work as expected and you can try to change the content as desired.

Thank you.

March 26, 2020 at 7:30 pm #5773353

nicolasL-12

Ok thanks - i think the first solution should work if it doesn’t broke all the rewrite rules

March 26, 2020 at 8:05 pm #5773485

Bruno
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello,

Usually inserting this content and making the connection with the original content, this does not break the permalinks.

Please, let me know if I can help with any other questions you may have about it. I'll be happy to help.

Thank you.