Use simplified language code for time_locale
issue5443 review29511002
This commit is contained in:
1 parent
d305c26e54
commit
a208d9a0d2
4 files changed
+578
-759
No files matched your search
@@ -16,7 +16,7 @@ def locale_strftime(lang):
|
||||
'%B': [None],
|
||||
'%p': [],
|
||||
}
|
||||
locale.setlocale(locale.LC_ALL, lang + '.UTF_8')
|
||||
locale.setlocale(locale.LC_ALL, locale.normalize(lang + '.UTF_8'))
|
||||
t = list(time.gmtime())
|
||||
for i in range(12):
|
||||
t[1] = i + 1
|
||||
@@ -43,7 +43,7 @@ if __name__ == '__main__':
|
||||
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
|
||||
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 -*-
|
||||
|
||||
@@ -412,6 +412,7 @@ class Lang(ModelSQL, ModelView):
|
||||
'''
|
||||
Convert datetime to a string as specified by the format argument.
|
||||
'''
|
||||
code = code[:2]
|
||||
if code in TIME_LOCALE:
|
||||
for f, i in (('%a', 6), ('%A', 6), ('%b', 1), ('%B', 1)):
|
||||
format = format.replace(f,
|
||||
|
||||
+572
-754
File diff suppressed because it is too large.
Load diff
@@ -54,9 +54,9 @@ class IrTestCase(ModuleTestCase):
|
||||
pool = Pool()
|
||||
Lang = pool.get('ir.lang')
|
||||
test_data = [
|
||||
((2016, 8, 3), 'en_EN', '%d %B %Y', u"03 August 2016"),
|
||||
((2016, 8, 3), 'fr_FR', '%d %B %Y', u"03 ao\xfbt 2016"),
|
||||
((2016, 8, 3), 'fr_FR', u'%d %B %Y', u"03 ao\xfbt 2016"),
|
||||
((2016, 8, 3), 'en', '%d %B %Y', u"03 August 2016"),
|
||||
((2016, 8, 3), 'fr', '%d %B %Y', u"03 ao\xfbt 2016"),
|
||||
((2016, 8, 3), 'fr', u'%d %B %Y', u"03 ao\xfbt 2016"),
|
||||
]
|
||||
for date, code, format_, result in test_data:
|
||||
self.assertEqual(
|
||||
|
||||
Reference in new issue
Block a user