Changeset 1856
- Timestamp:
- 10/20/04 16:29:30 (20 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/tool.py
r1851 r1856 22 22 # 23 23 # $Log$ 24 # Revision 1.135 2004/10/20 14:29:30 jalet 25 # Now logs something when locale settings are incorrect. 26 # 24 27 # Revision 1.134 2004/10/20 08:12:27 jalet 25 28 # Another fix for charset detection and Python2.3 … … 535 538 """Initializes the command line tool.""" 536 539 # locale stuff 540 defaultToCLocale = 0 537 541 try : 538 542 locale.setlocale(locale.LC_ALL, lang) 539 543 gettext.install("pykota") 540 544 except (locale.Error, IOError) : 545 locale.setlocale(locale.LC_ALL, "C") 546 defaultToCLocale = 1 541 547 gettext.NullTranslations().install() 542 548 … … 545 551 # Else we use the current locale's one. 546 552 # If nothing is set, we use ISO-8859-15 widely used in western Europe. 553 localecharset = None 547 554 try : 548 # preferred method with Python 2.3 and up549 localecharset = locale.getpreferredencoding()550 except AttributeError :551 localecharset = locale.getlocale()[1]552 555 try : 553 localecharset = localecharset or locale.getdefaultlocale()[1] 554 except ValueError : 555 pass # Unknown locale, strange... 556 # preferred method with Python 2.3 and up 557 localecharset = locale.getpreferredencoding() 558 except AttributeError : 559 localecharset = locale.getlocale()[1] 560 try : 561 localecharset = localecharset or locale.getdefaultlocale()[1] 562 except ValueError : 563 pass # Unknown locale, strange... 564 except locale.Error : 565 pass 556 566 self.charset = charset or os.environ.get("CHARSET") or localecharset or "ISO-8859-15" 557 567 … … 576 586 self.softwareJobSize = 0 577 587 self.softwareJobPrice = 0.0 588 if defaultToCLocale : 589 self.printInfo("Incorrect locale settings. PyKota falls back to the 'C' locale.", "warn") 578 590 self.logdebug("Charset in use : %s" % self.charset) 579 591