1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/lib/locale.py Sun Dec 11 18:07:32 2016 +0100
1.3 @@ -0,0 +1,55 @@
1.4 +#!/usr/bin/env python
1.5 +
1.6 +"""
1.7 +Locale functions.
1.8 +
1.9 +Copyright (C) 2016 Paul Boddie <paul@boddie.org.uk>
1.10 +
1.11 +This program is free software; you can redistribute it and/or modify it under
1.12 +the terms of the GNU General Public License as published by the Free Software
1.13 +Foundation; either version 3 of the License, or (at your option) any later
1.14 +version.
1.15 +
1.16 +This program is distributed in the hope that it will be useful, but WITHOUT
1.17 +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1.18 +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1.19 +details.
1.20 +
1.21 +You should have received a copy of the GNU General Public License along with
1.22 +this program. If not, see <http://www.gnu.org/licenses/>.
1.23 +"""
1.24 +
1.25 +from __builtins__.types import check_int, check_string
1.26 +from native import getlocale as _getlocale, setlocale as _setlocale
1.27 +
1.28 +LC_CTYPE = 0
1.29 +LC_NUMERIC = 1
1.30 +LC_TIME = 2
1.31 +LC_COLLATE = 3
1.32 +LC_MONETARY = 4
1.33 +LC_MESSAGES = 5
1.34 +LC_ALL = 6
1.35 +
1.36 +def setlocale(category, value):
1.37 +
1.38 + "Set the locale for 'category' to 'value'."
1.39 +
1.40 + check_int(category)
1.41 + check_string(value)
1.42 + return _setlocale(category, value)
1.43 +
1.44 +def getlocale(category=LC_CTYPE):
1.45 +
1.46 + "Return the locale value for 'category'."
1.47 +
1.48 + check_int(category)
1.49 + return _getlocale(category)
1.50 +
1.51 +def initlocale(category=LC_CTYPE):
1.52 +
1.53 + "Initialise the locale for 'category' from the environment."
1.54 +
1.55 + check_int(category)
1.56 + return _setlocale(category, "")
1.57 +
1.58 +# vim: tabstop=4 expandtab shiftwidth=4