diff options
Diffstat (limited to 'util')
-rwxr-xr-x | util/local_database/cldr2qlocalexml.py | 16 | ||||
-rwxr-xr-x | util/local_database/qlocalexml2cpp.py | 15 |
2 files changed, 29 insertions, 2 deletions
diff --git a/util/local_database/cldr2qlocalexml.py b/util/local_database/cldr2qlocalexml.py index a67971b..f0f9cb1 100755 --- a/util/local_database/cldr2qlocalexml.py +++ b/util/local_database/cldr2qlocalexml.py @@ -234,6 +234,18 @@ def generateLocaleInfo(path): result['longTimeFormat'] = convert_date(findEntry(path, "dates/calendars/calendar[gregorian]/timeFormats/timeFormatLength[full]/timeFormat/pattern")) result['shortTimeFormat'] = convert_date(findEntry(path, "dates/calendars/calendar[gregorian]/timeFormats/timeFormatLength[short]/timeFormat/pattern")) + endonym = None + if country_code and script_code: + endonym = findEntryDef(path, "localeDisplayNames/languages/language[type=%s_%s_%s]" % (language_code, script_code, country_code)) + if not endonym and script_code: + endonym = findEntryDef(path, "localeDisplayNames/languages/language[type=%s_%s]" % (language_code, script_code)) + if not endonym and country_code: + endonym = findEntryDef(path, "localeDisplayNames/languages/language[type=%s_%s]" % (language_code, country_code)) + if not endonym: + endonym = findEntryDef(path, "localeDisplayNames/languages/language[type=%s]" % (language_code)) + result['language_endonym'] = endonym + result['country_endonym'] = findEntryDef(path, "localeDisplayNames/territories/territory[type=%s]" % (country_code)) + currency_format = get_number_in_system(path, "numbers/currencyFormats/currencyFormatLength/currencyFormat/pattern", numbering_system) currency_format = parse_number_format(currency_format, result) result['currencyFormat'] = currency_format[0] @@ -687,8 +699,10 @@ print " <localeList>" print \ " <locale>\n\ <language>C</language>\n\ + <languageEndonym></languageEndonym>\n\ <script>AnyScript</script>\n\ <country>AnyCountry</country>\n\ + <countryEndonym></countryEndonym>\n\ <decimal>46</decimal>\n\ <group>44</group>\n\ <list>59</list>\n\ @@ -740,8 +754,10 @@ for key in locale_keys: print " <locale>" print " <language>" + l['language'] + "</language>" + print " <languageEndonym>" + l['language_endonym'].encode('utf-8') + "</languageEndonym>" print " <script>" + l['script'] + "</script>" print " <country>" + l['country'] + "</country>" + print " <countryEndonym>" + l['country_endonym'].encode('utf-8') + "</countryEndonym>" print " <languagecode>" + l['language_code'] + "</languagecode>" print " <scriptcode>" + l['script_code'] + "</scriptcode>" print " <countrycode>" + l['country_code'] + "</countrycode>" diff --git a/util/local_database/qlocalexml2cpp.py b/util/local_database/qlocalexml2cpp.py index f16ecbf..8907435 100755 --- a/util/local_database/qlocalexml2cpp.py +++ b/util/local_database/qlocalexml2cpp.py @@ -237,8 +237,10 @@ def assertSingleChar(string): class Locale: def __init__(self, elt): self.language = eltText(firstChildElt(elt, "language")) + self.languageEndonym = eltText(firstChildElt(elt, "languageEndonym")) self.script = eltText(firstChildElt(elt, "script")) self.country = eltText(firstChildElt(elt, "country")) + self.countryEndonym = eltText(firstChildElt(elt, "countryEndonym")) self.decimal = int(eltText(firstChildElt(elt, "decimal"))) self.group = int(eltText(firstChildElt(elt, "group"))) self.listDelim = int(eltText(firstChildElt(elt, "list"))) @@ -509,6 +511,7 @@ def main(): currency_symbol_data = StringData() currency_display_name_data = StringData() currency_format_data = StringData() + endonyms_data = StringData() # Locale data data_temp_file.write("static const QLocalePrivate locale_data[] = {\n") @@ -521,7 +524,7 @@ def main(): for key in locale_keys: l = locale_map[key] - data_temp_file.write(" { %6d,%6d,%6d,%6d,%6d,%6d,%6d,%6d,%6d,%6d,%6d,%6d,%6d,%6d,%6d,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s, {%s}, %s,%s,%s,%s,%6d,%6d,%6d,%6d,%6d }, // %s/%s/%s\n" \ + data_temp_file.write(" { %6d,%6d,%6d,%6d,%6d,%6d,%6d,%6d,%6d,%6d,%6d,%6d,%6d,%6d,%6d,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s, {%s}, %s,%s,%s,%s,%s,%s,%6d,%6d,%6d,%6d,%6d }, // %s/%s/%s\n" \ % (key[0], key[1], key[2], l.decimal, l.group, @@ -562,6 +565,8 @@ def main(): currency_display_name_data.append(l.currencyDisplayName), currency_format_data.append(l.currencyFormat), currency_format_data.append(l.currencyNegativeFormat), + endonyms_data.append(l.languageEndonym), + endonyms_data.append(l.countryEndonym), l.currencyDigits, l.currencyRounding, l.firstDayOfWeek, @@ -570,7 +575,7 @@ def main(): l.language, l.script, l.country)) - data_temp_file.write(" { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, {0,0,0}, 0,0, 0,0, 0,0, 0,0, 0, 0, 0, 0, 0 } // trailing 0s\n") + data_temp_file.write(" { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, {0,0,0}, 0,0, 0,0, 0,0, 0,0, 0, 0, 0, 0, 0, 0,0, 0,0 } // trailing 0s\n") data_temp_file.write("};\n") data_temp_file.write("\n") @@ -661,6 +666,12 @@ def main(): data_temp_file.write(wrap_list(currency_format_data.data)) data_temp_file.write("\n};\n") + # 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(wrap_list(endonyms_data.data)) + data_temp_file.write("\n};\n") + data_temp_file.write("\n") # Language name list |