Opened 9 years ago
Last modified 9 years ago
#12202 closed defect
Mismatch datetime separator in datetime picker for several locales — at Initial Version
Reported by: | Jun Omae | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | 1.0.9 |
Component: | i18n | Version: | 1.0-stable |
Severity: | normal | Keywords: | datetimepicker |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
Originally reported in [50289f02/rjollos.git].
timepicker_separator
is always ' '
when iso8601 format isn't configured. However, date/time separator isn't a space character for several locales.
>>> import babel >>> babel.__version__ '0.9.6' >>> from babel.dates import get_datetime_format >>> from trac.util.translation import get_available_locales >>> fmts = {} >>> for locale_id in sorted(get_available_locales()): ... fmt = get_datetime_format('medium', locale_id) ... fmts.setdefault(fmt, []).append(locale_id) ... >>> for fmt in fmts: ... print('%r => %s' % (fmt, ' '.join(fmts[fmt]))) ... u'{1} {0}' => ca cs da de el en_GB en_US eo es es_AR es_MX et fi fr gl he hu hy it ja ko nb nl pl pt pt_BR ru sl sv tr uk zh_CN zh_TW u'{1}, {0}' => ro
>>> babel.__version__ '1.3' >>> from babel.dates import get_datetime_format >>> from trac.util.translation import get_available_locales >>> fmts = {} >>> for locale_id in sorted(get_available_locales()): ... fmt = get_datetime_format('medium', locale_id) ... fmts.setdefault(fmt, []).append(locale_id) ... >>> fmts {u'{0} {1}': ['nb'], u'{1} {0}': ['ca', 'cs', 'da', 'de', 'en_GB', 'eo', 'es', 'es_AR', 'es_MX', 'et', 'fi', 'fr', 'gl', 'hu', 'it', 'ja', 'ko', 'nl', 'pt', 'pt_BR', 'sl', 'sv', 'tr', 'uk', 'zh_CN', 'zh_TW'], u'{1}, {0}': ['en_US', 'he', 'hy', 'pl', 'ro', 'ru'], u'{1} - {0}': ['el']} >>> for fmt in fmts: ... print('%r => %s' % (fmt, ' '.join(fmts[fmt]))) ... u'{0} {1}' => nb u'{1} {0}' => ca cs da de en_GB eo es es_AR es_MX et fi fr gl hu it ja ko nl pt pt_BR sl sv tr uk zh_CN zh_TW u'{1}, {0}' => en_US he hy pl ro ru u'{1} - {0}' => el
Proposed changes:
-
trac/util/datefmt.py
diff --git a/trac/util/datefmt.py b/trac/util/datefmt.py index 7058c0e26..cd78fc712 100644
a b def get_first_week_day_jquery_ui(req): 401 401 return (locale.first_week_day + 1) % 7 402 402 return 0 # Sunday 403 403 404 def get_timepicker_separator_jquery_ui(req): 405 locale = req.lc_time 406 if locale == 'iso8601': 407 return 'T' 408 if babel and locale: 409 return get_datetime_format('medium', locale=locale) \ 410 .replace('{0}', '').replace('{1}', '') 411 return ' ' 412 404 413 def is_24_hours(locale): 405 414 """Returns `True` for 24 hour time formats.""" 406 415 if locale == 'iso8601': -
trac/web/chrome.py
diff --git a/trac/web/chrome.py b/trac/web/chrome.py index dd9c3b8ed..7bd875e80 100644
a b from trac.util.datefmt import ( 59 59 from_utimestamp, http_date, utc, get_date_format_jquery_ui, is_24_hours, 60 60 get_time_format_jquery_ui, user_time, get_month_names_jquery_ui, 61 61 get_day_names_jquery_ui, get_timezone_list_jquery_ui, 62 get_first_week_day_jquery_ui )62 get_first_week_day_jquery_ui, get_timepicker_separator_jquery_ui) 63 63 from trac.util.translation import _, get_available_locales 64 64 from trac.web.api import IRequestHandler, ITemplateStreamFilter, HTTPNotFound 65 65 from trac.web.href import Href … … class Chrome(Component): 1276 1276 'time_format': get_time_format_jquery_ui(req.lc_time), 1277 1277 'ampm': not is_24_hours(req.lc_time), 1278 1278 'first_week_day': get_first_week_day_jquery_ui(req), 1279 'timepicker_separator': 'T' if is_iso8601 else ' ',1279 'timepicker_separator': get_timepicker_separator_jquery_ui(req), 1280 1280 'show_timezone': is_iso8601, 1281 1281 # default timezone must be included 1282 1282 'timezone_list': get_timezone_list_jquery_ui() \
Note:
See TracTickets
for help on using tickets.