Next Previous Contents

11.

, . , , , . , , , , .

, , , . ; , , , .

, . .

c : localization internationalization. , . . , - //. - ... , . , - , : "" () . , .

( i18n ), , , , .

, , .

, ; .

, . , .

11.1 Locale

- locale. locale , . , locale , . , locale- / / . , / - / / , / - / / .

// , .

Locale

locale - , , , :

  1. ( . )
  2. /

- www.sensi.org/~alec/locale , (, ..)

www.tsu.ru/~pascal/x_locale/

( glibc):

:

: /usr/share/locale/ru_RU.KOI8-R/ ( ).

   LANG=ru
   LC_ALL=ru_RU.KOI8-R

- .

, :

?

UNIX ( POSIX:1996) locale , LANG:

$ export LANG={}

, : LANG="C" LANG="POSIX" ( ) - , ANSI C (ISO 9899:1990), US-ASCII (7 bit) ( Portable Character Set).

POSIX.2, LANG= locale:

$ locale -a

(POSIX.2 E (?)) :

        language_TERRITORY.Codeset

:

        language[_TERRITORY[.Codeset[@modyfier]]]

ISO 639 "language names", ISO 3166 - "territory names". _SU ( ), alias : ru_SU --> ru_RU.

LANG , , LANG="ru_RU.KOI8-R" LANG="ru_RU.ISO_8859-5". :

$ export LANG="ru_RU.KOI8-R"

locale, aliases () . "C" --> "POSIX".

$ export LANG=ru
$ export LANG=ru_RU
$ export LANG=ru_RU.KOI8-R

, , KOI8-R ( koi8-r ). , .

FreeBSD 2.x . Linux - . (Solaris, SCO, AIX e.t.c.) LANG="ru_RU", LANG="ru" ( Codeset ISO8859-5 ).

: ru_RU.X-CP-866 (ru_RU.IBM866), ru_RU.x-mac-cyrillic, ru_RU.ISO_8859-5 ru_RU.CP1251 - . ( x-mac-cyrillic) IANA. , , - - .

( export LANG={}) , locale locale API libc, . , :

, man-, .., :

$ export LANG="C"
$ export LC_CTYPE="ru_RU.KOI8-R"
$ export LC_COLLATE="ru_RU.KOI8-R"
$ export LC_TIME="C"

:

$ export LC_ALL={}

, "" " ". locale API . , PostScript: LC_NUMERIC ru_RU '' : "," , PostScript : "."  LC_NUMERIC printf("%f",float);. C (POSIX) LC_NUMERIC, PostScript:

$ export LC_NUMERIC="POSIX"

locale ( ).

$ locale

: UNICODE. LANG="ru_RU.UTF-8" .

Locale

RedHat Linux (, , Linux), locale: C (libc), - X . locale .

locale , LANG. , sh:

LANG=ru_SU
export LANG

, date. , .

RedHat 5.x KOI8-R locale ru_SU. ru_RU locale, iso-8859-5 .

locale . , ( ) ru_SU locale, POSIX . , , locale. , :

LANG=ru_SU
LC_NUMERIC=POSIX
export LANG LC_NUMERIC

. locale(7).

Linux. , Linux libc 5.3.12 (: RedHat 4.1), locale. Interneta (, , ).

, locale, 'locale -a'. locale , libc.

X, locale. XFree86 3.3 locale. , . , /usr/lib/X11/locale/ ( ). , koi8-r iso8859-5..

Locale

locale , . API, , locale. , locale - , locale ( ).

man setlocale(3):

locale, setlocale(LC_ALL, "" ) , , localeconv() locale - strcoll() strxfrm() .

:

  1. 8 . setlocale(). - 8- , ctype.h limits.h, signed/unsigned . , - . :
        if (c >= 'A' && c <= 'Z') {
            ...
    

    "locale"- . , locale ctype.h. :
         if (isalpha(c) && isupper(c)) { ... 
         if (isascii(c) && isupper(c))
    

    8- . MS-DOS 0x0E5 - . : "" GoldEd "" Norton Commander...
  2. , , . strcoll() strxfrm() strcmp() , time(), localtime(), strftime() , , localeconv() .
  3. /. . . , . , gettext() (Sun/POSIX ), catgets() (X/Open ). . i18n .
  4. EUC/Unicode . , char. wchar_t, , , Unicode. ANSI C API.

, , ( Voropay1 ) ( SingleUnix ).

11.2

, , ( i18n ) - .

. ( ) . , , free !

GNU, , . Ulrich Drepper (drepper@ipd.info.uni-karlsruhe.de) gettext. GNU , , prep.ai.mit.edu. , . , gettext .

: gettext GNU , ! GNU , locale . , ( , ). , : .po , , . , -, ! Ulrich Drepper ( drepper@ipd.info.uni-karlsruhe.de).


Next Previous Contents