WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#16459 closed defect (bug) (fixed)

get_post_format_link() and problem with translated post format slug

Reported by: pavelevap Owned by:
Milestone: 3.1 Priority: normal
Severity: normal Version: 3.1
Component: I18N Keywords:
Focuses: Cc:

Description

Hi, using latest WP trunk, Twenty Ten.

Post format slug "gallery" was translated to "galerie", but in Twenty Ten there is a following call (loop.php):

echo get_post_format_link( 'gallery' );

So, there are visible links to ?post_format=gallery (Nothing found) instead of translated ?post_format=galerie

Attachments (3)

16459.fix-link.diff (645 bytes) - added by markjaquith 3 years ago.
Fix for the faulty link with default permalinks
16459.no-translating-slugs.diff (1.8 KB) - added by markjaquith 3 years ago.
No translation for slugs at all
16459.no-translating-slugs.2.diff (2.2 KB) - added by markjaquith 3 years ago.
With some unused code removed.

Download all attachments as: .zip

Change History (21)

comment:1 ryan3 years ago

Post format slugs should never be translated.

comment:2 ryan3 years ago

Sorry, they should never be translated in the DB but I think we do perform translation for the sake of permalinks.

comment:3 pavelevap3 years ago

Yes, it makes sense to me to translate them to have permalinks with translated words galerie instead of gallery. But they are translated on the fly and not in database, I guess.

But the problem is in Twenty Ten or get_post_format_link() function which calls not translated post format slugs. Maybe it should be direct part of this function to call translated slug to be compatible with other themes (and not change it only in Twenty Ten).

comment:4 ryan3 years ago

Without pretty permalinks turned on, ?post_format=gallery is correct. The actual post format saved in the DB is never translated and post_format= is an explicit requests for what is in the DB. With pretty permalinks turned on, I believe you will see /type/galerie/ permalinks that will map to a post_format=gallery query.

comment:5 pavelevap3 years ago

But I have one post with "Galerie" format and for ?post_format=gallery there is "Nothing found" and for ?post_format=galerie is this post correctly listed. And problem is that get_post_format_link() generates wrong link to not translated ?post_format=gallery

comment:6 ryan3 years ago

post_format=galerie should never happen. That's a bug.

comment:7 ryan3 years ago

  • Milestone changed from Awaiting Review to 3.1

comment:8 pavelevap3 years ago

But it works well and I like it this way :-)

comment:9 nacin3 years ago

Can't reproduce get_post_format_link() getting 'galerie' versus 'gallery' with permalinks disabled. I'm probably doing something wrong.

Noticed some other issues with canonical which a patch will address soon. Will look again later tonight.

comment:10 markjaquith3 years ago

I can reproduce, using the latest French .mo file.

The link generated by Twenty Ten is:

http://wp.dev/?post_format=gallery

It 404s. But this works:

http://wp.dev/?post_format=galerie

The first problem is that WordPress is generating that link. The second is that it doesn't redirect to the correct link. I suppose it can't be avoided that if the translation changes, the links will break.

markjaquith3 years ago

Fix for the faulty link with default permalinks

comment:11 markjaquith3 years ago

There's a fix for the faulty link generation. It just wasn't being passed through the slug translator like the pretty permalink was.

comment:12 ryan3 years ago

post_format should always use the real slugs. Why do an on the fly translation for the slug and still have the english "post_format" in the URL? Formats are internal keys (like type, status, and ID) that should not be translated.

markjaquith3 years ago

No translation for slugs at all

comment:13 markjaquith3 years ago

There's a patch that removes translation altogether, for both default and pretty permalinks.

comment:14 follow-up: pavelevap3 years ago

So why are post format slugs enabled for translation?

comment:15 in reply to: ↑ 14 ryan3 years ago

Replying to pavelevap:

So why are post format slugs enabled for translation?

That was intended for the /type/format/ pretty permalinks, but I think we might remove translation there too since using translations for permalinks is fragile.

markjaquith3 years ago

With some unused code removed.

comment:16 markjaquith3 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [17391]) No translation for post format slugs. Too fragile for the future. fixes #16459 for trunk

comment:17 markjaquith3 years ago

(In [17394]) No translation for post format slugs. Too fragile for the future. fixes #16459 for 3.1 branch

comment:18 markjaquith3 years ago

(In [17403]) Do not use PHP5-only array_combine. props duck_. see #16459 for 3.1

Note: See TracTickets for help on using tickets.