[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.14.8 Internationalization

The following listing contains the interface of the Intl unit.

This unit provides national language support via locales and `.mo' files.

 
{ Welcome to the wonderful world of
  INTERNATIONALIZATION (i18n).

This unit provides the powerful mechanism of national language support by accessing `.mo' files and locale information.

It includes: locales (not xlocales) and libintl.

See documentation for gettext (`info gettext') for details.

Because GPC can deal with both CStrings and Pascal Strings, there is an interface for both types of arguments and function results with slightly different names.

E.g. for Pascal strings:

function GetText (const MsgId: String): TString;

And the same as above, but with a C interface:

function GetTextC (MsgId: CString): CString;

`PLConv' in Pascal is very different from `struct lconv *' in C. Element names do not have underscores and have sometimes different sizes. The conversion is done automatically and has correct results.

Furthermore, we have a tool similar to `xgettext' to extract all strings out of a Pascal source. It extracts the strings and writes a complete `.po' file to a file. See http://www.gnu-pascal.de/contrib/eike/ The filename is pas2po-VERSION.tar.gz.

Copyright (C) 2001-2002 by Eike Lange

Author: Eike Lange <eike.lange@uni-essen.de>

This unit is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation, version 2.

This unit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details.

You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. }

{$gnu-pascal,I-}

unit Intl;

interface

uses GPC;

type IntlString = String (16);

{ Port from _p_lconv in intlc.c } PLConv = ^TLConv; TLConv = record { Numeric (non-monetary) information. }

{ Decimal point character. } DecimalPoint: IntlString;

{ Thousands separator. } ThousandsSep: IntlString;

{ Each element is the number of digits in each group; elements with higher indices are farther left. An element with value CharMax means that no further grouping is done. An element with value Chr (0) means that the previous element is used for all groups farther left. } Grouping: IntlString;

{ Monetary information. }

{ First three chars are a currency symbol from ISO 4217. Fourth char is the separator. Fifth char is Chr (0). } IntCurrSymbol: IntlString;

{ Local currency symbol. } CurrencySymbol: IntlString;

{ Decimal point character. } MonDecimalPoint: IntlString;

{ Thousands separator. } MonThousandsSep: IntlString;

{ Like `Grouping' element (above). } MonGrouping: IntlString;

{ Sign for positive values. } PositiveSign: IntlString;

{ Sign for negative values. } NegativeSign: IntlString;

{ Int'l fractional digits. } IntFracDigits: ByteInt;

{ Local fractional digits. } FracDigits: ByteInt;

{ 1 if CurrencySymbol precedes a positive value, 0 if it succeeds. } PCSPrecedes: ByteInt;

{ 1 iff a space separates CurrencySymbol from a positive value. } PSepBySpace: ByteInt;

{ 1 if CurrencySymbol precedes a negative value, 0 if it succeeds. } NCSPrecedes: ByteInt;

{ 1 iff a space separates CurrencySymbol from a negative value. } NSepBySpace: ByteInt;

{ Positive and negative sign positions: 0 Parentheses surround the quantity and CurrencySymbol. 1 The sign string precedes the quantity and CurrencySymbol. 2 The sign string follows the quantity and CurrencySymbol. 3 The sign string immediately precedes the CurrencySymbol. 4 The sign string immediately follows the CurrencySymbol. } PSignPosn, NSignPosn: ByteInt; end;

{ Please do not assign anything to these identifiers! } var LC_CTYPE: Integer; asmname '_p_LC_CTYPE'; external; LC_NUMERIC: Integer; asmname '_p_LC_NUMERIC'; external; LC_TIME: Integer; asmname '_p_LC_TIME'; external; LC_COLLATE: Integer; asmname '_p_LC_COLLATE'; external; LC_MONETARY: Integer; asmname '_p_LC_MONETARY'; external; LC_MESSAGES: Integer; asmname '_p_LC_MESSAGES'; external; LC_ALL: Integer; asmname '_p_LC_ALL'; external; CharMax: Char; asmname '_p_CHAR_MAX'; external;

{@section Locales }

{ Set and/or return the current locale. } function SetLocale (Category: Integer; const Locale: String): TString;

{ Set and/or return the current locale. Same as above, but returns a CString. } function SetLocaleC (Category: Integer; const Locale: String): CString;

{ Return the numeric/monetary information for the current locale. The result is allocated from the heap. You can Dispose it when you don't need it anymore. } function LocaleConv: PLConv;

{@section GetText }

{ Look up MsgId in the current default message catalog for the current LC_MESSAGES locale. If not found, returns MsgId itself (the default text). } function GetText (const MsgId: String): TString;

{ Same as above, but with a C interface } function GetTextC (MsgId: CString): CString;

{ Look up MsgId in the DomainName message catalog for the current LC_MESSAGES locale. } function DGetText (const DomainName, MsgId: String): TString;

{ Same as above, but with a C interface } function DGetTextC (DomainName, MsgId: CString): CString;

{ Look up MsgId in the DomainName message catalog for the current Category locale. } function DCGetText (const DomainName, MsgId: String; Category: Integer): TString;

{ Same as above, but with a C interface } function DCGetTextC (DomainName, MsgId: CString; Category: Integer): CString;

{ Set the current default message catalog to DomainName. If DomainName is empty, reset to the default of `messages'. } function TextDomain (const DomainName: String): TString;

{ Same as above, but with a C interface. If DomainName is nil, return the current default. } function TextDomainC (DomainName: CString): CString;

{ Specify that the DomainName message catalog will be found in DirName rather than in the system locale data base. } function BindTextDomain (const DomainName, DirName: String): TString;

{ Same as above, but with a C interface } function BindTextDomainC (DomainName, DirName: CString): CString;


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Frank Heckenbach on May, 10 2002 using texi2html