Make WordPress Core

Opened 20 years ago

Closed 19 years ago

Last modified 17 months ago

#1540 closed defect (bug) (fixed)

Date format returned by wp_get_archives is not localizable

Reported by: stephenju's profile stephenju Owned by: skippy's profile skippy
Milestone: 2.0.6 Priority: lowest
Severity: normal Version: 1.5.1.2
Component: Template Keywords: bg|needs-patch bg|2nd-opinion has-patch
Focuses: Cc:

Description

When using wp_get_archives('type=monthly'), the date string format in the links is hard coded as "month year" not localizable.

Attachments (2)

wp_archive-l10n.patch (913 bytes) - added by drssay 19 years ago.
20xbranchfix.patch (949 bytes) - added by Viper007Bond 19 years ago.
Missing _'s

Download all attachments as: .zip

Change History (13)

#1 @skippy
20 years ago

  • Keywords bg|needs-patch bg|2nd-opinion added
  • Milestone set to 1.6
  • Owner changed from anonymous to skippy
  • Status changed from new to assigned

lines 306 and 309 of wp-includes/template-functions-general.php:

$text = sprintf('%s %d', $month[zeroise($arcresult->month,2)], $arcresult->year);

I don't see a clean way to use the blog's preferred date format; maybe someone else will.

#2 @nbachiyski
20 years ago

We could easily fetch also the unix timestamp of a post in that month from the database and then form the string using the date_i18n function with an internationalized date format:

$text = date_i18n(_('F Y'), $arcresult->post_date);

However, in this situation we could run into some problems. The string marked for internaliozation is 'F Y' (which means: monthname year). For example I want to translate it as '\a\r\c\h\i\v\e \f\o\r\: Y F', but somewhere in Wordpress the same combination 'F Y' is used and it is again internationalized. If the second occurence of 'F Y' is in other context (far apart from archives) then our translation will be totally inadequate.

Actually, using the same string in many contexts is far more general gettext issue and maybe is its greatest flaw...

#3 @matt
20 years ago

  • Milestone changed from 1.6 to 2.1
  • Priority changed from normal to lowest

#4 @stephenju
20 years ago

May I suggest that an additional month date format option to be added in the admin? This will avoid the ambiguity and allow user full control over the format.

Also, I would argue this is a high priority bug since it's the default format of the archive listing and every blog in a language with different date/time format will show it WRONG.

#5 @drssay
19 years ago

Is there any solution of this?
This ticket must fixed quickly for non latin1 user(for example China & Japan & Korean)
I Think below solution is very good solution.

$text = date_i18n(_('F Y'), $arcresult->post_date);

#6 @drssay
19 years ago

second option

$text = sprintf(_('%1$s %2$d'), $month[zeroise($arcresult->month,2)], $arcresult->year);

I think that best solution using smallest edit.

patch attached.

#7 @rgovostes
19 years ago

  • Keywords has-patch added

#8 @ryan
19 years ago

  • Milestone changed from 2.1 to 2.0.6

#9 @ryan
19 years ago

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

(In [4545]) gettext date format strings in wp_get_archives. fixes #1540

#10 @tai
19 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Please put one more underbar like

(__('%1$s %2$d')

, otherwise it doesn't work.

@Viper007Bond
19 years ago

Missing _'s

#11 @markjaquith
19 years ago

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

(In [4641]) _() => () typo fix. props tai. fixes #1540

Note: See TracTickets for help on using tickets.