Ticket #1540 (closed defect: fixed)

Opened 3 years ago

Last modified 2 years ago

Date format returned by wp_get_archives is not localizable

Reported by: stephenju Assigned to: skippy
Priority: lowest Milestone: 2.0.6
Component: Template Version: 1.5.1.2
Severity: normal Keywords: bg|needs-patch bg|2nd-opinion has-patch
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

wp_archive-l10n.patch (0.9 kB) - added by drssay on 05/21/06 01:52:53.
20xbranchfix.patch (0.9 kB) - added by Viper007Bond on 12/11/06 16:15:38.
Missing _'s

Change History

08/10/05 02:10:07 changed by skippy

  • keywords set to bg|needs-patch bg|2nd-opinion.
  • owner changed from anonymous to skippy.
  • status changed from new to assigned.
  • milestone set to 1.6.

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.

08/11/05 10:27:14 changed by nbachiyski

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...

11/13/05 03:14:48 changed by matt

  • priority changed from normal to lowest.
  • milestone changed from 1.6 to 2.1.

01/03/06 14:46:50 changed by stephenju

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.

02/17/06 12:34:33 changed by drssay

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);

05/21/06 01:52:16 changed by drssay

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.

05/21/06 01:52:53 changed by drssay

  • attachment wp_archive-l10n.patch added.

08/14/06 19:48:38 changed by rgovostes

  • keywords changed from bg|needs-patch bg|2nd-opinion to bg|needs-patch bg|2nd-opinion has-patch.

11/29/06 21:34:36 changed by ryan

  • milestone changed from 2.1 to 2.0.6.

11/29/06 21:34:54 changed by ryan

  • status changed from assigned to closed.
  • resolution set to fixed.

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

12/11/06 13:13:54 changed by tai

  • status changed from closed to reopened.
  • resolution deleted.

Please put one more underbar like

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

, otherwise it doesn't work.

12/11/06 16:15:38 changed by Viper007Bond

  • attachment 20xbranchfix.patch added.

Missing _'s

12/11/06 21:24:03 changed by markjaquith

  • status changed from reopened to closed.
  • resolution set to fixed.

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