No project description provided
Project description
This package exposes part of the xlocale-family of C functions to Python. This is particularly useful to set the locale per-thread.
Normally you use the locale.setlocale function to change the locale for the entire process:
import locale locale.setlocale(locale.LC_ALL, 'nl_NL')
This may not be desirable for webservers or other applications that use multiple threads. To change the locale for just the current thread you do this:
import xlocale loc = xlocale.Locale(xlocale.LC_ALL_MASK, 'nl_NL') loc.use()
Creating a locale object
- xlocale.Locale([mask[, locale[, base]])
Create a new locale object. The new locale is created by taken a base locale and changing one or more locale categories. If no base is given the C locale will be used.
mask is a bitmask build from the LC_*_MASK constants. Normally you will want to use LC_ALL_MASK to change the locale completely.
locale is a string with the locale name. If not provided the C locale will be used.
- xlocale.Locale.current_locale()
Return a Locale instance for the currently locale.
Locale instances
- Locale.use()
Switch the locale for the current thread.
- Locale.name(mask)
Return the name for a locale category. mask is a bitmask of locale categories, and the name for the first configured category will be returned.
This method is not available on all platforms, and will raise an exception on unsupported platforms.
- Locale.lconv()
Return information describing how numbers and currency values must be displayed in the current locale. This is an object with the following attributes:
decimal_point |
The decimal point character, except for currency values, cannot be an empty string. |
thousands_sep |
The separator between groups of digits before the decimal point, except for currency values. |
grouping |
The sizes of the groups of digits, except for currency This is a list of integers representing group size from low order digit groups to high order (right to left). The list may be terminated with 0 or CHAR_MAX. If the list is terminated with 0 the last group size before the 0 is repeated to account for all the digits. If the list isterminated with CHAR_MAX, no more grouping is performed. |
int_curr_symbol |
The standardized international currency symbol. |
currency_symbol |
The local currency symbol. |
mon_decimal_point |
The decimal point character for currency values. |
mon_thousands_sep |
The separator for digit groups in currency values. |
mon_grouping |
Like grouping but for currency values. |
positive_sign |
The character used to denote nonnegative currency values, usually the empty string. |
negative_sign |
The character used to denote negative currency values, usually a minus sign. |
int_frac_digits |
The number of digits after the decimal point in an international-style currency value. |
frac_digits |
The number of digits after the decimal point in the locale style for currency values. |
p_cs_precedes |
True if the currency symbol precedes the currency value for nonnegative values, False if it follows. |
p_sep_by_space |
True if a space is inserted between the currency symbol and the currency value for nonnegative values, False otherwise. |
n_cs_precedes |
Like p_cs_precedes but for negative values. |
n_sep_by_space |
Like p_sep_by_space but for negative values. |
p_sign_posn |
The location of the positive_sign with respect to a nonnegative quantity and the currency_symbol, coded as follows:
|
n_sign_posn |
Like p_sign_posn but for negative currency values. |
int_p_cs_precedes |
Same as p_cs_precedes, but for internationally monetary quantities. formatted monetary quantities. |
int_n_cs_precedes |
Same as n_cs_precedes, but for internationally monetary quantities. formatted monetary quantities. |
int_p_sep_by_space |
Same as p_sep_by_space, but for internationally formatted monetary quantities. |
int_n_sep_by_space |
Same as n_sep_by_space, but for internationally formatted monetary quantities. |
int_p_sign_posn |
Same as p_sign_posn, but for internationally formatted monetary quantities. |
int_n_sign_posn |
Same as n_sign_posn, but for internationally formatted monetary quantities. |
Constants
Constant |
Description |
---|---|
LC_COLLATE_MASK |
Collation |
LC_CTYPE_MASK |
Character type |
LC_MESSAGES_MASK |
Messages |
LC_MONETARY_MASK |
Monetary |
LC_NUMERIC_MASK |
Numeric |
LC_TIME_MASK |
Time |
LC_ALL_MASK |
Combination of all of the above. |
Changelog
1.3.4 - February 25, 2018
More Python 3 compilation fixes.
1.3.3 - February 25, 2018
Python 3 has no PyInt.
1.3.2 - February 25, 2018
Fix handling of exceptions raised when creating a Locale: they are now correctly seen as being raised in the constructor.
1.3.1 - February 23, 2018
Add Python 3 support.
Add manylinux support.
1.2 - November 15, 2014
No longer return the current locale from Locale.use(). This created unsolvable double free problems.
1.1 - October 10, 2014
Fix a memory handling error in Locale.use() which could result in a segfault when using a locale instance multiple times.
1.0 - August 27, 2014
First release
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file xlocale-1.3.4.tar.gz
.
File metadata
- Download URL: xlocale-1.3.4.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d2949b2e248aca17f0f695fb2dd5cb439208510a1d6ef16f56ff88da8c1f0dd |
|
MD5 | 8efc0a0f4ba59dbce520baef20e59585 |
|
BLAKE2b-256 | 1633254885fa5b72964cde8508bfb0d770d99567a7209e28bcd75f2b6fd4d7c6 |
File details
Details for the file xlocale-1.3.4-cp36-cp36m-manylinux1_x86_64.whl
.
File metadata
- Download URL: xlocale-1.3.4-cp36-cp36m-manylinux1_x86_64.whl
- Upload date:
- Size: 25.8 kB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d673f9f914ff70053d367484532459ab17a653904a89b32088c401de936674a9 |
|
MD5 | 47ce0c9ca84c9f62979f5914b3688187 |
|
BLAKE2b-256 | f6e879a1674b9072de88446d5ba610d6e75ee93e172843362fa03ba5b5d23a63 |
File details
Details for the file xlocale-1.3.4-cp35-cp35m-manylinux1_x86_64.whl
.
File metadata
- Download URL: xlocale-1.3.4-cp35-cp35m-manylinux1_x86_64.whl
- Upload date:
- Size: 25.8 kB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a4715aaeec01027562f070c8b5760ec3b01a9bfa8582542f3e918e7d2d7d524 |
|
MD5 | 1d11cec6fe031a71bdcc9d064e0bd733 |
|
BLAKE2b-256 | 145f13ec96fcabd4a69b423b54c732c5edc55f3fc0ff294c387241987b449e83 |
File details
Details for the file xlocale-1.3.4-cp34-cp34m-manylinux1_x86_64.whl
.
File metadata
- Download URL: xlocale-1.3.4-cp34-cp34m-manylinux1_x86_64.whl
- Upload date:
- Size: 25.7 kB
- Tags: CPython 3.4m
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cefcb4db10b11e7b957a0ccb680d667b7171ffea6f6e1d977ff87cb3a6c7df0e |
|
MD5 | 685cfa591713b678c3cd857a9880e894 |
|
BLAKE2b-256 | 813ddc5012442f8b8192e750295e10064e48cab486f58328a43829c9395d25e6 |
File details
Details for the file xlocale-1.3.4-cp33-cp33m-manylinux1_x86_64.whl
.
File metadata
- Download URL: xlocale-1.3.4-cp33-cp33m-manylinux1_x86_64.whl
- Upload date:
- Size: 25.6 kB
- Tags: CPython 3.3m
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8e88466a5cddebc71dc9506691c5228a66750119fcac5346a08f1f60c9d95c9 |
|
MD5 | 75584d698d48514366906d4f2cd59b09 |
|
BLAKE2b-256 | 261db18003f6f342f7f7d1874daf11a00cd9fe208c77b31079673099aac67104 |
File details
Details for the file xlocale-1.3.4-cp27-cp27mu-manylinux1_x86_64.whl
.
File metadata
- Download URL: xlocale-1.3.4-cp27-cp27mu-manylinux1_x86_64.whl
- Upload date:
- Size: 25.6 kB
- Tags: CPython 2.7mu
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa7dd462349ae8b23a5b7f0f5b15024cc4dc8668af27a10ed23b980408eb9260 |
|
MD5 | a10286bd2ad1c760a17c6149bd93794a |
|
BLAKE2b-256 | bfbd59eb4fd4cbcbc131d277822aeebc0009e9518ef9fe45984133f2231685f2 |
File details
Details for the file xlocale-1.3.4-cp27-cp27m-manylinux1_x86_64.whl
.
File metadata
- Download URL: xlocale-1.3.4-cp27-cp27m-manylinux1_x86_64.whl
- Upload date:
- Size: 25.6 kB
- Tags: CPython 2.7m
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e81414534996daaae5af0f5d0d45abd6f2754d4f59daee20dafb86ff62e7f692 |
|
MD5 | e9b448dbba29d92c4a3e0dd4de233a5c |
|
BLAKE2b-256 | 4da5c65e3b1e48e5d145614fab7f44a28bb18efd24ed12a7257e7a119937a0d1 |