January 16, 2006 Re: number formatting | ||||
|---|---|---|---|---|
  | ||||
Posted in reply to John C  | Please do! use this account: someidiot at at at earthlink dot . dot net "John C" <johnch_atms@hotmail.com> wrote in message news:dqghld$1llj$1@digitaldaemon.com... > "Kris" <fu@bar.com> wrote in message news:dq8o9c$12rs$1@digitaldaemon.com... >> "John C" <johnch_atms@hotmail.com> wrote... >> [snip] >>> This reminds me that one of the gaping holes in Phobos is support for locales. Open std.dateparse to see how bad it is - English day and month names are hard coded! There should be a localisation module that might incorporate numeric formatting (the latter would probably depend on the former, eg for currencies). >>> >>> Right, I guess I'm looking at rolling my own stuff. >> >> >> The ICU project has truly excellent support for this kind of thing, although it is industrial strength ~ can be a bit heavyweight for personal use? They have all kinds of tools for externalizing and migrating/managing I18N concerns, and there's a D wrapper for ICU in the Mango library. >> >> I'm also interested in a lightweight implementation (Mango has a bunch of support functions to make it happen) ~ just haven't got around to hooking up the pieces yet. If ICU is not appropriate for your needs, and you think it's a reasonably idea, we might combine efforts? >> > > Kris, may I send you the work I've done on this? So far I've got a general class to represent locales on the user's system, several classes for date/time, number and text formatting support, a set of calendars (Gregorian, Japanese, Hijri etc), and some string-related functions. > > The following example lists all the calendars supported by a locale. > > Culture[] allCultures = Culture.getCultures(CultureTypes.ALL); > foreach (Culture culture; allCultures) { > writefln("Culture: " ~ culture.name ~ " - " ~ culture.displayName); > Calendar[] calendars = culture.optionalCalendars; > writefln("Calendars:"); > foreach (Calendar cal; calendars) { > writefln("\t" ~ cal.toString()); > } > writefln(); > } > > This example prints the days of the week in French: > > Culture culture = new Culture("fr-fr"); > for (DayOfWeek dayOfWeek = DayOfWeek.SUNDAY; dayOfWeek <= > DayOfWeek.SATURDAY; dayOfWeek++) { > writefln(culture.dateTimeFormat.getDayName(dayOfWeek)); > } > > John. >  | |||
January 16, 2006 Re: number formatting | ||||
|---|---|---|---|---|
  | ||||
Posted in reply to John C  | John C wrote:
> "Kris" <fu@bar.com> wrote in message news:dq8o9c$12rs$1@digitaldaemon.com...
> 
>>"John C" <johnch_atms@hotmail.com> wrote...
>>[snip]
>>
>>>This reminds me that one of the gaping holes in Phobos is support for locales. Open std.dateparse to see how bad it is - English day and month names are hard coded! There should be a localisation module that might incorporate numeric formatting (the latter would probably depend on the former, eg for currencies).
>>>
>>>Right, I guess I'm looking at rolling my own stuff.
>>
>>
>>The ICU project has truly excellent support for this kind of thing, although it is industrial strength ~ can be a bit heavyweight for personal use? They have all kinds of tools for externalizing and migrating/managing I18N concerns, and there's a D wrapper for ICU in the Mango library.
>>
>>I'm also interested in a lightweight implementation (Mango has a bunch of support functions to make it happen) ~ just haven't got around to hooking up the pieces yet. If ICU is not appropriate for your needs, and you think it's a reasonably idea, we might combine efforts?
>>
> 
> 
> Kris, may I send you the work I've done on this? So far I've got a general class to represent locales on the user's system, several classes for date/time, number and text formatting support, a set of calendars (Gregorian, Japanese, Hijri etc), and some string-related functions.
> 
> The following example lists all the calendars supported by a locale.
> 
>     Culture[] allCultures = Culture.getCultures(CultureTypes.ALL);
>     foreach (Culture culture; allCultures) {
>         writefln("Culture: " ~ culture.name ~ " - " ~ culture.displayName);
>         Calendar[] calendars = culture.optionalCalendars;
>         writefln("Calendars:");
>         foreach (Calendar cal; calendars) {
>             writefln("\t" ~ cal.toString());
>         }
>         writefln();
>     }
> 
> This example prints the days of the week in French:
> 
>     Culture culture = new Culture("fr-fr");
>     for (DayOfWeek dayOfWeek = DayOfWeek.SUNDAY; dayOfWeek <= DayOfWeek.SATURDAY; dayOfWeek++) {
>         writefln(culture.dateTimeFormat.getDayName(dayOfWeek));
>     }
> 
Nice. But: what about locales where Monday is the first day of week?
 | |||
January 17, 2006 Re: number formatting | ||||
|---|---|---|---|---|
  | ||||
Posted in reply to Ivan Senji  | "Ivan Senji" <ivan.senji_REMOVE_@_THIS__gmail.com> wrote in message news:dqhavm$2fmg$1@digitaldaemon.com... > John C wrote: >> "Kris" <fu@bar.com> wrote in message news:dq8o9c$12rs$1@digitaldaemon.com... >> >>>"John C" <johnch_atms@hotmail.com> wrote... >>>[snip] >>> >>>>This reminds me that one of the gaping holes in Phobos is support for locales. Open std.dateparse to see how bad it is - English day and month names are hard coded! There should be a localisation module that might incorporate numeric formatting (the latter would probably depend on the former, eg for currencies). >>>> >>>>Right, I guess I'm looking at rolling my own stuff. >>> >>> >>>The ICU project has truly excellent support for this kind of thing, although it is industrial strength ~ can be a bit heavyweight for personal use? They have all kinds of tools for externalizing and migrating/managing I18N concerns, and there's a D wrapper for ICU in the Mango library. >>> >>>I'm also interested in a lightweight implementation (Mango has a bunch of support functions to make it happen) ~ just haven't got around to hooking up the pieces yet. If ICU is not appropriate for your needs, and you think it's a reasonably idea, we might combine efforts? >>> >> >> >> Kris, may I send you the work I've done on this? So far I've got a general class to represent locales on the user's system, several classes for date/time, number and text formatting support, a set of calendars (Gregorian, Japanese, Hijri etc), and some string-related functions. >> >> The following example lists all the calendars supported by a locale. >> >> Culture[] allCultures = Culture.getCultures(CultureTypes.ALL); >> foreach (Culture culture; allCultures) { >> writefln("Culture: " ~ culture.name ~ " - " ~ >> culture.displayName); >> Calendar[] calendars = culture.optionalCalendars; >> writefln("Calendars:"); >> foreach (Calendar cal; calendars) { >> writefln("\t" ~ cal.toString()); >> } >> writefln(); >> } >> >> This example prints the days of the week in French: >> >> Culture culture = new Culture("fr-fr"); >> for (DayOfWeek dayOfWeek = DayOfWeek.SUNDAY; dayOfWeek <= >> DayOfWeek.SATURDAY; dayOfWeek++) { >> writefln(culture.dateTimeFormat.getDayName(dayOfWeek)); >> } >> > > Nice. But: what about locales where Monday is the first day of week? You'd offset it with the 'firstDayOfWeek' property.  | |||
Copyright © 1999-2021 by the D Language Foundation
 
Permalink
Reply