[haiku-development] Re: ICU, Locale Kit, and separators

  • From: Oliver Tappe <zooey@xxxxxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Fri, 16 Nov 2012 13:11:58 +0100

Hi,

On 2012-11-16 at 03:49:19 [+0100], John Scipione <jscipione@xxxxxxxxx> 
wrote:
[ ... ]
> Both these bugs are essentially the same problem, to solve them I need
> to know what the localized separator should be for the given locale,
> in the first bug for decimal numbers, the second for time.
> 
> The worst part is, ICU _knows_ what the separator should be because it
> displays it correctly in Locale, but as far as I can tell, there is no
> way to get it to tell me!

please have a look at the ICU classes DecimalFormatSymbols and 
DateFormatSymbols, which serve exactly that purpose. The icu-addon of our 
libroot uses those classes, so maybe looking at that code can provide some 
hints - it lives in src/system/libroot/add-ons/icu.

The Locale Kit provides something similar with BFormattingConventions, 
however, accessing those symbols (via GetString()) has not been implemented 
yet.
BLocale::GetString() is partly implemented, but AFAICS doesn't provide all 
the strings yet, the ones you're after are missing.

Concerning the path for solving those tickets, the preferred way would be 
to implement support for accessing those symbols in BFormattingConventions. 
This class can be used to get the proper time-format for the current 
locale, I think using it could be useful in Deskbar's 
TTimeView::UpdateTimeFormat().

Alternatively, one could use the POSIX function strftime() to format the 
time in the deskbar clock, as IIRC Deskbar already invokes setlocale() to 
activate the selected locale within the POSIX layer.

cheers,
        Oliver

Other related posts: