Add ir.calendar for month and day
This allows to replace time_locale and use the translation infrastructure instead. So it can be customized using the translation override or derivative languages. This provides also a standard base to modules that needs calendar month and day. issue7815 review56451002
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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')
|
||||
@@ -0,0 +1,103 @@
|
||||
<?xml version="1.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. -->
|
||||
<tryton>
|
||||
<data group="1">
|
||||
<record model="ir.calendar.month" id="January">
|
||||
<field name="index" eval="1"/>
|
||||
<field name="name">January</field>
|
||||
<field name="abbreviation">Jan</field>
|
||||
</record>
|
||||
<record model="ir.calendar.month" id="February">
|
||||
<field name="index" eval="2"/>
|
||||
<field name="name">February</field>
|
||||
<field name="abbreviation">Feb</field>
|
||||
</record>
|
||||
<record model="ir.calendar.month" id="March">
|
||||
<field name="index" eval="3"/>
|
||||
<field name="name">March</field>
|
||||
<field name="abbreviation">Mar</field>
|
||||
</record>
|
||||
<record model="ir.calendar.month" id="April">
|
||||
<field name="index" eval="4"/>
|
||||
<field name="name">April</field>
|
||||
<field name="abbreviation">Apr</field>
|
||||
</record>
|
||||
<record model="ir.calendar.month" id="May">
|
||||
<field name="index" eval="5"/>
|
||||
<field name="name">May</field>
|
||||
<field name="abbreviation">May</field>
|
||||
</record>
|
||||
<record model="ir.calendar.month" id="June">
|
||||
<field name="index" eval="6"/>
|
||||
<field name="name">June</field>
|
||||
<field name="abbreviation">Jun</field>
|
||||
</record>
|
||||
<record model="ir.calendar.month" id="July">
|
||||
<field name="index" eval="7"/>
|
||||
<field name="name">July</field>
|
||||
<field name="abbreviation">Jul</field>
|
||||
</record>
|
||||
<record model="ir.calendar.month" id="August">
|
||||
<field name="index" eval="8"/>
|
||||
<field name="name">August</field>
|
||||
<field name="abbreviation">Aug</field>
|
||||
</record>
|
||||
<record model="ir.calendar.month" id="September">
|
||||
<field name="index" eval="9"/>
|
||||
<field name="name">September</field>
|
||||
<field name="abbreviation">Sep</field>
|
||||
</record>
|
||||
<record model="ir.calendar.month" id="October">
|
||||
<field name="index" eval="10"/>
|
||||
<field name="name">October</field>
|
||||
<field name="abbreviation">Oct</field>
|
||||
</record>
|
||||
<record model="ir.calendar.month" id="November">
|
||||
<field name="index" eval="11"/>
|
||||
<field name="name">November</field>
|
||||
<field name="abbreviation">Nov</field>
|
||||
</record>
|
||||
<record model="ir.calendar.month" id="December">
|
||||
<field name="index" eval="12"/>
|
||||
<field name="name">December</field>
|
||||
<field name="abbreviation">Dec</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.calendar.day" id="Monday">
|
||||
<field name="index" eval="0"/>
|
||||
<field name="name">Monday</field>
|
||||
<field name="abbreviation">Mon</field>
|
||||
</record>
|
||||
<record model="ir.calendar.day" id="Tuesday">
|
||||
<field name="index" eval="1"/>
|
||||
<field name="name">Tuesday</field>
|
||||
<field name="abbreviation">Tue</field>
|
||||
</record>
|
||||
<record model="ir.calendar.day" id="Wednesday">
|
||||
<field name="index" eval="2"/>
|
||||
<field name="name">Wednesday</field>
|
||||
<field name="abbreviation">Wed</field>
|
||||
</record>
|
||||
<record model="ir.calendar.day" id="Thursday">
|
||||
<field name="index" eval="3"/>
|
||||
<field name="name">Thursday</field>
|
||||
<field name="abbreviation">Thu</field>
|
||||
</record>
|
||||
<record model="ir.calendar.day" id="Friday">
|
||||
<field name="index" eval="4"/>
|
||||
<field name="name">Friday</field>
|
||||
<field name="abbreviation">Fri</field>
|
||||
</record>
|
||||
<record model="ir.calendar.day" id="Saturday">
|
||||
<field name="index" eval="5"/>
|
||||
<field name="name">Saturday</field>
|
||||
<field name="abbreviation">Sat</field>
|
||||
</record>
|
||||
<record model="ir.calendar.day" id="Sunday">
|
||||
<field name="index" eval="6"/>
|
||||
<field name="name">Sunday</field>
|
||||
<field name="abbreviation">Sun</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
@@ -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)
|
||||
@@ -11,6 +11,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="code">en</field>
|
||||
<field name="name">English</field>
|
||||
<field name="date">%m/%d/%Y</field>
|
||||
<field name="am">AM</field>
|
||||
<field name="pm">PM</field>
|
||||
<field name="grouping">[3, 3, 0]</field>
|
||||
<field name="decimal_point">.</field>
|
||||
<field name="thousands_sep">,</field>
|
||||
|
||||
+28
-12
@@ -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):
|
||||
|
||||
@@ -9,6 +9,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="code">bg</field>
|
||||
<field name="name">Bulgarian</field>
|
||||
<field name="date">%d.%m.%Y</field>
|
||||
<field name="am"></field>
|
||||
<field name="pm"></field>
|
||||
<field name="grouping">[3, 3, 0]</field>
|
||||
<field name="decimal_point">,</field>
|
||||
<field name="thousands_sep">.</field>
|
||||
@@ -28,6 +30,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="code">ca</field>
|
||||
<field name="name">Català</field>
|
||||
<field name="date">%d/%m/%Y</field>
|
||||
<field name="am">a. m.</field>
|
||||
<field name="pm">p. m.</field>
|
||||
<field name="grouping">[3, 3, 0]</field>
|
||||
<field name="decimal_point">,</field>
|
||||
<field name="thousands_sep"> </field>
|
||||
@@ -47,6 +51,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="code">cs</field>
|
||||
<field name="name">Czech</field>
|
||||
<field name="date">%d.%m.%Y</field>
|
||||
<field name="am"></field>
|
||||
<field name="pm"></field>
|
||||
<field name="grouping">[3, 3, 0]</field>
|
||||
<field name="decimal_point">,</field>
|
||||
<field name="thousands_sep"> </field>
|
||||
@@ -66,6 +72,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="code">de</field>
|
||||
<field name="name">German</field>
|
||||
<field name="date">%d.%m.%Y</field>
|
||||
<field name="am"></field>
|
||||
<field name="pm"></field>
|
||||
<field name="grouping">[3, 3, 0]</field>
|
||||
<field name="decimal_point">,</field>
|
||||
<field name="thousands_sep">.</field>
|
||||
@@ -88,6 +96,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="code">es</field>
|
||||
<field name="name">Spanish</field>
|
||||
<field name="date">%d/%m/%Y</field>
|
||||
<field name="am"></field>
|
||||
<field name="pm"></field>
|
||||
<field name="grouping">[3, 3, 0]</field>
|
||||
<field name="decimal_point">,</field>
|
||||
<field name="thousands_sep">.</field>
|
||||
@@ -107,6 +117,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="code">es_419</field>
|
||||
<field name="name">Spanish (Latin American)</field>
|
||||
<field name="date">%d/%m/%Y</field>
|
||||
<field name="am"></field>
|
||||
<field name="pm"></field>
|
||||
<field name="grouping">[3, 3, 0]</field>
|
||||
<field name="decimal_point">.</field>
|
||||
<field name="thousands_sep">,</field>
|
||||
@@ -127,6 +139,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="name">Persian</field>
|
||||
<field name="direction">rtl</field>
|
||||
<field name="date">%Y/%m/%d</field>
|
||||
<field name="am"></field>
|
||||
<field name="pm"></field>
|
||||
<field name="grouping">[3, 0]</field>
|
||||
<field name="decimal_point">.</field>
|
||||
<field name="thousands_sep">,</field>
|
||||
@@ -146,6 +160,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="code">fr</field>
|
||||
<field name="name">French</field>
|
||||
<field name="date">%d.%m.%Y</field>
|
||||
<field name="am"></field>
|
||||
<field name="pm"></field>
|
||||
<field name="grouping">[3, 0]</field>
|
||||
<field name="decimal_point">,</field>
|
||||
<field name="thousands_sep"> </field>
|
||||
@@ -165,6 +181,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="code">hu</field>
|
||||
<field name="name">Hungarian</field>
|
||||
<field name="date">%Y-%m-%d</field>
|
||||
<field name="am"></field>
|
||||
<field name="pm"></field>
|
||||
<field name="grouping">[3, 3, 0]</field>
|
||||
<field name="decimal_point">,</field>
|
||||
<field name="thousands_sep">.</field>
|
||||
@@ -184,6 +202,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="code">it</field>
|
||||
<field name="name">Italian</field>
|
||||
<field name="date">%d/%m/%Y</field>
|
||||
<field name="am"></field>
|
||||
<field name="pm"></field>
|
||||
<field name="grouping">[3, 3, 0]</field>
|
||||
<field name="decimal_point">,</field>
|
||||
<field name="thousands_sep">.</field>
|
||||
@@ -203,6 +223,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="code">lo</field>
|
||||
<field name="name">Lao</field>
|
||||
<field name="date">%d/%m/%Y</field>
|
||||
<field name="am">AM</field>
|
||||
<field name="pm">PM</field>
|
||||
<field name="grouping">[3, 3, 0]</field>
|
||||
<field name="decimal_point">.</field>
|
||||
<field name="thousands_sep">,</field>
|
||||
@@ -222,6 +244,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="code">lt</field>
|
||||
<field name="name">Lithuanian</field>
|
||||
<field name="date">%Y-%m-%d</field>
|
||||
<field name="am"></field>
|
||||
<field name="pm"></field>
|
||||
<field name="grouping">[3, 3, 0]</field>
|
||||
<field name="decimal_point">,</field>
|
||||
<field name="thousands_sep"> </field>
|
||||
@@ -241,6 +265,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="code">nl</field>
|
||||
<field name="name">Dutch</field>
|
||||
<field name="date">%d-%m-%Y</field>
|
||||
<field name="am"></field>
|
||||
<field name="pm"></field>
|
||||
<field name="grouping">[3, 3, 0]</field>
|
||||
<field name="decimal_point">,</field>
|
||||
<field name="thousands_sep">.</field>
|
||||
@@ -260,6 +286,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="code">pl</field>
|
||||
<field name="name">Polish</field>
|
||||
<field name="date">%d.%m.%Y</field>
|
||||
<field name="am"></field>
|
||||
<field name="pm"></field>
|
||||
<field name="decimal_point">,</field>
|
||||
<field name="thousands_sep"></field>
|
||||
<field name="mon_grouping">[3, 3, 0]</field>
|
||||
@@ -278,6 +306,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="code">pt</field>
|
||||
<field name="name">Portuguese</field>
|
||||
<field name="date">%d-%m-%Y</field>
|
||||
<field name="am"></field>
|
||||
<field name="pm"></field>
|
||||
<field name="grouping">[]</field>
|
||||
<field name="decimal_point">,</field>
|
||||
<field name="thousands_sep"></field>
|
||||
@@ -297,6 +327,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="code">ru</field>
|
||||
<field name="name">Russian</field>
|
||||
<field name="date">%d.%m.%Y</field>
|
||||
<field name="am"></field>
|
||||
<field name="pm"></field>
|
||||
<field name="grouping">[3, 3, 0]</field>
|
||||
<field name="decimal_point">,</field>
|
||||
<field name="thousands_sep"> </field>
|
||||
@@ -316,6 +348,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="code">sl</field>
|
||||
<field name="name">Slovenian</field>
|
||||
<field name="date">%d.%m.%Y</field>
|
||||
<field name="am"></field>
|
||||
<field name="pm"></field>
|
||||
<field name="grouping">[3, 3, 0]</field>
|
||||
<field name="decimal_point">,</field>
|
||||
<field name="thousands_sep">.</field>
|
||||
@@ -335,6 +369,8 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="code">zh_CN</field>
|
||||
<field name="name">Chinese Simplified</field>
|
||||
<field name="date">%Y-%m-%d</field>
|
||||
<field name="am">上午</field>
|
||||
<field name="pm">下午</field>
|
||||
<field name="grouping">[3, 0]</field>
|
||||
<field name="decimal_point">.</field>
|
||||
<field name="thousands_sep">,</field>
|
||||
|
||||
@@ -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']}}
|
||||
@@ -17,4 +17,5 @@ xml:
|
||||
rule.xml
|
||||
module.xml
|
||||
trigger.xml
|
||||
calendar_.xml
|
||||
message.xml
|
||||
|
||||
@@ -17,6 +17,10 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<separator string="Date Formatting" colspan="6" id="date"/>
|
||||
<label name="date"/>
|
||||
<field name="date"/>
|
||||
<label name="am"/>
|
||||
<field name="am"/>
|
||||
<label name="pm"/>
|
||||
<field name="pm"/>
|
||||
<separator string="Numbers Formatting" colspan="6" id="number"/>
|
||||
<label name="grouping"/>
|
||||
<field name="grouping"/>
|
||||
|
||||
@@ -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():
|
||||
|
||||
Reference in New Issue
Block a user