Use a table to describe the keys to the locale information dictionary;

this is slightly easier to read than the list environment that had been
used.
This commit is contained in:
Fred Drake 2000-11-30 07:13:58 +00:00
parent e0b9deb3ce
commit c01f6e691b
1 changed files with 42 additions and 67 deletions

View File

@ -45,7 +45,7 @@ functions:
\begin{verbatim} \begin{verbatim}
import locale import locale
locale.setlocale(locale.LC_ALL,"") locale.setlocale(locale.LC_ALL, '')
\end{verbatim} \end{verbatim}
This sets the locale for all categories to the user's default This sets the locale for all categories to the user's default
@ -61,67 +61,42 @@ locale.setlocale(locale.LC_ALL,"")
Returns the database of of the local conventions as a dictionary. Returns the database of of the local conventions as a dictionary.
This dictionary has the following strings as keys: This dictionary has the following strings as keys:
\begin{itemize} \begin{tableiii}{l|l|p{3in}}{constant}{Key}{Category}{Meaning}
\item \lineiii{LC_NUMERIC}{\code{'decimal_point'}}
\code{'decimal_point'} specifies the decimal point used in floating {Decimal point character.}
point number representations for the \constant{LC_NUMERIC} \lineiii{}{\code{'grouping'}}
category. {Sequence of numbers specifying which relative positions
the \code{'thousands_sep'} is expected. If the sequence is
terminated with \constant{CHAR_MAX}, no further grouping
is performed. If the sequence terminates with a \code{0},
the last group size is repeatedly used.}
\lineiii{}{\code{'thousands_sep'}}
{Character used between groups.}\hline
\lineiii{LC_MONETARY}{\code{'int_curr_symbol'}}
{International currency symbol.}
\lineiii{}{\code{'currency_symbol'}}
{Local currency symbol.}
\lineiii{}{\code{'mon_decimal_point'}}
{Decimal point used for monetary values.}
\lineiii{}{\code{'mon_thousands_sep'}}
{Group separator used for monetary values.}
\lineiii{}{\code{'mon_grouping'}}
{Equivalent to \code{'grouping'}, used for monetary
values.}
\lineiii{}{\code{'positive_sign'}}
{Symbol used to annotate a positive monetary value.}
\lineiii{}{\code{'negative_sign'}}
{Symbol used to annotate a nnegative monetary value.}
\lineiii{}{\code{'frac_digits'}}
{Number of fractional digits used in local formatting
of monetary values.}
\lineiii{}{\code{'int_frac_digits'}}
{Number of fractional digits used in international
formatting of monetary values.}
\end{tableiii}
\item The possible values for \code{'p_sign_posn'} and
\code{'groupin'} is a sequence of numbers specifying at which \code{'n_sign_posn'} are given below.
relative positions the \code{'thousands_sep'} is expected. If the
sequence is terminated with \constant{CHAR_MAX}, no further
grouping is performed. If the sequence terminates with a \code{0},
the last group size is repeatedly used.
\item
\code{'thousands_sep'} is the character used between groups.
\item
\code{'int_curr_symbol'} specifies the international currency
symbol from the \constant{LC_MONETARY} category.
\item
\code{'currency_symbol'} is the local currency symbol.
\item
\code{'mon_decimal_point'} is the decimal point used in monetary
values.
\item
\code{'mon_thousands_sep'} is the separator for grouping of
monetary values.
\item
\code{'mon_grouping'} has the same format as the \code{'grouping'}
key; it is used for monetary values.
\item
\code{'positive_sign'} and \code{'negative_sign'} gives the sign
used for positive and negative monetary quantities.
\item
\code{'int_frac_digits'} and \code{'frac_digits'} specify the number
of fractional digits used in the international and local
formatting of monetary values.
\item
\code{'p_cs_precedes'} and \code{'n_cs_precedes'} specifies whether
the currency symbol precedes the value for positive or negative
values.
\item
\code{'p_sep_by_space'} and \code{'n_sep_by_space'} specifies
whether there is a space between the positive or negative value
and the currency symbol.
\item
\code{'p_sign_posn'} and \code{'n_sign_posn'} indicate how the
sign should be placed for positive and negative monetary values.
\end{itemize}
The possible values for \code{p_sign_posn} and
\code{n_sign_posn} are given below.
\begin{tableii}{c|l}{code}{Value}{Explanation} \begin{tableii}{c|l}{code}{Value}{Explanation}
\lineii{0}{Currency and value are surrounded by parentheses.} \lineii{0}{Currency and value are surrounded by parentheses.}
@ -129,7 +104,7 @@ locale.setlocale(locale.LC_ALL,"")
\lineii{2}{The sign should follow the value and currency symbol.} \lineii{2}{The sign should follow the value and currency symbol.}
\lineii{3}{The sign should immediately precede the value.} \lineii{3}{The sign should immediately precede the value.}
\lineii{4}{The sign should immediately follow the value.} \lineii{4}{The sign should immediately follow the value.}
\lineii{LC_MAX}{Nothing is specified in this locale.} \lineii{\constant{LC_MAX}}{Nothing is specified in this locale.}
\end{tableii} \end{tableii}
\end{funcdesc} \end{funcdesc}
@ -289,10 +264,10 @@ Example:
\begin{verbatim} \begin{verbatim}
>>> import locale >>> import locale
>>> loc = locale.setlocale(locale.LC_ALL) # get current locale >>> loc = locale.setlocale(locale.LC_ALL) # get current locale
>>> locale.setlocale(locale.LC_ALL, "de") # use German locale >>> locale.setlocale(locale.LC_ALL, 'de') # use German locale
>>> locale.strcoll("f\344n", "foo") # compare a string containing an umlaut >>> locale.strcoll('f\344n', 'foo') # compare a string containing an umlaut
>>> locale.setlocale(locale.LC_ALL, "") # use user's preferred locale >>> locale.setlocale(locale.LC_ALL, '') # use user's preferred locale
>>> locale.setlocale(locale.LC_ALL, "C") # use default (C) locale >>> locale.setlocale(locale.LC_ALL, 'C') # use default (C) locale
>>> locale.setlocale(locale.LC_ALL, loc) # restore saved locale >>> locale.setlocale(locale.LC_ALL, loc) # restore saved locale
\end{verbatim} \end{verbatim}
@ -308,7 +283,7 @@ correctly.
Initially, when a program is started, the locale is the \samp{C} locale, no Initially, when a program is started, the locale is the \samp{C} locale, no
matter what the user's preferred locale is. The program must matter what the user's preferred locale is. The program must
explicitly say that it wants the user's preferred locale settings by explicitly say that it wants the user's preferred locale settings by
calling \code{setlocale(LC_ALL, "")}. calling \code{setlocale(LC_ALL, '')}.
It is generally a bad idea to call \function{setlocale()} in some library It is generally a bad idea to call \function{setlocale()} in some library
routine, since as a side effect it affects the entire program. Saving routine, since as a side effect it affects the entire program. Saving