Open
Bug 162664
Opened 22 years ago
Updated 16 years ago
Should support localised strings for date output (time2str vs. strftime vs. Template::Plugin::Date)
Categories
(Bugzilla :: Bugzilla-General, defect)
Tracking
()
NEW
People
(Reporter: burnus, Unassigned)
References
()
Details
At present words like Mon(day) or Aug(ust) are not translated based on the language of the choosen template. E.g. with the French template I would expect: mer aoû 14 14:38:44 but I get Wed Aug 14 14:38:44 I propose: a) To use the POSIX function setlocale to set the locale (setlocale) b) Construct the locale-language from the used RFC2616 Accept Language tag (from that used for the template) c) Replace time2str by strftime The problem is that the RFC2616, 14.4 Accept Language header is not that simple translateable into locales. They consist of a ISO 639 language code (ll) and a ISO 3166 country code (CC) separated by an underscore: ll_CC For the codes see: http://www.din.de/gremien/nas/nabd/iso3166ma/codlstp1/en_listp1.html http://www.loc.gov/standards/iso639-2/langcodes.html For the discussion see Mailinglist (URL) Patch to come.
Comment 1•22 years ago
|
||
The posix stuff isn't portable to windows. If you do want to go that way, the template toolkit date plugin does that. OTOH, Date::Format (which we already require) does it a more portable way, but presumably only supports a smaller subset of languages (Austrian, Czech, Dutch, English, French, German, Italian, and Norwegian) If you did want another language, you could always patch Date::Format...
Reporter | ||
Comment 2•22 years ago
|
||
Hmm. If I understand correctly we have these possibilities: a) Using Date::Format and Date::Language and support only Austrian, Czech, Dutch, French, German, Italian and Norwegian and get full support under Windows http://groups.google.de/groups?selm=3D46BBB7.2090406%40physik.fu-berlin.de b) Use POSIX qw(strftime setlocale); which fails under Windows (URL) due to POSIX but supports about 70 languages. c) Use Template::Plugin::Date which als requires POSIX and doesn't require the global.pl (or similar) to set the locale but makes the templates more crowded http://template-toolkit.org/docs/default/Modules/Template/Plugin/Date.html For my personal usage either approach works since I use Unix and my languages are supported.
Comment 3•22 years ago
|
||
Template::Plugin::Date does require POSIX - it does: if ($locale) { # format the date in a specific locale, saving and subsequently # restoring the current locale. my $old_locale = &POSIX::setlocale(&POSIX::LC_ALL); &POSIX::setlocale(&POSIX::LC_ALL, $locale); $datestr = &POSIX::strftime($format, @date); &POSIX::setlocale(&POSIX::LC_ALL, $old_locale); } I don't _know_ that this will fail on windows, but I'd be very surprised if it didn't - it may work with some cygwin stuff, though. Can someone test?
Reporter | ||
Comment 4•22 years ago
|
||
Change summary since to make it easier to find.
Summary: Should support localised strings for date output → Should support localised strings for date output (time2str vs. strftime vs. Template::Plugin::Date)
Comment 5•22 years ago
|
||
bbaetz: http://www.xav.com/perl/lib/POSIX.html says the POSIX module supports Windows. Do you have another source of information? Gerv
Comment 6•22 years ago
|
||
Unless someone provides a source which says we can't use POSIX stuff (Template::Plugin::Date) on Windows, I intend to code up a solution which does that. Gerv
Comment 7•21 years ago
|
||
Jouni: comments please?
Comment 8•21 years ago
|
||
Years ago Posix date formatting didn't work, but things may have changed. I'll try this out soon. I need the same thing for bug 82878 anyway.
Comment 9•21 years ago
|
||
I ran the Date format plugin example code on Win32 without problems. Ask if you need more testing. -- [% USE date %] # use current time and default format [% date.format %] # specify time as seconds since epoch or 'h:m:s d-m-y' string [% date.format(960973980) %] [% date.format('4:20:36 21/12/2000') %] # specify format [% date.format(mytime, '%H:%M:%S') %] # specify locale [% date.format(date.now, '%a %d %b %y', 'en_GB') %] # named parameters [% date.format(mytime, format = '%H:%M:%S') %] [% date.format(locale = 'en_GB') %] [% date.format(time = date.now, format = '%H:%M:%S', locale = 'en_GB) %] # specify default format to plugin [% USE date(format = '%H:%M:%S', locale = 'de_DE') %] [% date.format %]
Comment 10•19 years ago
|
||
Reassigning bugs that I'm not actively working on to the default component owner in order to try to make some sanity out of my personal buglist. This doesn't mean the bug isn't being dealt with, just that I'm not the one doing it. If you are dealing with this bug, please assign it to yourself.
Assignee: justdave → general
QA Contact: mattyt-bugzilla → default-qa
You need to log in
before you can comment on or make changes to this bug.
Description
•