Re: How to get a localized string

2003-12-09 Thread Dave Rolsky
On Tue, 9 Dec 2003, Henry Sobotka wrote:

> 2009. I would expect "9-12-2003" (expressing years in two digits is
> frowned upon; e.g. "1998-99" is considered an anglicism, "the proper way
> to write it" being "1998-1999"). The string version would be "le 9
> décembre 2003"; month abbreviations tend to be used only where space is
> limited (as in a table), and preceding dates with "le" is almost
> invariable, even where "the" would never be used in English. I'm left
> wondering if the "03-12-09" isn't an ISO-standard placeholder for "not
> sure of locale data", or based on a "Canada is officially metric, ergo
> ISO rules" premise out of touch with common usage (even for en_CA I
> would expect "12/09/03", not the preferable-for-the-sake-of-clarity
> y-m-d).

To file a bug report for the ICU data, which is what we use for
DateTime::Locale, go to http://www.jtcsv.com/cgibin/icu-bugs/

I double-checked and the latest version of the fr_CA locale still
specified the use of the YY-MM-DD format for medium and short lengths.


-dave

/*===
House Absolute Consulting
www.houseabsolute.com
===*/


Re: How to get a localized string

2003-12-08 Thread Henry Sobotka
Dave Rolsky wrote:
> 
> On Mon, 8 Dec 2003, Doug Treder wrote:
> 
> >$dt = DateTime->now(locale=>"fr_CA");  # canadian french
> >print $dt->strftime('%x');
> >'03-12-09'
> >
> > the "medium" format may or may not be numeric.  or is one of the two
> > locale modules wrong?
> 
> That's just what the locale data says.  There's no way to know whether or
> not a given locale will use only numbers in the output other than looking
> at the output.

Here in Quebec "03-12-09" would normally be interpreted as December 3,
2009. I would expect "9-12-2003" (expressing years in two digits is
frowned upon; e.g. "1998-99" is considered an anglicism, "the proper way
to write it" being "1998-1999"). The string version would be "le 9
décembre 2003"; month abbreviations tend to be used only where space is
limited (as in a table), and preceding dates with "le" is almost
invariable, even where "the" would never be used in English. I'm left
wondering if the "03-12-09" isn't an ISO-standard placeholder for "not
sure of locale data", or based on a "Canada is officially metric, ergo
ISO rules" premise out of touch with common usage (even for en_CA I
would expect "12/09/03", not the preferable-for-the-sake-of-clarity
y-m-d).

h~



Re: How to get a localized string

2003-12-08 Thread Dave Rolsky
On Mon, 8 Dec 2003, Doug Treder wrote:

> Good point, for example:
>
>$dt = DateTime->now(locale=>"fr_FR");  # france french
>print $dt->strftime('%x');
>'9 déc. 03'
>
>$dt = DateTime->now(locale=>"fr_CA");  # canadian french
>print $dt->strftime('%x');
>'03-12-09'
>
> the "medium" format may or may not be numeric.  or is one of the two
> locale modules wrong?

That's just what the locale data says.  There's no way to know whether or
not a given locale will use only numbers in the output other than looking
at the output.


-dave

/*===
House Absolute Consulting
www.houseabsolute.com
===*/


Re: How to get a localized string

2003-12-08 Thread Doug Treder
Good point, for example:

  $dt = DateTime->now(locale=>"fr_FR");  # france french
  print $dt->strftime('%x');
  '9 déc. 03'
  $dt = DateTime->now(locale=>"fr_CA");  # canadian french
  print $dt->strftime('%x');
  '03-12-09'
the "medium" format may or may not be numeric.  or is one of the two 
locale modules wrong?

-D



Dave Rolsky wrote:
On Mon, 8 Dec 2003, Doug Treder wrote:


the object should be able to use the locale it already contains;  I
shouldn't have to pass it in.   We already have shortcuts for ->mdy,
->dmy, ->hms  so there should be a nice little shortcut for a
locale-aware getter.  The presence of the former in the documentation
might lead one to believe an if statement would be the best way to
localize this use case (m/d/y vs d/m/y).


We do already have $dt->strftime('%x') but the length of the output
depends on the default date format length for the locale.   AFAICT, for
all locales this is currently "medium".
But that's not necessarily enough.

If we're going to add more methods that output localized _numeric_, they
need to be well thought out.  A locale_strftime method that doesn't take
format specifiers is really confusing, particularly since you propose to
have it just output the date, but others will want datetime, time, etc.
Maybe something like:

 $dt->localized_date
 $dt->localized_time
 $dt->localized_datetime
Each of these could accept an optional length argument.

-dave

/*===
House Absolute Consulting
www.houseabsolute.com
===*/



Re: How to get a localized string

2003-12-08 Thread Dave Rolsky
On Mon, 8 Dec 2003, Doug Treder wrote:

> the object should be able to use the locale it already contains;  I
> shouldn't have to pass it in.   We already have shortcuts for ->mdy,
> ->dmy, ->hms  so there should be a nice little shortcut for a
> locale-aware getter.  The presence of the former in the documentation
> might lead one to believe an if statement would be the best way to
> localize this use case (m/d/y vs d/m/y).

We do already have $dt->strftime('%x') but the length of the output
depends on the default date format length for the locale.   AFAICT, for
all locales this is currently "medium".

But that's not necessarily enough.

If we're going to add more methods that output localized _numeric_, they
need to be well thought out.  A locale_strftime method that doesn't take
format specifiers is really confusing, particularly since you propose to
have it just output the date, but others will want datetime, time, etc.

Maybe something like:

 $dt->localized_date
 $dt->localized_time
 $dt->localized_datetime

Each of these could accept an optional length argument.


-dave

/*===
House Absolute Consulting
www.houseabsolute.com
===*/


Re: How to get a localized string

2003-12-08 Thread Doug Treder
So...it would look like:

   $dt->strftime($dt->locale->medium_date_format);

could we get a shortcut method like:

   $dt->locale_strftime('medium');

the object should be able to use the locale it already contains;  I 
shouldn't have to pass it in.   We already have shortcuts for ->mdy, 
->dmy, ->hms  so there should be a nice little shortcut for a 
locale-aware getter.  The presence of the former in the documentation 
might lead one to believe an if statement would be the best way to 
localize this use case (m/d/y vs d/m/y).

-D



Dave Rolsky wrote:
On Mon, 8 Dec 2003, Doug Treder wrote:


and I know that locale knows what formatting it prefers (such as
day-month-year versus month-day-year abbreviations).  But is there an
less verbose way to pull it out than this:
   $dt->strftime($dt->locale->date_formats->{'medium'});

I was hoping for something like $dt->medium_format  does it exist?


 $dt->locale->medium_date_format

The locale classes need better docs, I think.

-dave

/*===
House Absolute Consulting
www.houseabsolute.com
===*/



Re: How to get a localized string

2003-12-08 Thread Dave Rolsky
On Mon, 8 Dec 2003, Doug Treder wrote:

> and I know that locale knows what formatting it prefers (such as
> day-month-year versus month-day-year abbreviations).  But is there an
> less verbose way to pull it out than this:
>
> $dt->strftime($dt->locale->date_formats->{'medium'});
>
> I was hoping for something like $dt->medium_format  does it exist?

 $dt->locale->medium_date_format

The locale classes need better docs, I think.


-dave

/*===
House Absolute Consulting
www.houseabsolute.com
===*/


How to get a localized string

2003-12-08 Thread Doug Treder
Couldn't find this in the FAQ...

If I create a datetime with a locale,

   $dt = DateTime->now(locale=>'fr_FR');

I know there is a locale in that datetime object...

   $dt->locale

and I know that locale knows what formatting it prefers (such as 
day-month-year versus month-day-year abbreviations).  But is there an 
less verbose way to pull it out than this:

   $dt->strftime($dt->locale->date_formats->{'medium'});

I was hoping for something like $dt->medium_format  does it exist?

-Doug