Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#16459 closed defect (bug) (fixed)

get_post_format_link() and problem with translated post format slug

Reported by: pavelevap's profile 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 14 years ago.
Fix for the faulty link with default permalinks
16459.no-translating-slugs.diff (1.8 KB) - added by markjaquith 14 years ago.
No translation for slugs at all
16459.no-translating-slugs.2.diff (2.2 KB) - added by markjaquith 14 years ago.
With some unused code removed.

Download all attachments as: .zip

Change History (21)

#1 @ryan
14 years ago

Post format slugs should never be translated.

#2 @ryan
14 years ago

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

#3 @pavelevap
14 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).

#4 @ryan
14 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.

#5 @pavelevap
14 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

#6 @ryan
14 years ago

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

#7 @ryan
14 years ago

  • Milestone changed from Awaiting Review to 3.1

#8 @pavelevap
14 years ago

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

#9 @nacin
14 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.

#10 @markjaquith
14 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.

@markjaquith
14 years ago

Fix for the faulty link with default permalinks

#11 @markjaquith
14 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.

#12 @ryan
14 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.

@markjaquith
14 years ago

No translation for slugs at all

#13 @markjaquith
14 years ago

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

#14 follow-up: @pavelevap
14 years ago

So why are post format slugs enabled for translation?

#15 in reply to: ↑ 14 @ryan
14 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.

@markjaquith
14 years ago

With some unused code removed.

#16 @markjaquith
14 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

#17 @markjaquith
14 years ago

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

#18 @markjaquith
14 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.