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.

Our next available supporter will start replying to tickets in about 1.40 hours from now. Thank you for your understanding.

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

Problem:

Translating post_format slugs is not working.

Solution:

I've solved it by applying "wpml_permalink" filter on it.

Relevant Documentation:

https://wpml.org/wpml-hook/wpml_permalink/

This topic contains 8 replies, has 2 voices.

Last updated by Itamar 3 weeks, 3 days ago.

Assigned support staff: Itamar.

Author Posts
September 22, 2019 at 1:29 pm #4618679

denisi-3

Hi.

(Dean, web developer speaking) I'm translating the site from English (default) to Croatian. Permalink formatting is set to "Post name". Everything is going smoothly, except for this one thing: post_format slugs. They are not listed by string translation plugin, nor do they appear anywhere in the taxonomy translation section.
Don't get me wrong.. I've successfully translated all the custom post type names and slugs and all the custom taxonomies too. No problems with those whatsoever. This is NOT custom. This is WordPress-native stuff.

There is no mention of this in any posts on your forums nor anywhere in the documentation.

Here's a live example of archive page for this particular taxonomy on my site (English version):
hidden link

... and Croatian version:
hidden link

Notice that "type/gallery"? The "gallery" part is the actual slug that in apparently not translatable. And I think it should be, according to the WordPress documentation. I'm not sure about "type" part. I don't think it originates from the theme nor plugins, but I could be wrong.

Before you ask: No. The theme is not really WPML-friendly, but I've made it work pretty well so far, as you can see for yourselves. The site is still WIP, but it is 95% done.

P.S.
I've made a small plugin that works around that "category widget drop-down list not working with language being passed as a parameter" bug. If you want it, you can have it.

P.P.S.
This is not a big deal, but I would like to be able to translate those "type" and "[insert-post-format-slug]" slugs, just like I did with all the taxonomies.

September 22, 2019 at 11:24 pm #4619581

denisi-3

I've come across another problem related to this one.

WordPress seems to be oblivious of current language when it comes to getting the post_format term link via get_term_link. Using 'suppress_filters=>true' still produces link to default language variant.

September 23, 2019 at 8:45 am #4621743

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi.

You can set different slugs in different languages for CPT and custom taxonomies in WPML -> Settings. I'm not sure whether you have translated the slugs in this way. Please read our documentation about it here.
https://wpml.org/documentation/getting-started-guide/translating-page-slugs/
Is this the way that you have translated 'gallery'?

Also, please make sure that it is not a cache issue by clearing all the cache on your site.
I can also see that WPML's Translation Management add-on is not active on your site.
Does activating the Translation Management add-on solves this issue?

Cheers,
Itamar.

September 23, 2019 at 9:37 am #4621997

denisi-3

All the taxonomies (including slugs) are translated, CPT or otherwise (apart from post-format ones, obviously).

I've dug deeper into the issue at hand, and it appears that "type" slug base is native to WordPress (wp-includes/taxonomy.php, line 42):

$post_format_base = apply_filters( 'post_format_rewrite_base', 'type' );

and is not translatable "out-of-he-box". Neither are post-format slugs (wp-includes/post-format.php. line 95):

function get_post_format_strings() {
	$strings = array(
		'standard' => _x( 'Standard', 'Post format' ), // Special case. any value that evals to false will be considered standard
		'aside'    => _x( 'Aside', 'Post format' ),
		'chat'     => _x( 'Chat', 'Post format' ),
		'gallery'  => _x( 'Gallery', 'Post format' ),
		'link'     => _x( 'Link', 'Post format' ),
		'image'    => _x( 'Image', 'Post format' ),
		'quote'    => _x( 'Quote', 'Post format' ),
		'status'   => _x( 'Status', 'Post format' ),
		'video'    => _x( 'Video', 'Post format' ),
		'audio'    => _x( 'Audio', 'Post format' ),
	);
	return $strings;
}

As you can see, slugs are array keys and are not made translatable. I can work around it, but, if I understand the matter, it would involve hard-flushing rewrites on every page load, and that is not a good idea IMHO.

Regarding translation management add-on, I am the sole translator for this site, so I don't really see the need to install it. I will try it tho, just to see if it changes anything.

I guess that's that. The problem is, IMO, not with WPML, but with WordPress itself.

P.S.
I misspoke earlier about the plugin I wrote... it's not a plugin, but a widget, added via child theme, a modified )and slightly renamed) WordPress original categories widget, modified to work with your plugin as expected.

P.P.S.
For the record, the theme is dMedia by Designing Media team.

September 23, 2019 at 11:01 am #4622689

denisi-3

Update:
Translation management did not change anything regarding this.

September 23, 2019 at 3:52 pm #4625523

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi and thanks for the extra details.

I can confirm your finding. I've checked things on my test site and indeed 'type' and 'gallery' are reserved names in WordPress. Therefore it seems that you cannot use them as your own slugs. And this explains also why you cannot translate them.

Please let me know if you have any other questions regarding this issue.

Thanks,
Itamar.

September 23, 2019 at 5:23 pm #4625937

denisi-3

Just to round things up:
That "get_term_link" always returning default language link for post-format? I've solved it by applying "wpml_permalink" filter on it. Works like a charm.

September 23, 2019 at 5:25 pm #4625939

denisi-3

My issue is resolved now. Thank you!

September 24, 2019 at 11:59 am #4631393

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+03:00)

Great, I'm glad that it is solved now!
Good luck with your web projects 🙂
Itamar.