mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-24 02:42:55 +00:00
remove invalid date/time format tags from locale data
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
parent
7dec2e8cd6
commit
1101c468c4
2 changed files with 801 additions and 765 deletions
|
@ -86,6 +86,42 @@ def tocurrencyformat(fromformat, frommap):
|
||||||
result.append(fmt)
|
result.append(fmt)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def todatetimeformat(fromformat):
|
||||||
|
unsupportedtags = [
|
||||||
|
'g',
|
||||||
|
'u',
|
||||||
|
'q',
|
||||||
|
'l',
|
||||||
|
'w',
|
||||||
|
'f',
|
||||||
|
'g',
|
||||||
|
'e',
|
||||||
|
'c',
|
||||||
|
'a',
|
||||||
|
'k',
|
||||||
|
'j',
|
||||||
|
'v',
|
||||||
|
]
|
||||||
|
possibleoccurances = [
|
||||||
|
'%s, ',
|
||||||
|
'%s.',
|
||||||
|
'%s-',
|
||||||
|
'%s',
|
||||||
|
]
|
||||||
|
result = fromformat
|
||||||
|
for tag in unsupportedtags:
|
||||||
|
uppertag = tag.upper()
|
||||||
|
for occurance in possibleoccurances:
|
||||||
|
result = result.replace(occurance % tag, '')
|
||||||
|
result = result.replace(occurance % (tag * 2), '')
|
||||||
|
result = result.replace(occurance % (tag * 3), '')
|
||||||
|
result = result.replace(occurance % (tag * 4), '')
|
||||||
|
result = result.replace(occurance % uppertag, '')
|
||||||
|
result = result.replace(occurance % (uppertag * 2), '')
|
||||||
|
result = result.replace(occurance % (uppertag * 3), '')
|
||||||
|
result = result.replace(occurance % (uppertag * 4), '')
|
||||||
|
return result
|
||||||
|
|
||||||
def tomonthslist(fromxmlelements, initialvalues):
|
def tomonthslist(fromxmlelements, initialvalues):
|
||||||
result = []
|
result = []
|
||||||
listcopy(initialvalues, result)
|
listcopy(initialvalues, result)
|
||||||
|
@ -272,8 +308,8 @@ def printlocaledata(frommap, key):
|
||||||
tochar(value['list_pattern_part_mid']),
|
tochar(value['list_pattern_part_mid']),
|
||||||
tochar(value['list_pattern_part_end']),
|
tochar(value['list_pattern_part_end']),
|
||||||
tochar(value['list_pattern_part_two']),
|
tochar(value['list_pattern_part_two']),
|
||||||
tochar(value['short_date_format']),
|
tochar(todatetimeformat(value['short_date_format'])),
|
||||||
tochar(value['long_date_format']),
|
tochar(todatetimeformat(value['long_date_format'])),
|
||||||
tochar(value['short_time_format']),
|
tochar(value['short_time_format']),
|
||||||
tochar(value['long_time_format']),
|
tochar(value['long_time_format']),
|
||||||
tochar(value['am']),
|
tochar(value['am']),
|
||||||
|
@ -448,7 +484,7 @@ localedefaults = {
|
||||||
'list_pattern_part_end': "%1, %2",
|
'list_pattern_part_end': "%1, %2",
|
||||||
'list_pattern_part_two': "%1, %2",
|
'list_pattern_part_two': "%1, %2",
|
||||||
'short_date_format': 'd MMM yyyy',
|
'short_date_format': 'd MMM yyyy',
|
||||||
'long_date_format': 'EEEE, d MMMM yyyy',
|
'long_date_format': 'd MMMM yyyy',
|
||||||
'short_time_format': 'HH:mm:ss',
|
'short_time_format': 'HH:mm:ss',
|
||||||
'long_time_format': 'HH:mm:ss z',
|
'long_time_format': 'HH:mm:ss z',
|
||||||
'am': 'AM',
|
'am': 'AM',
|
||||||
|
@ -648,20 +684,20 @@ for xml in glob.glob('common/main/*.xml'):
|
||||||
dateformattype = dateformat.get('type')
|
dateformattype = dateformat.get('type')
|
||||||
if dateformattype == 'short':
|
if dateformattype == 'short':
|
||||||
pattern = dateformat.find('./dateFormat/pattern')
|
pattern = dateformat.find('./dateFormat/pattern')
|
||||||
localemap[locale]['short_date_format'] = pattern.text
|
localemap[locale]['short_date_format'] = todatetimeformat(pattern.text)
|
||||||
elif dateformattype == 'long':
|
elif dateformattype == 'long':
|
||||||
pattern = dateformat.find('./dateFormat/pattern')
|
pattern = dateformat.find('./dateFormat/pattern')
|
||||||
localemap[locale]['long_date_format'] = pattern.text
|
localemap[locale]['long_date_format'] = todatetimeformat(pattern.text)
|
||||||
|
|
||||||
timeformat = calendar.find('./timeFormats/timeFormatLength')
|
timeformat = calendar.find('./timeFormats/timeFormatLength')
|
||||||
if timeformat is not None:
|
if timeformat is not None:
|
||||||
timeformattype = timeformat.get('type')
|
timeformattype = timeformat.get('type')
|
||||||
if timeformattype == 'short':
|
if timeformattype == 'short':
|
||||||
pattern = timeformat.find('./timeFormat/pattern')
|
pattern = timeformat.find('./timeFormat/pattern')
|
||||||
localemap[locale]['short_time_format'] = pattern.text
|
localemap[locale]['short_time_format'] = todatetimeformat(pattern.text)
|
||||||
elif timeformattype == 'long':
|
elif timeformattype == 'long':
|
||||||
pattern = timeformat.find('./timeFormat/pattern')
|
pattern = timeformat.find('./timeFormat/pattern')
|
||||||
localemap[locale]['long_time_format'] = pattern.text
|
localemap[locale]['long_time_format'] = todatetimeformat(pattern.text)
|
||||||
|
|
||||||
for dayperiodwidth in calendar.findall('./dayPeriods/dayPeriodContext/dayPeriodWidth'):
|
for dayperiodwidth in calendar.findall('./dayPeriods/dayPeriodContext/dayPeriodWidth'):
|
||||||
dayperiodwidthtype = dayperiodwidth.get('type')
|
dayperiodwidthtype = dayperiodwidth.get('type')
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue