mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
OS X build: Detect the users desired language correctly. Also fix parsing of ambiguous dates in mm/dd vs dd/mm formats, based on the users locale settings in OS X.
This commit is contained in:
parent
4060fa76b3
commit
8faaa8bbf5
@ -13,7 +13,7 @@ from functools import partial
|
|||||||
from dateutil.tz import tzlocal, tzutc, EPOCHORDINAL
|
from dateutil.tz import tzlocal, tzutc, EPOCHORDINAL
|
||||||
|
|
||||||
from calibre import strftime
|
from calibre import strftime
|
||||||
from calibre.constants import iswindows
|
from calibre.constants import iswindows, isosx, plugins
|
||||||
from calibre.utils.localization import lcdata
|
from calibre.utils.localization import lcdata
|
||||||
|
|
||||||
class SafeLocalTimeZone(tzlocal):
|
class SafeLocalTimeZone(tzlocal):
|
||||||
@ -68,6 +68,12 @@ if iswindows:
|
|||||||
except:
|
except:
|
||||||
parse_date_day_first = False
|
parse_date_day_first = False
|
||||||
del ctypes, LOCALE_SSHORTDATE, buf, LOCALE_USER_DEFAULT
|
del ctypes, LOCALE_SSHORTDATE, buf, LOCALE_USER_DEFAULT
|
||||||
|
elif isosx:
|
||||||
|
try:
|
||||||
|
date_fmt = plugins['usbobserver'][0].date_format()
|
||||||
|
parse_date_day_first = date_fmt.index(u'd') < date_fmt.index(u'M')
|
||||||
|
except:
|
||||||
|
parse_date_day_first = False
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
def first_index(raw, queries):
|
def first_index(raw, queries):
|
||||||
|
@ -23,7 +23,7 @@ def available_translations():
|
|||||||
return _available_translations
|
return _available_translations
|
||||||
|
|
||||||
def get_system_locale():
|
def get_system_locale():
|
||||||
from calibre.constants import iswindows
|
from calibre.constants import iswindows, isosx, plugins
|
||||||
lang = None
|
lang = None
|
||||||
if iswindows:
|
if iswindows:
|
||||||
try:
|
try:
|
||||||
@ -34,6 +34,13 @@ def get_system_locale():
|
|||||||
lang = None
|
lang = None
|
||||||
except:
|
except:
|
||||||
pass # Windows XP does not have the GetUserDefaultLocaleName fn
|
pass # Windows XP does not have the GetUserDefaultLocaleName fn
|
||||||
|
elif isosx:
|
||||||
|
try:
|
||||||
|
lang = plugins['usbobserver'][0].user_locale() or None
|
||||||
|
except:
|
||||||
|
# Fallback to environment vars if something bad happened
|
||||||
|
import traceback
|
||||||
|
traceback.print_exc()
|
||||||
if lang is None:
|
if lang is None:
|
||||||
try:
|
try:
|
||||||
lang = locale.getdefaultlocale(['LANGUAGE', 'LC_ALL', 'LC_CTYPE',
|
lang = locale.getdefaultlocale(['LANGUAGE', 'LC_ALL', 'LC_CTYPE',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user