[fpc-devel] Locale solution for Linux (and maybe *nix)

petr.kristan at epos.cz petr.kristan at epos.cz
Mon Aug 4 09:38:39 CEST 2008


On Mon, Aug 04, 2008 at 09:31:35AM +0200, Graeme Geldenhuys wrote:
> Hi,
> 
> In FPC the locale information is all hard-coded for Linux and other
> Unix based systems. We don't all live in the USA. ;-)  This is very
> annoying.  I also know we may not use glibc calls in FPC to get the
> locale information, because glibc is not always available on systems
> other than Linux.
> 
> Today I found the following on my Linux system which could possibly
> solve this issues.  Could other Linux distros and Unix users (*BSD,
> etc) confirm if they also have the following directory?
> 
> Under Ubuntu 7.10 I have the follow directory:  /usr/share/i18n/locales/
> 
> Inside that directory are files like en_GB, en_US, es_ES, de_DE etc....
> They are plain text files that should be fairly easy to parse and
> extract the locale information.  Couldn't we use that to populate the
> locale information inside FPC, without the need of glibc?
> 
> For example, here are some of the content of the en_ZA (English South
> Africa) file:
> 
> -------------[  en_ZA  ]--------------------
> <....snip....>
> LC_MONETARY
> % ISO 4217 Currency and fund codes
> % http://www.bsi-global.com/Technical+Information/Publications/_Publications/tig90.xalter
> % "ZAR "
> int_curr_symbol         "<U005A><U0041><U0052><U0020>"
> 
> % "R"
> currency_symbol         "<U0052>"
> 
> % "."
> mon_decimal_point       "<U002E>"
> 
> % ","
> mon_thousands_sep       "<U002C>"
> mon_grouping            3;3
> positive_sign           ""
> 
> % "-"
> negative_sign           "<U002D>"
> int_frac_digits         2
> frac_digits             2
> p_cs_precedes           1
> p_sep_by_space          0
> n_cs_precedes           1
> n_sep_by_space          0
> p_sign_posn             1
> n_sign_posn             1
> END LC_MONETARY
> 
> LC_NUMERIC
> % "."
> decimal_point           "<U002E>"
> 
> % ","
> thousands_sep           "<U002C>"
> grouping                3;3
> END LC_NUMERIC
> 
> LC_TIME
> % abday - The abbreviations for the week days:
> % - Sun, Mon, Tue, Wed, Thu, Fri, Sat
> abday       "<U0053><U0075><U006E>";"<U004D><U006F><U006E>";/
>             "<U0054><U0075><U0065>";"<U0057><U0065><U0064>";/
>             "<U0054><U0068><U0075>";"<U0046><U0072><U0069>";/
>             "<U0053><U0061><U0074>"
> <...snip...>
> % Date representation to be referenced by the "%x" field descriptor -
> % "%d/%m/%Y", day/month/year as decimal numbers (01/01/2000).
> d_fmt       "<U0025><U0064><U002F><U0025><U006D><U002F><U0025><U0059>"
> <...snip...>
> first_weekday 1
> END LC_TIME
> 
> LC_PAPER
> <...snip...>
> END LC_PAPER
> 
> LC_TELEPHONE
> <...snip...>
> END LC_TELEPHONE
> ----------------[  end  ]---------------------
> 
Include rtl/unix/clocale.pp into your project. 

Petr

-- 
Ing. Petr Kristan
.
EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice
tel: +420 466335223    Czech Republic (Eastern Europe) 
fax: +420 466510709



More information about the fpc-devel mailing list