mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-23 18:32:55 +00:00
locale data table should not have Default entry
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
parent
6ceb674ac4
commit
147ab650e1
2 changed files with 20 additions and 53 deletions
|
@ -281,7 +281,7 @@ def printtable(frommap, prefix):
|
|||
continue
|
||||
firstvalue = frommap[key][0]
|
||||
secondvalue = frommap[key][1]
|
||||
print(' { "%s\\0", "%s\\0", QLocale::%s::%s },' % (secondvalue, firstvalue, prefix, key))
|
||||
print(' { %s, %s, QLocale::%s::%s },' % (tochar(secondvalue), tochar(firstvalue), prefix, key))
|
||||
|
||||
# now everything except those but only unique code values
|
||||
for key in sorted(frommap.keys()):
|
||||
|
@ -292,7 +292,7 @@ def printtable(frommap, prefix):
|
|||
continue
|
||||
seenfirstvalues.append(firstvalue)
|
||||
secondvalue = frommap[key][1]
|
||||
print(' { "%s\\0", "%s\\0", QLocale::%s::%s },' % (secondvalue, firstvalue, prefix, key))
|
||||
print(' { %s, %s, QLocale::%s::%s },' % (tochar(secondvalue), tochar(firstvalue), prefix, key))
|
||||
|
||||
print('};')
|
||||
print('static const qint16 %sTblSize = sizeof(%sTbl) / sizeof(%sTblData);\n' % (lowerprefix, lowerprefix, lowerprefix))
|
||||
|
@ -303,7 +303,7 @@ def printlocaledata(frommap, key):
|
|||
# preserve the assumption in QLocalePrivate::findLocale that "AnyCountry" means "find me a
|
||||
# language, no matter what country it is spoken in" if "AnyCountry" is passed to it as argument
|
||||
# and also shrinks the table
|
||||
if value['country'] == 'QLocale::Country::AnyCountry' and not key in ('Default', 'C'):
|
||||
if value['country'] == 'QLocale::Country::AnyCountry' and not key == 'C':
|
||||
return
|
||||
print(''' {
|
||||
%s, %s, %s,
|
||||
|
@ -412,11 +412,10 @@ localenumberingmap = {}
|
|||
|
||||
# artificial entries
|
||||
languagemap['AnyLanguage'] = ['', 'Default']
|
||||
languagemap['C'] = ['', 'C']
|
||||
languagemap['C'] = ['C', 'C']
|
||||
countrymap['AnyCountry'] = ['', 'Default']
|
||||
scriptmap['AnyScript'] = ['', 'Default']
|
||||
|
||||
|
||||
# locale to parent parsing
|
||||
tree = ET.parse('common/supplemental/supplementalData.xml')
|
||||
root = tree.getroot()
|
||||
|
@ -452,9 +451,10 @@ for weekend in root.findall('./weekData/weekendEnd'):
|
|||
# locale to iso4217 parsing
|
||||
for region in root.findall('./currencyData/region'):
|
||||
regioniso3166 = region.get('iso3166')
|
||||
latestcurrency = region.find('currency')
|
||||
lastestcurrencyiso4217 = latestcurrency.get('iso4217')
|
||||
localeiso4217map[regioniso3166] = lastestcurrencyiso4217
|
||||
# data includes past currencies too, pick the current currency which is first
|
||||
currency = region.find('currency')
|
||||
currencyiso4217 = currency.get('iso4217')
|
||||
localeiso4217map[regioniso3166] = currencyiso4217
|
||||
|
||||
# locale to currency parsing
|
||||
for info in root.findall('./currencyData/fractions/info'):
|
||||
|
@ -518,7 +518,8 @@ if printenumsandexit:
|
|||
else:
|
||||
printtable(scriptmap, 'Script')
|
||||
|
||||
# these defaults are used only as parent locales fallback, actual defaults are set from root
|
||||
# these defaults are used as parent locales fallback, C uses them as actual values because root
|
||||
# contains UTF-8 characters and for compatibility. for the rest defaults are set from root
|
||||
localedefaults = {
|
||||
# enums
|
||||
'language': 'QLocale::Language::AnyLanguage',
|
||||
|
@ -575,8 +576,6 @@ localedefaults = {
|
|||
'narrow_day_names': ['7', '1', '2', '3', '4', '5', '6'],
|
||||
}
|
||||
# artificial entries
|
||||
localemap['Default'] = {}
|
||||
mapcopy(localedefaults, localemap['Default'])
|
||||
localemap['C'] = {}
|
||||
mapcopy(localedefaults, localemap['C'])
|
||||
localemap['C']['language'] = 'QLocale::Language::C'
|
||||
|
@ -705,6 +704,9 @@ def readlocale(fromxml, tomap, isparent):
|
|||
# taking the first character works even for UTF-8 chars
|
||||
tomap[locale]['zero'] = localenumberingmap[numbertype][0]
|
||||
|
||||
# locale numeric system was found, break
|
||||
break
|
||||
|
||||
# digits/rounding data is specific so check if it is mapped
|
||||
if currencytype and currencytype in localecurrencymap.keys():
|
||||
tomap[locale]['currency_digits'] = localecurrencymap[currencytype][0]
|
||||
|
@ -916,13 +918,12 @@ for xml in sorted(glob.glob('common/main/*.xml')):
|
|||
|
||||
print('''static const QLocalePrivate localeTbl[] = {''')
|
||||
|
||||
# print Default first, C second
|
||||
printlocaledata(localemap, 'Default')
|
||||
# print C first
|
||||
printlocaledata(localemap, 'C')
|
||||
|
||||
# now everything except those
|
||||
# now everything except that
|
||||
for key in sorted(localemap.keys()):
|
||||
if key in ('Default', 'C'):
|
||||
if key == 'C':
|
||||
continue
|
||||
printlocaledata(localemap, key)
|
||||
|
||||
|
|
|
@ -62,8 +62,8 @@ static const struct languageTblData {
|
|||
const char* code;
|
||||
const QLocale::Language language;
|
||||
} languageTbl[] = {
|
||||
{ "Default\0", "\0", QLocale::Language::AnyLanguage },
|
||||
{ "C\0", "\0", QLocale::Language::C },
|
||||
{ "Default\0", Q_NULLPTR, QLocale::Language::AnyLanguage },
|
||||
{ "C\0", "C\0", QLocale::Language::C },
|
||||
{ "Abkhazian\0", "ab\0", QLocale::Language::Abkhazian },
|
||||
{ "Achinese\0", "ace\0", QLocale::Language::Achinese },
|
||||
{ "Acoli\0", "ach\0", QLocale::Language::Acoli },
|
||||
|
@ -691,7 +691,7 @@ static const struct countryTblData {
|
|||
const char* code;
|
||||
const QLocale::Country country;
|
||||
} countryTbl[] = {
|
||||
{ "Default\0", "\0", QLocale::Country::AnyCountry },
|
||||
{ "Default\0", Q_NULLPTR, QLocale::Country::AnyCountry },
|
||||
{ "Afghanistan\0", "AF\0", QLocale::Country::Afghanistan },
|
||||
{ "Africa\0", "002\0", QLocale::Country::Africa },
|
||||
{ "Åland Islands\0", "AX\0", QLocale::Country::AlandIslands },
|
||||
|
@ -994,7 +994,7 @@ static const struct scriptTblData {
|
|||
const char* code;
|
||||
const QLocale::Script script;
|
||||
} scriptTbl[] = {
|
||||
{ "Default\0", "\0", QLocale::Script::AnyScript },
|
||||
{ "Default\0", Q_NULLPTR, QLocale::Script::AnyScript },
|
||||
{ "Adlam\0", "Adlm\0", QLocale::Script::AdlamScript },
|
||||
{ "Afaka\0", "Afak\0", QLocale::Script::AfakaScript },
|
||||
{ "Ahom\0", "Ahom\0", QLocale::Script::AhomScript },
|
||||
|
@ -1186,40 +1186,6 @@ static const struct scriptTblData {
|
|||
static const qint16 scriptTblSize = sizeof(scriptTbl) / sizeof(scriptTblData);
|
||||
|
||||
static const QLocalePrivate localeTbl[] = {
|
||||
{
|
||||
QLocale::Language::AnyLanguage, QLocale::Script::AnyScript, QLocale::Country::AnyCountry,
|
||||
// week
|
||||
Qt::Monday, Qt::Saturday, Qt::Sunday,
|
||||
// symbols
|
||||
46, 44, 59, 37, 45, 43, 101, 2, 1, 48,
|
||||
// quotation
|
||||
"\"\0", "\"\0", "'\0", "'\0",
|
||||
// endonym
|
||||
Q_NULLPTR, Q_NULLPTR,
|
||||
// list pattern
|
||||
"%1, %2\0", "%1, %2\0", "%1, %2\0", "%1, %2\0",
|
||||
// date/time format
|
||||
"d MMM yyyy\0", "d MMMM yyyy\0", "HH:mm:ss\0", "HH:mm:ss z\0",
|
||||
// am/pm
|
||||
"AM\0", "PM\0",
|
||||
// currency
|
||||
Q_NULLPTR, "%1%2\0", Q_NULLPTR, Q_NULLPTR,
|
||||
{ Q_NULLPTR, Q_NULLPTR, Q_NULLPTR, Q_NULLPTR, Q_NULLPTR, Q_NULLPTR, Q_NULLPTR },
|
||||
// month names
|
||||
{ "Jan\0", "Feb\0", "Mar\0", "Apr\0", "May\0", "Jun\0", "Jul\0", "Aug\0", "Sep\0", "Oct\0", "Nov\0", "Dec\0" },
|
||||
{ "January\0", "February\0", "March\0", "April\0", "May\0", "June\0", "July\0", "August\0", "September\0", "October\0", "November\0", "December\0" },
|
||||
{ "J\0", "F\0", "M\0", "A\0", "M\0", "J\0", "J\0", "A\0", "S\0", "O\0", "N\0", "D\0" },
|
||||
{ "Jan\0", "Feb\0", "Mar\0", "Apr\0", "May\0", "Jun\0", "Jul\0", "Aug\0", "Sep\0", "Oct\0", "Nov\0", "Dec\0" },
|
||||
{ "January\0", "February\0", "March\0", "April\0", "May\0", "June\0", "July\0", "August\0", "September\0", "October\0", "November\0", "December\0" },
|
||||
{ "1\0", "2\0", "3\0", "4\0", "5\0", "6\0", "7\0", "8\0", "9\0", "10\0", "11\0", "12\0" },
|
||||
// day names
|
||||
{ "Sun\0", "Mon\0", "Tue\0", "Wed\0", "Thu\0", "Fri\0", "Sat\0" },
|
||||
{ "Sunday\0", "Monday\0", "Tuesday\0", "Wednesday\0", "Thursday\0", "Friday\0", "Saturday\0" },
|
||||
{ "S\0", "M\0", "T\0", "W\0", "T\0", "F\0", "S\0" },
|
||||
{ "Sun\0", "Mon\0", "Tue\0", "Wed\0", "Thu\0", "Fri\0", "Sat\0" },
|
||||
{ "Sunday\0", "Monday\0", "Tuesday\0", "Wednesday\0", "Thursday\0", "Friday\0", "Saturday\0" },
|
||||
{ "7\0", "1\0", "2\0", "3\0", "4\0", "5\0", "6\0" }
|
||||
}, // Default
|
||||
{
|
||||
QLocale::Language::C, QLocale::Script::AnyScript, QLocale::Country::AnyCountry,
|
||||
// week
|
||||
|
|
Loading…
Add table
Reference in a new issue