diff --git a/CHANGELOG b/CHANGELOG
index 8d46a20780..e7011f38a3 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,4 @@
+* Add ir.calendar for month and day
* Rename languages: hu_HU, it_IT and pt_BR into hu, it and pt
* Define custom exceptions
* Remove _error_messages, raise_user_error and raise_user_warning
diff --git a/trytond/ir/__init__.py b/trytond/ir/__init__.py
index f2cabbb2e0..04af63e8b8 100644
--- a/trytond/ir/__init__.py
+++ b/trytond/ir/__init__.py
@@ -21,6 +21,7 @@ from .date import *
from .trigger import *
from .session import *
from . import queue
+from . import calendar_
from . import message
@@ -88,6 +89,8 @@ def register():
Session,
SessionWizard,
queue.Queue,
+ calendar_.Month,
+ calendar_.Day,
message.Message,
module='ir', type_='model')
Pool.register(
diff --git a/trytond/ir/calendar_.py b/trytond/ir/calendar_.py
new file mode 100644
index 0000000000..76b8cecac3
--- /dev/null
+++ b/trytond/ir/calendar_.py
@@ -0,0 +1,59 @@
+# This file is part of Tryton. The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
+
+from ..cache import Cache
+from ..model import ModelSQL, fields, Unique
+from ..transaction import Transaction
+
+
+class _Calendar(ModelSQL):
+ index = fields.Integer("Index", required=True)
+ name = fields.Char("Name", required=True, translate=True)
+ abbreviation = fields.Char("Abbreviation", required=True, translate=True)
+
+ @classmethod
+ def __setup__(cls):
+ super().__setup__()
+ t = cls.__table__()
+ cls.index.domain = [
+ ('index', '>=', cls._min_index),
+ ('index', '<=', cls._max_index),
+ ]
+ cls._order = [('index', 'ASC')]
+ cls._sql_constraints = [
+ ('index_unique', Unique(t, t.index),
+ "The index must by unique.")
+ ]
+
+ @classmethod
+ def locale(cls, language=None, field='name'):
+ transaction = Transaction()
+ if language is None:
+ language = transaction.language
+ elif isinstance(language, ModelSQL):
+ language = language.code
+ key = (language, field)
+ result = cls._cache_locale.get(key)
+ if not result:
+ with transaction.set_context(language=language):
+ records = cls.search([])
+ result = [None] * cls._min_index
+ result += [getattr(r, field) for r in records]
+ cls._cache_locale.set(key, result)
+ return result
+
+
+class Month(_Calendar):
+ "Month"
+ __name__ = 'ir.calendar.month'
+ _min_index = 1
+ _max_index = 12
+ _cache_locale = Cache('ir.calendar.month')
+
+
+class Day(_Calendar):
+ "Day"
+ __name__ = 'ir.calendar.day'
+ _min_index = 0
+ _max_index = 6
+ _cache_locale = Cache('ir.calendar.day')
diff --git a/trytond/ir/calendar_.xml b/trytond/ir/calendar_.xml
new file mode 100644
index 0000000000..91b7cc5294
--- /dev/null
+++ b/trytond/ir/calendar_.xml
@@ -0,0 +1,103 @@
+
+
+
+
+
+
+ January
+ Jan
+
+
+
+ February
+ Feb
+
+
+
+ March
+ Mar
+
+
+
+ April
+ Apr
+
+
+
+ May
+ May
+
+
+
+ June
+ Jun
+
+
+
+ July
+ Jul
+
+
+
+ August
+ Aug
+
+
+
+ September
+ Sep
+
+
+
+ October
+ Oct
+
+
+
+ November
+ Nov
+
+
+
+ December
+ Dec
+
+
+
+
+ Monday
+ Mon
+
+
+
+ Tuesday
+ Tue
+
+
+
+ Wednesday
+ Wed
+
+
+
+ Thursday
+ Thu
+
+
+
+ Friday
+ Fri
+
+
+
+ Saturday
+ Sat
+
+
+
+ Sunday
+ Sun
+
+
+
diff --git a/trytond/ir/gen_time_locale.py b/trytond/ir/gen_time_locale.py
deleted file mode 100644
index bd5e403f8c..0000000000
--- a/trytond/ir/gen_time_locale.py
+++ /dev/null
@@ -1,57 +0,0 @@
-# This file is part of Tryton. The COPYRIGHT file at the top level of
-# this repository contains the full copyright notices and license terms.
-import os
-import pprint
-import time
-
-from lxml import etree
-
-from . import locale
-
-
-def locale_strftime(lang):
- time_locale = {
- '%a': [],
- '%A': [],
- '%b': [None],
- '%B': [None],
- '%p': [],
- }
- locale.setlocale(locale.LC_ALL, locale.normalize(lang + '.UTF_8'))
- t = list(time.gmtime())
- for i in range(12):
- t[1] = i + 1
- for format in ('%b', '%B'):
- time_locale[format].append(time.strftime(format,
- t).decode('utf-8'))
- for i in range(7):
- t[6] = i
- for format in ('%a', '%A'):
- time_locale[format].append(time.strftime(format,
- t).decode('utf-8'))
- t[3] = 0
- time_locale['%p'].append(time.strftime('%p', t).decode('utf-8'))
- t[3] = 23
- time_locale['%p'].append(time.strftime('%p', t).decode('utf-8'))
- return time_locale
-
-
-if __name__ == '__main__':
- base = os.path.dirname(__file__)
- # Add en as it is not defined in lang.xml
- time_locale = {
- 'en': locale_strftime('en'),
- }
- with open(os.path.join(base, 'lang.xml'), 'rb') as fp:
- lang_xml = etree.parse(fp)
- for el in lang_xml.xpath('//field[@name="code"]'):
- lang = el.text[:2]
- time_locale[lang] = locale_strftime(lang)
- with open(os.path.join(base, 'time_locale.py'), 'w') as fp:
- fp.write('''# -*- coding: utf-8 -*-
-# This file is part of Tryton. The COPYRIGHT file at the top level of')
-# this repository contains the full copyright notices and license terms.')
-''')
- fp.write('TIME_LOCALE = \\\n')
- pp = pprint.PrettyPrinter(stream=fp)
- pp.pprint(time_locale)
diff --git a/trytond/ir/ir.xml b/trytond/ir/ir.xml
index b0068ddfb1..8df2a5a59d 100644
--- a/trytond/ir/ir.xml
+++ b/trytond/ir/ir.xml
@@ -11,6 +11,8 @@ this repository contains the full copyright notices and license terms. -->
en
English
%m/%d/%Y
+ AM
+ PM
[3, 3, 0]
.
,
diff --git a/trytond/ir/lang.py b/trytond/ir/lang.py
index 2938d4e854..fc23a6bafd 100644
--- a/trytond/ir/lang.py
+++ b/trytond/ir/lang.py
@@ -16,7 +16,6 @@ from ..transaction import Transaction
from ..pool import Pool
from ..exceptions import UserError
from ..i18n import gettext
-from .time_locale import TIME_LOCALE
Transaction.cache_keys.add('translate_name')
@@ -57,6 +56,9 @@ class Lang(DeactivableMixin, ModelSQL, ModelView):
# date
date = fields.Char('Date', required=True)
+ am = fields.Char("AM")
+ pm = fields.Char("PM")
+
# number
grouping = fields.Char('Grouping', required=True)
decimal_point = fields.Char('Decimal Separator', required=True)
@@ -473,21 +475,35 @@ class Lang(DeactivableMixin, ModelSQL, ModelView):
return s.replace('<', '').replace('>', '')
- def strftime(self, datetime, format=None):
+ def strftime(self, value, format=None):
'''
- Convert datetime to a string as specified by the format argument.
+ Convert value to a string as specified by the format argument.
'''
+ pool = Pool()
+ Month = pool.get('ir.calendar.month')
+ Day = pool.get('ir.calendar.day')
if format is None:
format = self.date
- code = self.code[:2]
- if code in TIME_LOCALE:
- for f, i in (('%a', 6), ('%A', 6), ('%b', 1), ('%B', 1)):
- format = format.replace(f,
- TIME_LOCALE[code][f][datetime.timetuple()[i]])
- format = format.replace('%p',
- TIME_LOCALE[code]['%p'][datetime.timetuple()[3] < 12 and 0
- or 1])
- return datetime.strftime(format)
+ format = format.replace('%x', self.date)
+ if isinstance(value, datetime.date):
+ for f, i, klass in (('%A', 6, Day), ('%B', 1, Month)):
+ for field, f in [('name', f), ('abbreviation', f.lower())]:
+ locale = klass.locale(self, field=field)
+ format = format.replace(f, locale[value.timetuple()[i]])
+ if isinstance(value, datetime.time):
+ time = value
+ else:
+ try:
+ time = value.time()
+ except AttributeError:
+ time = None
+ if time:
+ if time < datetime.time(12):
+ p = self.am or 'AM'
+ else:
+ p = self.pm or 'PM'
+ format = format.replace('%p', p)
+ return value.strftime(format)
def get_parent_language(code):
diff --git a/trytond/ir/lang.xml b/trytond/ir/lang.xml
index 1ae648a67d..e6858f2f47 100644
--- a/trytond/ir/lang.xml
+++ b/trytond/ir/lang.xml
@@ -9,6 +9,8 @@ this repository contains the full copyright notices and license terms. -->
bg
Bulgarian
%d.%m.%Y
+
+
[3, 3, 0]
,
.
@@ -28,6 +30,8 @@ this repository contains the full copyright notices and license terms. -->
ca
Català
%d/%m/%Y
+ a. m.
+ p. m.
[3, 3, 0]
,
@@ -47,6 +51,8 @@ this repository contains the full copyright notices and license terms. -->
cs
Czech
%d.%m.%Y
+
+
[3, 3, 0]
,
@@ -66,6 +72,8 @@ this repository contains the full copyright notices and license terms. -->
de
German
%d.%m.%Y
+
+
[3, 3, 0]
,
.
@@ -88,6 +96,8 @@ this repository contains the full copyright notices and license terms. -->
es
Spanish
%d/%m/%Y
+
+
[3, 3, 0]
,
.
@@ -107,6 +117,8 @@ this repository contains the full copyright notices and license terms. -->
es_419
Spanish (Latin American)
%d/%m/%Y
+
+
[3, 3, 0]
.
,
@@ -127,6 +139,8 @@ this repository contains the full copyright notices and license terms. -->
Persian
rtl
%Y/%m/%d
+
+
[3, 0]
.
,
@@ -146,6 +160,8 @@ this repository contains the full copyright notices and license terms. -->
fr
French
%d.%m.%Y
+
+
[3, 0]
,
@@ -165,6 +181,8 @@ this repository contains the full copyright notices and license terms. -->
hu
Hungarian
%Y-%m-%d
+
+
[3, 3, 0]
,
.
@@ -184,6 +202,8 @@ this repository contains the full copyright notices and license terms. -->
it
Italian
%d/%m/%Y
+
+
[3, 3, 0]
,
.
@@ -203,6 +223,8 @@ this repository contains the full copyright notices and license terms. -->
lo
Lao
%d/%m/%Y
+ AM
+ PM
[3, 3, 0]
.
,
@@ -222,6 +244,8 @@ this repository contains the full copyright notices and license terms. -->
lt
Lithuanian
%Y-%m-%d
+
+
[3, 3, 0]
,
@@ -241,6 +265,8 @@ this repository contains the full copyright notices and license terms. -->
nl
Dutch
%d-%m-%Y
+
+
[3, 3, 0]
,
.
@@ -260,6 +286,8 @@ this repository contains the full copyright notices and license terms. -->
pl
Polish
%d.%m.%Y
+
+
,
[3, 3, 0]
@@ -278,6 +306,8 @@ this repository contains the full copyright notices and license terms. -->
pt
Portuguese
%d-%m-%Y
+
+
[]
,
@@ -297,6 +327,8 @@ this repository contains the full copyright notices and license terms. -->
ru
Russian
%d.%m.%Y
+
+
[3, 3, 0]
,
@@ -316,6 +348,8 @@ this repository contains the full copyright notices and license terms. -->
sl
Slovenian
%d.%m.%Y
+
+
[3, 3, 0]
,
.
@@ -335,6 +369,8 @@ this repository contains the full copyright notices and license terms. -->
zh_CN
Chinese Simplified
%Y-%m-%d
+ 上午
+ 下午
[3, 0]
.
,
diff --git a/trytond/ir/time_locale.py b/trytond/ir/time_locale.py
deleted file mode 100644
index 0f178ec2b3..0000000000
--- a/trytond/ir/time_locale.py
+++ /dev/null
@@ -1,588 +0,0 @@
-# -*- coding: utf-8 -*-
-# This file is part of Tryton. The COPYRIGHT file at the top level of')
-# this repository contains the full copyright notices and license terms.')
-TIME_LOCALE = \
-{'bg': {'%A': ['\u043f\u043e\u043d\u0435\u0434\u0435\u043b\u043d\u0438\u043a',
- '\u0432\u0442\u043e\u0440\u043d\u0438\u043a',
- '\u0441\u0440\u044f\u0434\u0430',
- '\u0447\u0435\u0442\u0432\u044a\u0440\u0442\u044a\u043a',
- '\u043f\u0435\u0442\u044a\u043a',
- '\u0441\u044a\u0431\u043e\u0442\u0430',
- '\u043d\u0435\u0434\u0435\u043b\u044f'],
- '%B': [None,
- '\u044f\u043d\u0443\u0430\u0440\u0438',
- '\u0444\u0435\u0432\u0440\u0443\u0430\u0440\u0438',
- '\u043c\u0430\u0440\u0442',
- '\u0430\u043f\u0440\u0438\u043b',
- '\u043c\u0430\u0439',
- '\u044e\u043d\u0438',
- '\u044e\u043b\u0438',
- '\u0430\u0432\u0433\u0443\u0441\u0442',
- '\u0441\u0435\u043f\u0442\u0435\u043c\u0432\u0440\u0438',
- '\u043e\u043a\u0442\u043e\u043c\u0432\u0440\u0438',
- '\u043d\u043e\u0435\u043c\u0432\u0440\u0438',
- '\u0434\u0435\u043a\u0435\u043c\u0432\u0440\u0438'],
- '%a': ['\u043f\u043d',
- '\u0432\u0442',
- '\u0441\u0440',
- '\u0447\u0442',
- '\u043f\u0442',
- '\u0441\u0431',
- '\u043d\u0434'],
- '%b': [None,
- '\u044f\u043d\u0443',
- '\u0444\u0435\u0432',
- '\u043c\u0430\u0440',
- '\u0430\u043f\u0440',
- '\u043c\u0430\u0439',
- '\u044e\u043d\u0438',
- '\u044e\u043b\u0438',
- '\u0430\u0432\u0433',
- '\u0441\u0435\u043f',
- '\u043e\u043a\u0442',
- '\u043d\u043e\u0435',
- '\u0434\u0435\u043a'],
- '%p': ['', '']},
- 'ca': {'%A': ['dilluns',
- 'dimarts',
- 'dimecres',
- 'dijous',
- 'divendres',
- 'dissabte',
- 'diumenge'],
- '%B': [None,
- 'gener',
- 'febrer',
- 'mar\xe7',
- 'abril',
- 'maig',
- 'juny',
- 'juliol',
- 'agost',
- 'setembre',
- 'octubre',
- 'novembre',
- 'desembre'],
- '%a': ['dl', 'dt', 'dc', 'dj', 'dv', 'ds', 'dg'],
- '%b': [None,
- 'gen',
- 'feb',
- 'mar',
- 'abr',
- 'mai',
- 'jun',
- 'jul',
- 'ago',
- 'set',
- 'oct',
- 'nov',
- 'des'],
- '%p': ['', '']},
- 'cs': {'%A': ['Pond\u011bl\xed',
- '\xdater\xfd',
- 'St\u0159eda',
- '\u010ctvrtek',
- 'P\xe1tek',
- 'Sobota',
- 'Ned\u011ble'],
- '%B': [None,
- 'leden',
- '\xfanor',
- 'b\u0159ezen',
- 'duben',
- 'kv\u011bten',
- '\u010derven',
- '\u010dervenec',
- 'srpen',
- 'z\xe1\u0159\xed',
- '\u0159\xedjen',
- 'listopad',
- 'prosinec'],
- '%a': ['Po', '\xdat', 'St', '\u010ct', 'P\xe1', 'So', 'Ne'],
- '%b': [None,
- 'led',
- '\xfano',
- 'b\u0159e',
- 'dub',
- 'kv\u011b',
- '\u010den',
- '\u010dec',
- 'srp',
- 'z\xe1\u0159',
- '\u0159\xedj',
- 'lis',
- 'pro'],
- '%p': ['', '']},
- 'de': {'%A': ['Montag',
- 'Dienstag',
- 'Mittwoch',
- 'Donnerstag',
- 'Freitag',
- 'Samstag',
- 'Sonntag'],
- '%B': [None,
- 'Januar',
- 'Februar',
- 'M\xe4rz',
- 'April',
- 'Mai',
- 'Juni',
- 'Juli',
- 'August',
- 'September',
- 'Oktober',
- 'November',
- 'Dezember'],
- '%a': ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So'],
- '%b': [None,
- 'Jan',
- 'Feb',
- 'M\xe4r',
- 'Apr',
- 'Mai',
- 'Jun',
- 'Jul',
- 'Aug',
- 'Sep',
- 'Okt',
- 'Nov',
- 'Dez'],
- '%p': ['', '']},
- 'en': {'%A': ['Monday',
- 'Tuesday',
- 'Wednesday',
- 'Thursday',
- 'Friday',
- 'Saturday',
- 'Sunday'],
- '%B': [None,
- 'January',
- 'February',
- 'March',
- 'April',
- 'May',
- 'June',
- 'July',
- 'August',
- 'September',
- 'October',
- 'November',
- 'December'],
- '%a': ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
- '%b': [None,
- 'Jan',
- 'Feb',
- 'Mar',
- 'Apr',
- 'May',
- 'Jun',
- 'Jul',
- 'Aug',
- 'Sep',
- 'Oct',
- 'Nov',
- 'Dec'],
- '%p': ['AM', 'PM']},
- 'es': {'%A': ['lunes',
- 'martes',
- 'mi\xe9rcoles',
- 'jueves',
- 'viernes',
- 's\xe1bado',
- 'domingo'],
- '%B': [None,
- 'enero',
- 'febrero',
- 'marzo',
- 'abril',
- 'mayo',
- 'junio',
- 'julio',
- 'agosto',
- 'septiembre',
- 'octubre',
- 'noviembre',
- 'diciembre'],
- '%a': ['lun', 'mar', 'mi\xe9', 'jue', 'vie', 's\xe1b', 'dom'],
- '%b': [None,
- 'ene',
- 'feb',
- 'mar',
- 'abr',
- 'may',
- 'jun',
- 'jul',
- 'ago',
- 'sep',
- 'oct',
- 'nov',
- 'dic'],
- '%p': ['', '']},
- 'fr': {'%A': ['lundi',
- 'mardi',
- 'mercredi',
- 'jeudi',
- 'vendredi',
- 'samedi',
- 'dimanche'],
- '%B': [None,
- 'janvier',
- 'f\xe9vrier',
- 'mars',
- 'avril',
- 'mai',
- 'juin',
- 'juillet',
- 'ao\xfbt',
- 'septembre',
- 'octobre',
- 'novembre',
- 'd\xe9cembre'],
- '%a': ['lun.', 'mar.', 'mer.', 'jeu.', 'ven.', 'sam.', 'dim.'],
- '%b': [None,
- 'janv.',
- 'f\xe9vr.',
- 'mars',
- 'avril',
- 'mai',
- 'juin',
- 'juil.',
- 'ao\xfbt',
- 'sept.',
- 'oct.',
- 'nov.',
- 'd\xe9c.'],
- '%p': ['', '']},
- 'hu': {'%A': ['h\xe9tf\u0151',
- 'kedd',
- 'szerda',
- 'cs\xfct\xf6rt\xf6k',
- 'p\xe9ntek',
- 'szombat',
- 'vas\xe1rnap'],
- '%B': [None,
- 'janu\xe1r',
- 'febru\xe1r',
- 'm\xe1rcius',
- '\xe1prilis',
- 'm\xe1jus',
- 'j\xfanius',
- 'j\xfalius',
- 'augusztus',
- 'szeptember',
- 'okt\xf3ber',
- 'november',
- 'december'],
- '%a': ['h', 'k', 'sze', 'cs', 'p', 'szo', 'v'],
- '%b': [None,
- 'jan',
- 'febr',
- 'm\xe1rc',
- '\xe1pr',
- 'm\xe1j',
- 'j\xfan',
- 'j\xfal',
- 'aug',
- 'szept',
- 'okt',
- 'nov',
- 'dec'],
- '%p': ['', '']},
- 'it': {'%A': ['luned\xec',
- 'marted\xec',
- 'mercoled\xec',
- 'gioved\xec',
- 'venerd\xec',
- 'sabato',
- 'domenica'],
- '%B': [None,
- 'gennaio',
- 'febbraio',
- 'marzo',
- 'aprile',
- 'maggio',
- 'giugno',
- 'luglio',
- 'agosto',
- 'settembre',
- 'ottobre',
- 'novembre',
- 'dicembre'],
- '%a': ['lun', 'mar', 'mer', 'gio', 'ven', 'sab', 'dom'],
- '%b': [None,
- 'gen',
- 'feb',
- 'mar',
- 'apr',
- 'mag',
- 'giu',
- 'lug',
- 'ago',
- 'set',
- 'ott',
- 'nov',
- 'dic'],
- '%p': ['', '']},
- 'lo': {'%A': ['\u0e88\u0eb1\u0e99',
- '\u0ead\u0eb1\u0e87\u0e84\u0eb2\u0e99',
- '\u0e9e\u0eb8\u0e94',
- '\u0e9e\u0eb0\u0eab\u0eb1\u0e94',
- '\u0eaa\u0eb8\u0e81',
- '\u0ec0\u0eaa\u0ebb\u0eb2',
- '\u0ead\u0eb2\u0e97\u0eb4\u0e94'],
- '%B': [None,
- '\u0ea1\u0eb1\u0e87\u0e81\u0ead\u0e99',
- '\u0e81\u0eb8\u0ea1\u0e9f\u0eb2',
- '\u0ea1\u0eb5\u0e99\u0eb2',
- '\u0ec0\u0ea1\u0eaa\u0eb2',
- '\u0e9e\u0eb6\u0e94\u0eaa\u0eb0\u0e9e\u0eb2',
- '\u0ea1\u0eb4\u0e96\u0eb8\u0e99\u0eb2',
- '\u0e81\u0ecd\u0ea5\u0eb0\u0e81\u0ebb\u0e94',
- '\u0eaa\u0eb4\u0e87\u0eab\u0eb2',
- '\u0e81\u0eb1\u0e99\u0e8d\u0eb2',
- '\u0e95\u0eb8\u0ea5\u0eb2',
- '\u0e9e\u0eb0\u0e88\u0eb4\u0e81',
- '\u0e97\u0eb1\u0e99\u0ea7\u0eb2'],
- '%a': ['\u0e88.',
- '\u0e84.',
- '\u0e9e.',
- '\u0e9e\u0eab.',
- '\u0eaa.',
- '\u0eaa.',
- '\u0ead\u0eb2.'],
- '%b': [None,
- '\u0ea1.\u0e81.',
- '\u0e81.\u0e9e.',
- '\u0ea1.\u0e99.',
- '\u0ea1.\u0eaa.',
- '\u0e9e.\u0e9e.',
- '\u0ea1\u0eb4.\u0e96.',
- '\u0e81.\u0ea5.',
- '\u0eaa.\u0eab.',
- '\u0e81.\u0e8d.',
- '\u0e95.\u0ea5.',
- '\u0e9e.\u0e88.',
- '\u0e97.\u0ea7.'],
- '%p': ['AM', 'PM']},
- 'lt': {'%A': ['Pirmadienis',
- 'Antradienis',
- 'Tre\u010diadienis',
- 'Ketvirtadienis',
- 'Penktadienis',
- '\u0160e\u0161tadienis',
- 'Sekmadienis'],
- '%B': [None,
- 'sausio',
- 'vasario',
- 'kovo',
- 'baland\u017eio',
- 'gegu\u017e\u0117s',
- 'bir\u017eelio',
- 'liepos',
- 'rugpj\u016b\u010dio',
- 'rugs\u0117jo',
- 'spalio',
- 'lapkri\u010dio',
- 'gruod\u017eio'],
- '%a': ['Pr', 'An', 'Tr', 'Kt', 'Pn', '\u0160t', 'Sk'],
- '%b': [None,
- 'Sau',
- 'Vas',
- 'Kov',
- 'Bal',
- 'Geg',
- 'Bir',
- 'Lie',
- 'Rgp',
- 'Rgs',
- 'Spa',
- 'Lap',
- 'Grd'],
- '%p': ['', '']},
- 'nl': {'%A': ['maandag',
- 'dinsdag',
- 'woensdag',
- 'donderdag',
- 'vrijdag',
- 'zaterdag',
- 'zondag'],
- '%B': [None,
- 'januari',
- 'februari',
- 'maart',
- 'april',
- 'mei',
- 'juni',
- 'juli',
- 'augustus',
- 'september',
- 'oktober',
- 'november',
- 'december'],
- '%a': ['ma', 'di', 'wo', 'do', 'vr', 'za', 'zo'],
- '%b': [None,
- 'jan',
- 'feb',
- 'mrt',
- 'apr',
- 'mei',
- 'jun',
- 'jul',
- 'aug',
- 'sep',
- 'okt',
- 'nov',
- 'dec'],
- '%p': ['', '']},
- 'pt': {'%A': ['Segunda',
- 'Ter\xe7a',
- 'Quarta',
- 'Quinta',
- 'Sexta',
- 'S\xe1bado',
- 'Domingo'],
- '%B': [None,
- 'Janeiro',
- 'Fevereiro',
- 'Mar\xe7o',
- 'Abril',
- 'Maio',
- 'Junho',
- 'Julho',
- 'Agosto',
- 'Setembro',
- 'Outubro',
- 'Novembro',
- 'Dezembro'],
- '%a': ['Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'S\xe1b', 'Dom'],
- '%b': [None,
- 'Jan',
- 'Fev',
- 'Mar',
- 'Abr',
- 'Mai',
- 'Jun',
- 'Jul',
- 'Ago',
- 'Set',
- 'Out',
- 'Nov',
- 'Dez'],
- '%p': ['', '']},
- 'ru': {'%A': ['\u041f\u043e\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0438\u043a',
- '\u0412\u0442\u043e\u0440\u043d\u0438\u043a',
- '\u0421\u0440\u0435\u0434\u0430',
- '\u0427\u0435\u0442\u0432\u0435\u0440\u0433',
- '\u041f\u044f\u0442\u043d\u0438\u0446\u0430',
- '\u0421\u0443\u0431\u0431\u043e\u0442\u0430',
- '\u0412\u043e\u0441\u043a\u0440\u0435\u0441\u0435\u043d\u044c\u0435'],
- '%B': [None,
- '\u042f\u043d\u0432\u0430\u0440\u044c',
- '\u0424\u0435\u0432\u0440\u0430\u043b\u044c',
- '\u041c\u0430\u0440\u0442',
- '\u0410\u043f\u0440\u0435\u043b\u044c',
- '\u041c\u0430\u0439',
- '\u0418\u044e\u043d\u044c',
- '\u0418\u044e\u043b\u044c',
- '\u0410\u0432\u0433\u0443\u0441\u0442',
- '\u0421\u0435\u043d\u0442\u044f\u0431\u0440\u044c',
- '\u041e\u043a\u0442\u044f\u0431\u0440\u044c',
- '\u041d\u043e\u044f\u0431\u0440\u044c',
- '\u0414\u0435\u043a\u0430\u0431\u0440\u044c'],
- '%a': ['\u041f\u043d',
- '\u0412\u0442',
- '\u0421\u0440',
- '\u0427\u0442',
- '\u041f\u0442',
- '\u0421\u0431',
- '\u0412\u0441'],
- '%b': [None,
- '\u044f\u043d\u0432',
- '\u0444\u0435\u0432',
- '\u043c\u0430\u0440',
- '\u0430\u043f\u0440',
- '\u043c\u0430\u0439',
- '\u0438\u044e\u043d',
- '\u0438\u044e\u043b',
- '\u0430\u0432\u0433',
- '\u0441\u0435\u043d',
- '\u043e\u043a\u0442',
- '\u043d\u043e\u044f',
- '\u0434\u0435\u043a'],
- '%p': ['', '']},
- 'sl': {'%A': ['ponedeljek',
- 'torek',
- 'sreda',
- '\u010detrtek',
- 'petek',
- 'sobota',
- 'nedelja'],
- '%B': [None,
- 'januar',
- 'februar',
- 'marec',
- 'april',
- 'maj',
- 'junij',
- 'julij',
- 'avgust',
- 'september',
- 'oktober',
- 'november',
- 'december'],
- '%a': ['pon', 'tor', 'sre', '\u010det', 'pet', 'sob', 'ned'],
- '%b': [None,
- 'jan',
- 'feb',
- 'mar',
- 'apr',
- 'maj',
- 'jun',
- 'jul',
- 'avg',
- 'sep',
- 'okt',
- 'nov',
- 'dec'],
- '%p': ['', '']},
- 'zh': {'%A': ['\u661f\u671f\u4e00',
- '\u661f\u671f\u4e8c',
- '\u661f\u671f\u4e09',
- '\u661f\u671f\u56db',
- '\u661f\u671f\u4e94',
- '\u661f\u671f\u516d',
- '\u661f\u671f\u65e5'],
- '%B': [None,
- '\u4e00\u6708',
- '\u4e8c\u6708',
- '\u4e09\u6708',
- '\u56db\u6708',
- '\u4e94\u6708',
- '\u516d\u6708',
- '\u4e03\u6708',
- '\u516b\u6708',
- '\u4e5d\u6708',
- '\u5341\u6708',
- '\u5341\u4e00\u6708',
- '\u5341\u4e8c\u6708'],
- '%a': ['\u4e00',
- '\u4e8c',
- '\u4e09',
- '\u56db',
- '\u4e94',
- '\u516d',
- '\u65e5'],
- '%b': [None,
- '1\u6708',
- '2\u6708',
- '3\u6708',
- '4\u6708',
- '5\u6708',
- '6\u6708',
- '7\u6708',
- '8\u6708',
- '9\u6708',
- '10\u6708',
- '11\u6708',
- '12\u6708'],
- '%p': ['\u4e0a\u5348', '\u4e0b\u5348']}}
diff --git a/trytond/ir/tryton.cfg b/trytond/ir/tryton.cfg
index 5f0b346455..9fe8b7c700 100644
--- a/trytond/ir/tryton.cfg
+++ b/trytond/ir/tryton.cfg
@@ -17,4 +17,5 @@ xml:
rule.xml
module.xml
trigger.xml
+ calendar_.xml
message.xml
diff --git a/trytond/ir/view/lang_form.xml b/trytond/ir/view/lang_form.xml
index 877b2831b7..6e90372c60 100644
--- a/trytond/ir/view/lang_form.xml
+++ b/trytond/ir/view/lang_form.xml
@@ -17,6 +17,10 @@ this repository contains the full copyright notices and license terms. -->
+
+
+
+
diff --git a/trytond/tests/test_ir.py b/trytond/tests/test_ir.py
index e271f9be00..e45b0cd1d6 100644
--- a/trytond/tests/test_ir.py
+++ b/trytond/tests/test_ir.py
@@ -53,16 +53,16 @@ class IrTestCase(ModuleTestCase):
"Test Lang.strftime"
pool = Pool()
Lang = pool.get('ir.lang')
+ lang = Lang.get('en')
test_data = [
- ((2016, 8, 3), 'en', '%d %B %Y', "03 August 2016"),
- ((2016, 8, 3), 'fr', '%d %B %Y', "03 ao\xfbt 2016"),
- ((2016, 8, 3), 'fr', '%d %B %Y', "03 ao\xfbt 2016"),
+ (datetime.date(2016, 8, 3), '%d %B %Y', "03 August 2016"),
+ (datetime.time(8, 20), '%I:%M %p', "08:20 AM"),
+ (datetime.datetime(2018, 11, 1, 14, 30), '%a %d %b %Y %I:%M %p',
+ "Thu 01 Nov 2018 02:30 PM"),
+ (datetime.date(2018, 11, 1), '%x', "11/01/2018"),
]
- for date, code, format_, result in test_data:
- lang = Lang.get(code)
- self.assertEqual(
- lang.strftime(datetime.date(*date), format_),
- result)
+ for date, format_, result in test_data:
+ self.assertEqual(lang.strftime(date, format_), result)
def suite():