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 calibre import strftime
|
||||
from calibre.constants import iswindows
|
||||
from calibre.constants import iswindows, isosx, plugins
|
||||
from calibre.utils.localization import lcdata
|
||||
|
||||
class SafeLocalTimeZone(tzlocal):
|
||||
@ -68,6 +68,12 @@ if iswindows:
|
||||
except:
|
||||
parse_date_day_first = False
|
||||
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:
|
||||
try:
|
||||
def first_index(raw, queries):
|
||||
|
@ -23,7 +23,7 @@ def available_translations():
|
||||
return _available_translations
|
||||
|
||||
def get_system_locale():
|
||||
from calibre.constants import iswindows
|
||||
from calibre.constants import iswindows, isosx, plugins
|
||||
lang = None
|
||||
if iswindows:
|
||||
try:
|
||||
@ -34,6 +34,13 @@ def get_system_locale():
|
||||
lang = None
|
||||
except:
|
||||
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:
|
||||
try:
|
||||
lang = locale.getdefaultlocale(['LANGUAGE', 'LC_ALL', 'LC_CTYPE',
|
||||
|
Loading…
x
Reference in New Issue
Block a user