Commit c01f6e69 authored by Fred Drake's avatar Fred Drake

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.
parent e0b9deb3
...@@ -45,7 +45,7 @@ functions: ...@@ -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,"") ...@@ -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
\item terminated with \constant{CHAR_MAX}, no further grouping
\code{'groupin'} is a sequence of numbers specifying at which is performed. If the sequence terminates with a \code{0},
relative positions the \code{'thousands_sep'} is expected. If the the last group size is repeatedly used.}
sequence is terminated with \constant{CHAR_MAX}, no further \lineiii{}{\code{'thousands_sep'}}
grouping is performed. If the sequence terminates with a \code{0}, {Character used between groups.}\hline
the last group size is repeatedly used. \lineiii{LC_MONETARY}{\code{'int_curr_symbol'}}
{International currency symbol.}
\item \lineiii{}{\code{'currency_symbol'}}
\code{'thousands_sep'} is the character used between groups. {Local currency symbol.}
\lineiii{}{\code{'mon_decimal_point'}}
\item {Decimal point used for monetary values.}
\code{'int_curr_symbol'} specifies the international currency \lineiii{}{\code{'mon_thousands_sep'}}
symbol from the \constant{LC_MONETARY} category. {Group separator used for monetary values.}
\lineiii{}{\code{'mon_grouping'}}
\item {Equivalent to \code{'grouping'}, used for monetary
\code{'currency_symbol'} is the local currency symbol. values.}
\lineiii{}{\code{'positive_sign'}}
\item {Symbol used to annotate a positive monetary value.}
\code{'mon_decimal_point'} is the decimal point used in monetary \lineiii{}{\code{'negative_sign'}}
values. {Symbol used to annotate a nnegative monetary value.}
\lineiii{}{\code{'frac_digits'}}
\item {Number of fractional digits used in local formatting
\code{'mon_thousands_sep'} is the separator for grouping of of monetary values.}
monetary values. \lineiii{}{\code{'int_frac_digits'}}
{Number of fractional digits used in international
\item formatting of monetary values.}
\code{'mon_grouping'} has the same format as the \code{'grouping'} \end{tableiii}
key; it is used for monetary values.
The possible values for \code{'p_sign_posn'} and
\item \code{'n_sign_posn'} are given below.
\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,"") ...@@ -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: ...@@ -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. ...@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment