summaryrefslogtreecommitdiff
path: root/src/mailman/core/i18n.py
diff options
context:
space:
mode:
authorBarry Warsaw2016-03-24 21:29:30 -0400
committerBarry Warsaw2016-03-24 21:29:30 -0400
commit5404f98d90410d69a744d9c0fb71a8a31f3a4a88 (patch)
treebeb5010e4d74ab0f8056419dc05058fc2bbd8cc6 /src/mailman/core/i18n.py
parenta0cf7d44cbf0527d8bac05f870208a85689da42f (diff)
downloadmailman-5404f98d90410d69a744d9c0fb71a8a31f3a4a88.tar.gz
mailman-5404f98d90410d69a744d9c0fb71a8a31f3a4a88.tar.zst
mailman-5404f98d90410d69a744d9c0fb71a8a31f3a4a88.zip
Diffstat (limited to 'src/mailman/core/i18n.py')
-rw-r--r--src/mailman/core/i18n.py81
1 files changed, 8 insertions, 73 deletions
diff --git a/src/mailman/core/i18n.py b/src/mailman/core/i18n.py
index 28a231a97..ebe61894a 100644
--- a/src/mailman/core/i18n.py
+++ b/src/mailman/core/i18n.py
@@ -17,24 +17,23 @@
"""Internationalization."""
-__all__ = [
- '_',
- 'ctime',
- 'initialize',
- ]
-
-
-import time
import mailman.messages
from flufl.i18n import PackageStrategy, registry
from mailman.interfaces.configuration import ConfigurationUpdatedEvent
+# We can't use @mailman.public here because of circular imports.
+__all__ = [
+ '_',
+ 'handle_ConfigurationUpdatedEvent',
+ 'initialize',
+ ]
+
+
_ = None
-
def initialize(application=None):
"""Initialize the i18n subsystem.
@@ -50,70 +49,6 @@ def initialize(application=None):
_ = application._
-
-def ctime(date):
- """Translate a ctime.
-
- :param date: The date to translate.
- :type date: str or time float
- :return: The translated date.
- :rtype: string
- """
- # Don't make these module globals since we have to do runtime translation
- # of the strings anyway.
- daysofweek = [
- _('Mon'), _('Tue'), _('Wed'), _('Thu'),
- _('Fri'), _('Sat'), _('Sun')
- ]
- months = [
- '',
- _('Jan'), _('Feb'), _('Mar'), _('Apr'), _('May'), _('Jun'),
- _('Jul'), _('Aug'), _('Sep'), _('Oct'), _('Nov'), _('Dec')
- ]
-
- tzname = _('Server Local Time')
- if isinstance(date, str):
- try:
- year, mon, day, hh, mm, ss, wday, ydat, dst = time.strptime(date)
- if dst in (0, 1):
- tzname = time.tzname[dst]
- else:
- # MAS: No exception but dst = -1 so try
- return ctime(time.mktime((year, mon, day, hh, mm, ss, wday,
- ydat, dst)))
- except (ValueError, AttributeError):
- try:
- wday, mon, day, hms, year = date.split()
- hh, mm, ss = hms.split(':')
- year = int(year)
- day = int(day)
- hh = int(hh)
- mm = int(mm)
- ss = int(ss)
- except ValueError:
- return date
- else:
- for i in range(0, 7):
- wconst = (1999, 1, 1, 0, 0, 0, i, 1, 0)
- if wday.lower() == time.strftime('%a', wconst).lower():
- wday = i
- break
- for i in range(1, 13):
- mconst = (1999, i, 1, 0, 0, 0, 0, 1, 0)
- if mon.lower() == time.strftime('%b', mconst).lower():
- mon = i
- break
- else:
- year, mon, day, hh, mm, ss, wday, yday, dst = time.localtime(date)
- if dst in (0, 1):
- tzname = time.tzname[dst]
-
- wday = daysofweek[wday]
- mon = months[mon]
- return _('$wday $mon $day $hh:$mm:$ss $tzname $year')
-
-
-
def handle_ConfigurationUpdatedEvent(event):
if isinstance(event, ConfigurationUpdatedEvent):
_.default = event.config.mailman.default_language