From 4e1b6d30dd1f2475c86f331314610938fa0a0afa Mon Sep 17 00:00:00 2001 From: Louis Date: Wed, 19 Feb 2014 11:31:19 +0100 Subject: [PATCH] Solving locale problems --- songbook.py | 6 +++++- songbook/plastex.py | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/songbook.py b/songbook.py index 08cf8e80..3fd2af2e 100755 --- a/songbook.py +++ b/songbook.py @@ -36,7 +36,11 @@ def argument_parser(args): def main(): # set script locale to match user's - locale.setlocale(locale.LC_ALL, '') + try: + locale.setlocale(locale.LC_ALL, '') + except locale.Error as error: + # Locale is not installed on user's system, or wrongly configured. + sys.stderr.write("Locale error: {}\n".format(error.message)) options = argument_parser(sys.argv[1:]) diff --git a/songbook/plastex.py b/songbook/plastex.py index f1065024..5ba9a55d 100755 --- a/songbook/plastex.py +++ b/songbook/plastex.py @@ -80,7 +80,8 @@ def parsetex(filename): doc = SongParser.parse(filename) # /* BEGIN plasTeX patch - locale.setlocale(locale.LC_TIME, "%s.%s" % oldlocale) + if oldlocale[0] and oldlocale[1]: + locale.setlocale(locale.LC_TIME, "%s.%s" % oldlocale) # plasTeX patch END */ # Extraction des données