Misc fixes to the QLocale data parser/generator
Change-Id: I01589eae4e48bc1f484d54277de8f18262ca8f31 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
This commit is contained in:
parent
fc271b4273
commit
40ed226e53
@ -136,13 +136,13 @@ def generateLocaleInfo(path):
|
|||||||
|
|
||||||
language_id = enumdata.languageCodeToId(language_code)
|
language_id = enumdata.languageCodeToId(language_code)
|
||||||
if language_id == -1:
|
if language_id == -1:
|
||||||
sys.stderr.write("unnknown language code \"" + language_code + "\"\n")
|
sys.stderr.write("unknown language code \"" + language_code + "\"\n")
|
||||||
return {}
|
return {}
|
||||||
language = enumdata.language_list[language_id][0]
|
language = enumdata.language_list[language_id][0]
|
||||||
|
|
||||||
script_id = enumdata.scriptCodeToId(script_code)
|
script_id = enumdata.scriptCodeToId(script_code)
|
||||||
if script_code == -1:
|
if script_code == -1:
|
||||||
sys.stderr.write("unnknown script code \"" + script_code + "\"\n")
|
sys.stderr.write("unknown script code \"" + script_code + "\"\n")
|
||||||
return {}
|
return {}
|
||||||
script = "AnyScript"
|
script = "AnyScript"
|
||||||
if script_id != -1:
|
if script_id != -1:
|
||||||
@ -153,7 +153,7 @@ def generateLocaleInfo(path):
|
|||||||
if country_id != -1:
|
if country_id != -1:
|
||||||
country = enumdata.country_list[country_id][0]
|
country = enumdata.country_list[country_id][0]
|
||||||
if country == "":
|
if country == "":
|
||||||
sys.stderr.write("unnknown country code \"" + country_code + "\"\n")
|
sys.stderr.write("unknown country code \"" + country_code + "\"\n")
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
# So we say we accept only those values that have "contributed" or
|
# So we say we accept only those values that have "contributed" or
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
##
|
##
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
# langugae_list and country_list reflect the current values of enums in qlocale.h
|
# language_list and country_list reflect the current values of enums in qlocale.h
|
||||||
# If new xml language files are available in CLDR, these languages and countries
|
# If new xml language files are available in CLDR, these languages and countries
|
||||||
# need to be *appended* to this list.
|
# need to be *appended* to this list.
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ language_list = {
|
|||||||
78 : [ "Maltese", "mt" ],
|
78 : [ "Maltese", "mt" ],
|
||||||
79 : [ "Maori", "mi" ],
|
79 : [ "Maori", "mi" ],
|
||||||
80 : [ "Marathi", "mr" ],
|
80 : [ "Marathi", "mr" ],
|
||||||
81 : [ "Moldavian", "mo" ],
|
81 : [ "Moldavian", "mo" ], # deprecated (alias to "ro_MD")
|
||||||
82 : [ "Mongolian", "mn" ],
|
82 : [ "Mongolian", "mn" ],
|
||||||
83 : [ "Nauru", "na" ],
|
83 : [ "Nauru", "na" ],
|
||||||
84 : [ "Nepali", "ne" ],
|
84 : [ "Nepali", "ne" ],
|
||||||
@ -146,7 +146,7 @@ language_list = {
|
|||||||
98 : [ "Sangho", "sg" ],
|
98 : [ "Sangho", "sg" ],
|
||||||
99 : [ "Sanskrit", "sa" ],
|
99 : [ "Sanskrit", "sa" ],
|
||||||
100 : [ "Serbian", "sr" ],
|
100 : [ "Serbian", "sr" ],
|
||||||
101 : [ "SerboCroatian", "sh" ],
|
101 : [ "SerboCroatian", "sh" ], # legacy (alias to "sr_Latn")
|
||||||
102 : [ "Sesotho", "st" ],
|
102 : [ "Sesotho", "st" ],
|
||||||
103 : [ "Setswana", "tn" ],
|
103 : [ "Setswana", "tn" ],
|
||||||
104 : [ "Shona", "sn" ],
|
104 : [ "Shona", "sn" ],
|
||||||
@ -160,7 +160,7 @@ language_list = {
|
|||||||
112 : [ "Sundanese", "su" ],
|
112 : [ "Sundanese", "su" ],
|
||||||
113 : [ "Swahili", "sw" ],
|
113 : [ "Swahili", "sw" ],
|
||||||
114 : [ "Swedish", "sv" ],
|
114 : [ "Swedish", "sv" ],
|
||||||
115 : [ "Tagalog", "tl" ],
|
115 : [ "Tagalog", "tl" ], # legacy (alias to "fil")
|
||||||
116 : [ "Tajik", "tg" ],
|
116 : [ "Tajik", "tg" ],
|
||||||
117 : [ "Tamil", "ta" ],
|
117 : [ "Tamil", "ta" ],
|
||||||
118 : [ "Tatar", "tt" ],
|
118 : [ "Tatar", "tt" ],
|
||||||
@ -172,7 +172,7 @@ language_list = {
|
|||||||
124 : [ "Tsonga", "ts" ],
|
124 : [ "Tsonga", "ts" ],
|
||||||
125 : [ "Turkish", "tr" ],
|
125 : [ "Turkish", "tr" ],
|
||||||
126 : [ "Turkmen", "tk" ],
|
126 : [ "Turkmen", "tk" ],
|
||||||
127 : [ "Twi", "tw" ],
|
127 : [ "Twi", "tw" ], # should be an alias to Akan
|
||||||
128 : [ "Uigur", "ug" ],
|
128 : [ "Uigur", "ug" ],
|
||||||
129 : [ "Ukrainian", "uk" ],
|
129 : [ "Ukrainian", "uk" ],
|
||||||
130 : [ "Urdu", "ur" ],
|
130 : [ "Urdu", "ur" ],
|
||||||
|
@ -52,14 +52,6 @@ class Error:
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.msg
|
return self.msg
|
||||||
|
|
||||||
def check_static_char_array_length(name, array):
|
|
||||||
# some compilers like VC6 doesn't allow static arrays more than 64K bytes size.
|
|
||||||
size = reduce(lambda x, y: x+len(escapedString(y)), array, 0)
|
|
||||||
if size > 65535:
|
|
||||||
print "\n\n\n#error Array %s is too long! " % name
|
|
||||||
sys.stderr.write("\n\n\nERROR: the content of the array '%s' is too long: %d > 65535 " % (name, size))
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
def wrap_list(lst):
|
def wrap_list(lst):
|
||||||
def split(lst, size):
|
def split(lst, size):
|
||||||
for i in range(len(lst)/size+1):
|
for i in range(len(lst)/size+1):
|
||||||
@ -580,7 +572,6 @@ def main():
|
|||||||
data_temp_file.write("\n")
|
data_temp_file.write("\n")
|
||||||
|
|
||||||
# List patterns data
|
# List patterns data
|
||||||
#check_static_char_array_length("list_pattern_part", list_pattern_part_data.data)
|
|
||||||
data_temp_file.write("static const ushort list_pattern_part_data[] = {\n")
|
data_temp_file.write("static const ushort list_pattern_part_data[] = {\n")
|
||||||
data_temp_file.write(wrap_list(list_pattern_part_data.data))
|
data_temp_file.write(wrap_list(list_pattern_part_data.data))
|
||||||
data_temp_file.write("\n};\n")
|
data_temp_file.write("\n};\n")
|
||||||
@ -588,7 +579,6 @@ def main():
|
|||||||
data_temp_file.write("\n")
|
data_temp_file.write("\n")
|
||||||
|
|
||||||
# Date format data
|
# Date format data
|
||||||
#check_static_char_array_length("date_format", date_format_data.data)
|
|
||||||
data_temp_file.write("static const ushort date_format_data[] = {\n")
|
data_temp_file.write("static const ushort date_format_data[] = {\n")
|
||||||
data_temp_file.write(wrap_list(date_format_data.data))
|
data_temp_file.write(wrap_list(date_format_data.data))
|
||||||
data_temp_file.write("\n};\n")
|
data_temp_file.write("\n};\n")
|
||||||
@ -596,7 +586,6 @@ def main():
|
|||||||
data_temp_file.write("\n")
|
data_temp_file.write("\n")
|
||||||
|
|
||||||
# Time format data
|
# Time format data
|
||||||
#check_static_char_array_length("time_format", time_format_data.data)
|
|
||||||
data_temp_file.write("static const ushort time_format_data[] = {\n")
|
data_temp_file.write("static const ushort time_format_data[] = {\n")
|
||||||
data_temp_file.write(wrap_list(time_format_data.data))
|
data_temp_file.write(wrap_list(time_format_data.data))
|
||||||
data_temp_file.write("\n};\n")
|
data_temp_file.write("\n};\n")
|
||||||
@ -604,7 +593,6 @@ def main():
|
|||||||
data_temp_file.write("\n")
|
data_temp_file.write("\n")
|
||||||
|
|
||||||
# Months data
|
# Months data
|
||||||
#check_static_char_array_length("months", months_data.data)
|
|
||||||
data_temp_file.write("static const ushort months_data[] = {\n")
|
data_temp_file.write("static const ushort months_data[] = {\n")
|
||||||
data_temp_file.write(wrap_list(months_data.data))
|
data_temp_file.write(wrap_list(months_data.data))
|
||||||
data_temp_file.write("\n};\n")
|
data_temp_file.write("\n};\n")
|
||||||
@ -612,7 +600,6 @@ def main():
|
|||||||
data_temp_file.write("\n")
|
data_temp_file.write("\n")
|
||||||
|
|
||||||
# Days data
|
# Days data
|
||||||
#check_static_char_array_length("days", days_data.data)
|
|
||||||
data_temp_file.write("static const ushort days_data[] = {\n")
|
data_temp_file.write("static const ushort days_data[] = {\n")
|
||||||
data_temp_file.write(wrap_list(days_data.data))
|
data_temp_file.write(wrap_list(days_data.data))
|
||||||
data_temp_file.write("\n};\n")
|
data_temp_file.write("\n};\n")
|
||||||
@ -620,7 +607,6 @@ def main():
|
|||||||
data_temp_file.write("\n")
|
data_temp_file.write("\n")
|
||||||
|
|
||||||
# AM data
|
# AM data
|
||||||
#check_static_char_array_length("am", am_data.data)
|
|
||||||
data_temp_file.write("static const ushort am_data[] = {\n")
|
data_temp_file.write("static const ushort am_data[] = {\n")
|
||||||
data_temp_file.write(wrap_list(am_data.data))
|
data_temp_file.write(wrap_list(am_data.data))
|
||||||
data_temp_file.write("\n};\n")
|
data_temp_file.write("\n};\n")
|
||||||
@ -628,7 +614,6 @@ def main():
|
|||||||
data_temp_file.write("\n")
|
data_temp_file.write("\n")
|
||||||
|
|
||||||
# PM data
|
# PM data
|
||||||
#check_static_char_array_length("pm", am_data.data)
|
|
||||||
data_temp_file.write("static const ushort pm_data[] = {\n")
|
data_temp_file.write("static const ushort pm_data[] = {\n")
|
||||||
data_temp_file.write(wrap_list(pm_data.data))
|
data_temp_file.write(wrap_list(pm_data.data))
|
||||||
data_temp_file.write("\n};\n")
|
data_temp_file.write("\n};\n")
|
||||||
@ -636,7 +621,6 @@ def main():
|
|||||||
data_temp_file.write("\n")
|
data_temp_file.write("\n")
|
||||||
|
|
||||||
# Currency symbol data
|
# Currency symbol data
|
||||||
#check_static_char_array_length("currency_symbol", currency_symbol_data.data)
|
|
||||||
data_temp_file.write("static const ushort currency_symbol_data[] = {\n")
|
data_temp_file.write("static const ushort currency_symbol_data[] = {\n")
|
||||||
data_temp_file.write(wrap_list(currency_symbol_data.data))
|
data_temp_file.write(wrap_list(currency_symbol_data.data))
|
||||||
data_temp_file.write("\n};\n")
|
data_temp_file.write("\n};\n")
|
||||||
@ -644,7 +628,6 @@ def main():
|
|||||||
data_temp_file.write("\n")
|
data_temp_file.write("\n")
|
||||||
|
|
||||||
# Currency display name data
|
# Currency display name data
|
||||||
#check_static_char_array_length("currency_display_name", currency_display_name_data.data)
|
|
||||||
data_temp_file.write("static const ushort currency_display_name_data[] = {\n")
|
data_temp_file.write("static const ushort currency_display_name_data[] = {\n")
|
||||||
data_temp_file.write(wrap_list(currency_display_name_data.data))
|
data_temp_file.write(wrap_list(currency_display_name_data.data))
|
||||||
data_temp_file.write("\n};\n")
|
data_temp_file.write("\n};\n")
|
||||||
@ -652,13 +635,11 @@ def main():
|
|||||||
data_temp_file.write("\n")
|
data_temp_file.write("\n")
|
||||||
|
|
||||||
# Currency format data
|
# Currency format data
|
||||||
#check_static_char_array_length("currency_format", currency_format_data.data)
|
|
||||||
data_temp_file.write("static const ushort currency_format_data[] = {\n")
|
data_temp_file.write("static const ushort currency_format_data[] = {\n")
|
||||||
data_temp_file.write(wrap_list(currency_format_data.data))
|
data_temp_file.write(wrap_list(currency_format_data.data))
|
||||||
data_temp_file.write("\n};\n")
|
data_temp_file.write("\n};\n")
|
||||||
|
|
||||||
# Endonyms data
|
# Endonyms data
|
||||||
#check_static_char_array_length("endonyms", endonyms_data.data)
|
|
||||||
data_temp_file.write("static const ushort endonyms_data[] = {\n")
|
data_temp_file.write("static const ushort endonyms_data[] = {\n")
|
||||||
data_temp_file.write(wrap_list(endonyms_data.data))
|
data_temp_file.write(wrap_list(endonyms_data.data))
|
||||||
data_temp_file.write("\n};\n")
|
data_temp_file.write("\n};\n")
|
||||||
@ -783,6 +764,7 @@ def main():
|
|||||||
data_temp_file.close()
|
data_temp_file.close()
|
||||||
qlocaledata_file.close()
|
qlocaledata_file.close()
|
||||||
|
|
||||||
|
os.remove(qtsrcdir + "/src/corelib/tools/qlocale_data_p.h")
|
||||||
os.rename(data_temp_file_path, qtsrcdir + "/src/corelib/tools/qlocale_data_p.h")
|
os.rename(data_temp_file_path, qtsrcdir + "/src/corelib/tools/qlocale_data_p.h")
|
||||||
|
|
||||||
# qlocale.h
|
# qlocale.h
|
||||||
@ -844,6 +826,7 @@ def main():
|
|||||||
qlocaleh_temp_file.close()
|
qlocaleh_temp_file.close()
|
||||||
qlocaleh_file.close()
|
qlocaleh_file.close()
|
||||||
|
|
||||||
|
os.remove(qtsrcdir + "/src/corelib/tools/qlocale.h")
|
||||||
os.rename(qlocaleh_temp_file_path, qtsrcdir + "/src/corelib/tools/qlocale.h")
|
os.rename(qlocaleh_temp_file_path, qtsrcdir + "/src/corelib/tools/qlocale.h")
|
||||||
|
|
||||||
# qlocale.qdoc
|
# qlocale.qdoc
|
||||||
@ -862,6 +845,7 @@ def main():
|
|||||||
qlocaleqdoc_temp_file.close()
|
qlocaleqdoc_temp_file.close()
|
||||||
qlocaleqdoc_file.close()
|
qlocaleqdoc_file.close()
|
||||||
|
|
||||||
|
os.remove(qtsrcdir + "/src/corelib/tools/qlocale.qdoc")
|
||||||
os.rename(qlocaleqdoc_temp_file_path, qtsrcdir + "/src/corelib/tools/qlocale.qdoc")
|
os.rename(qlocaleqdoc_temp_file_path, qtsrcdir + "/src/corelib/tools/qlocale.qdoc")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -181,9 +181,13 @@ def _findEntryInFile(file, path, draft=None, attribute=None):
|
|||||||
return (elt.firstChild.nodeValue, None)
|
return (elt.firstChild.nodeValue, None)
|
||||||
|
|
||||||
def findAlias(file):
|
def findAlias(file):
|
||||||
if not doc_cache.has_key(file):
|
doc = False
|
||||||
return False
|
if doc_cache.has_key(file):
|
||||||
doc = doc_cache[file]
|
doc = doc_cache[file]
|
||||||
|
else:
|
||||||
|
doc = xml.dom.minidom.parse(file)
|
||||||
|
doc_cache[file] = doc
|
||||||
|
|
||||||
alias_elt = findChild(doc.documentElement, "alias")
|
alias_elt = findChild(doc.documentElement, "alias")
|
||||||
if not alias_elt:
|
if not alias_elt:
|
||||||
return False
|
return False
|
||||||
@ -242,7 +246,7 @@ def findEntry(base, path, draft=None, attribute=None):
|
|||||||
if result:
|
if result:
|
||||||
return result
|
return result
|
||||||
if not aliaspath:
|
if not aliaspath:
|
||||||
raise Error("findEntry: fatal error: %s: did not found key %s" % (filename, path))
|
raise Error("findEntry: fatal error: %s: can not find key %s" % (filename, path))
|
||||||
path = aliaspath
|
path = aliaspath
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
Loading…
Reference in New Issue
Block a user