Tidy up generation of aliases in locale-related enums
Replace lines of formatted output with dictionaries from which that output can be generated efficiently (in sorted order). Tidy up the python code, in the process. Change-Id: Ifb74eb69342646c5dbabc3247b3a8ddef602e934 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
d363113745
commit
cd0a76a150
@ -437,19 +437,19 @@ public:
|
|||||||
Osage = 358,
|
Osage = 358,
|
||||||
Tangut = 359,
|
Tangut = 359,
|
||||||
|
|
||||||
Norwegian = NorwegianBokmal,
|
Afan = Oromo,
|
||||||
|
Bhutani = Dzongkha,
|
||||||
|
Byelorussian = Belarusian,
|
||||||
|
Cambodian = Khmer,
|
||||||
|
Chewa = Nyanja,
|
||||||
|
Frisian = WesternFrisian,
|
||||||
|
Kurundi = Rundi,
|
||||||
Moldavian = Romanian,
|
Moldavian = Romanian,
|
||||||
|
Norwegian = NorwegianBokmal,
|
||||||
|
RhaetoRomance = Romansh,
|
||||||
SerboCroatian = Serbian,
|
SerboCroatian = Serbian,
|
||||||
Tagalog = Filipino,
|
Tagalog = Filipino,
|
||||||
Twi = Akan,
|
Twi = Akan,
|
||||||
Afan = Oromo,
|
|
||||||
Byelorussian = Belarusian,
|
|
||||||
Bhutani = Dzongkha,
|
|
||||||
Cambodian = Khmer,
|
|
||||||
Kurundi = Rundi,
|
|
||||||
RhaetoRomance = Romansh,
|
|
||||||
Chewa = Nyanja,
|
|
||||||
Frisian = WesternFrisian,
|
|
||||||
Uigur = Uighur,
|
Uigur = Uighur,
|
||||||
|
|
||||||
LastLanguage = Tangut
|
LastLanguage = Tangut
|
||||||
@ -868,15 +868,15 @@ public:
|
|||||||
World = 260,
|
World = 260,
|
||||||
Europe = 261,
|
Europe = 261,
|
||||||
|
|
||||||
Tokelau = TokelauCountry,
|
|
||||||
Tuvalu = TuvaluCountry,
|
|
||||||
DemocraticRepublicOfCongo = CongoKinshasa,
|
DemocraticRepublicOfCongo = CongoKinshasa,
|
||||||
PeoplesRepublicOfCongo = CongoBrazzaville,
|
|
||||||
DemocraticRepublicOfKorea = NorthKorea,
|
DemocraticRepublicOfKorea = NorthKorea,
|
||||||
|
LatinAmericaAndTheCaribbean = LatinAmerica,
|
||||||
|
PeoplesRepublicOfCongo = CongoBrazzaville,
|
||||||
RepublicOfKorea = SouthKorea,
|
RepublicOfKorea = SouthKorea,
|
||||||
RussianFederation = Russia,
|
RussianFederation = Russia,
|
||||||
SyrianArabRepublic = Syria,
|
SyrianArabRepublic = Syria,
|
||||||
LatinAmericaAndTheCaribbean = LatinAmerica,
|
Tokelau = TokelauCountry,
|
||||||
|
Tuvalu = TuvaluCountry,
|
||||||
|
|
||||||
LastCountry = Europe
|
LastCountry = Europe
|
||||||
};
|
};
|
||||||
|
@ -27,9 +27,13 @@
|
|||||||
##
|
##
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
# language_list and country_list reflect the current values of enums in qlocale.h
|
# Each *_list reflects the current values of its 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
|
||||||
# need to be *appended* to this list (for compatibility between versions).
|
# countries need to be *appended* to this list (for compatibility
|
||||||
|
# between versions). Include any spaces present in names (scripts
|
||||||
|
# shall squish them out for the enum entries) in *_list, but use the
|
||||||
|
# squished forms of names in the *_aliases mappings.
|
||||||
|
|
||||||
### Qt 6: restore alphabetic order in each list.
|
### Qt 6: restore alphabetic order in each list.
|
||||||
|
|
||||||
language_list = {
|
language_list = {
|
||||||
@ -395,6 +399,25 @@ language_list = {
|
|||||||
359 : ["Tangut", "txg"]
|
359 : ["Tangut", "txg"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
language_aliases = {
|
||||||
|
# Legacy - should disappear at some point:
|
||||||
|
'Norwegian': 'NorwegianBokmal',
|
||||||
|
'Moldavian': 'Romanian',
|
||||||
|
'SerboCroatian': 'Serbian',
|
||||||
|
'Tagalog': 'Filipino',
|
||||||
|
'Twi': 'Akan',
|
||||||
|
# Renamings:
|
||||||
|
'Afan': 'Oromo',
|
||||||
|
'Byelorussian': 'Belarusian',
|
||||||
|
'Bhutani': 'Dzongkha',
|
||||||
|
'Cambodian': 'Khmer',
|
||||||
|
'Kurundi': 'Rundi',
|
||||||
|
'RhaetoRomance': 'Romansh',
|
||||||
|
'Chewa': 'Nyanja',
|
||||||
|
'Frisian': 'WesternFrisian',
|
||||||
|
'Uigur': 'Uighur',
|
||||||
|
}
|
||||||
|
|
||||||
country_list = {
|
country_list = {
|
||||||
0 : ["AnyCountry", "ZZ"],
|
0 : ["AnyCountry", "ZZ"],
|
||||||
1 : ["Afghanistan", "AF"],
|
1 : ["Afghanistan", "AF"],
|
||||||
@ -660,6 +683,20 @@ country_list = {
|
|||||||
261 : ["Europe", "150"]
|
261 : ["Europe", "150"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
country_aliases = {
|
||||||
|
# Deprecated:
|
||||||
|
'Tokelau': 'TokelauCountry',
|
||||||
|
'Tuvalu': 'TuvaluCountry',
|
||||||
|
# Renamings:
|
||||||
|
'DemocraticRepublicOfCongo': 'CongoKinshasa',
|
||||||
|
'PeoplesRepublicOfCongo': 'CongoBrazzaville',
|
||||||
|
'DemocraticRepublicOfKorea': 'NorthKorea',
|
||||||
|
'RepublicOfKorea': 'SouthKorea',
|
||||||
|
'RussianFederation': 'Russia',
|
||||||
|
'SyrianArabRepublic': 'Syria',
|
||||||
|
'LatinAmericaAndTheCaribbean': 'LatinAmerica',
|
||||||
|
}
|
||||||
|
|
||||||
script_list = {
|
script_list = {
|
||||||
0 : ["AnyScript", "Zzzz"],
|
0 : ["AnyScript", "Zzzz"],
|
||||||
1 : ["Arabic", "Arab"],
|
1 : ["Arabic", "Arab"],
|
||||||
@ -805,6 +842,12 @@ script_list = {
|
|||||||
141 : ["Jamo", "Jamo"]
|
141 : ["Jamo", "Jamo"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
script_aliases = {
|
||||||
|
# Renamings:
|
||||||
|
'SimplifiedChineseScript': 'SimplifiedHanScript',
|
||||||
|
'TraditionalChineseScript': 'TraditionalHanScript',
|
||||||
|
}
|
||||||
|
|
||||||
def countryCodeToId(code):
|
def countryCodeToId(code):
|
||||||
if not code:
|
if not code:
|
||||||
return 0
|
return 0
|
||||||
|
@ -38,6 +38,7 @@ import sys
|
|||||||
import tempfile
|
import tempfile
|
||||||
import datetime
|
import datetime
|
||||||
import xml.dom.minidom
|
import xml.dom.minidom
|
||||||
|
from enumdata import language_aliases, country_aliases, script_aliases
|
||||||
|
|
||||||
from localexml import Locale
|
from localexml import Locale
|
||||||
|
|
||||||
@ -751,27 +752,15 @@ def main():
|
|||||||
|
|
||||||
# Language enum
|
# Language enum
|
||||||
qlocaleh_temp_file.write(" enum Language {\n")
|
qlocaleh_temp_file.write(" enum Language {\n")
|
||||||
language = ""
|
language = None
|
||||||
for key in language_map.keys():
|
for key, value in language_map.items():
|
||||||
language = fixedLanguageName(language_map[key][0], dupes)
|
language = fixedLanguageName(value[0], dupes)
|
||||||
qlocaleh_temp_file.write(" " + language + " = " + str(key) + ",\n")
|
qlocaleh_temp_file.write(" " + language + " = " + str(key) + ",\n")
|
||||||
# legacy. should disappear at some point
|
|
||||||
qlocaleh_temp_file.write("\n")
|
qlocaleh_temp_file.write("\n " +
|
||||||
qlocaleh_temp_file.write(" Norwegian = NorwegianBokmal,\n")
|
",\n ".join('%s = %s' % pair
|
||||||
qlocaleh_temp_file.write(" Moldavian = Romanian,\n")
|
for pair in sorted(language_aliases.items())) +
|
||||||
qlocaleh_temp_file.write(" SerboCroatian = Serbian,\n")
|
",\n")
|
||||||
qlocaleh_temp_file.write(" Tagalog = Filipino,\n")
|
|
||||||
qlocaleh_temp_file.write(" Twi = Akan,\n")
|
|
||||||
# renamings
|
|
||||||
qlocaleh_temp_file.write(" Afan = Oromo,\n")
|
|
||||||
qlocaleh_temp_file.write(" Byelorussian = Belarusian,\n")
|
|
||||||
qlocaleh_temp_file.write(" Bhutani = Dzongkha,\n")
|
|
||||||
qlocaleh_temp_file.write(" Cambodian = Khmer,\n")
|
|
||||||
qlocaleh_temp_file.write(" Kurundi = Rundi,\n")
|
|
||||||
qlocaleh_temp_file.write(" RhaetoRomance = Romansh,\n")
|
|
||||||
qlocaleh_temp_file.write(" Chewa = Nyanja,\n")
|
|
||||||
qlocaleh_temp_file.write(" Frisian = WesternFrisian,\n")
|
|
||||||
qlocaleh_temp_file.write(" Uigur = Uighur,\n")
|
|
||||||
qlocaleh_temp_file.write("\n")
|
qlocaleh_temp_file.write("\n")
|
||||||
qlocaleh_temp_file.write(" LastLanguage = " + language + "\n")
|
qlocaleh_temp_file.write(" LastLanguage = " + language + "\n")
|
||||||
qlocaleh_temp_file.write(" };\n")
|
qlocaleh_temp_file.write(" };\n")
|
||||||
@ -780,36 +769,28 @@ def main():
|
|||||||
|
|
||||||
# Script enum
|
# Script enum
|
||||||
qlocaleh_temp_file.write(" enum Script {\n")
|
qlocaleh_temp_file.write(" enum Script {\n")
|
||||||
script = ""
|
script = None
|
||||||
for key in script_map.keys():
|
for key, value in script_map.items():
|
||||||
script = fixedScriptName(script_map[key][0], dupes)
|
script = fixedScriptName(value[0], dupes)
|
||||||
qlocaleh_temp_file.write(" " + script + " = " + str(key) + ",\n")
|
qlocaleh_temp_file.write(" " + script + " = " + str(key) + ",\n")
|
||||||
# renamings
|
qlocaleh_temp_file.write("\n " +
|
||||||
qlocaleh_temp_file.write("\n")
|
",\n ".join('%s = %s' % pair
|
||||||
qlocaleh_temp_file.write(" SimplifiedChineseScript = SimplifiedHanScript,\n")
|
for pair in sorted(script_aliases.items())) +
|
||||||
qlocaleh_temp_file.write(" TraditionalChineseScript = TraditionalHanScript,\n")
|
",\n")
|
||||||
qlocaleh_temp_file.write("\n")
|
qlocaleh_temp_file.write("\n")
|
||||||
qlocaleh_temp_file.write(" LastScript = " + script + "\n")
|
qlocaleh_temp_file.write(" LastScript = " + script + "\n")
|
||||||
qlocaleh_temp_file.write(" };\n")
|
qlocaleh_temp_file.write(" };\n")
|
||||||
|
|
||||||
# Country enum
|
# Country enum
|
||||||
qlocaleh_temp_file.write(" enum Country {\n")
|
qlocaleh_temp_file.write(" enum Country {\n")
|
||||||
country = ""
|
country = None
|
||||||
for key in country_map.keys():
|
for key, value in country_map.items():
|
||||||
country = fixedCountryName(country_map[key][0], dupes)
|
country = fixedCountryName(value[0], dupes)
|
||||||
qlocaleh_temp_file.write(" " + country + " = " + str(key) + ",\n")
|
qlocaleh_temp_file.write(" " + country + " = " + str(key) + ",\n")
|
||||||
# deprecated
|
qlocaleh_temp_file.write("\n " +
|
||||||
qlocaleh_temp_file.write("\n")
|
",\n ".join('%s = %s' % pair
|
||||||
qlocaleh_temp_file.write(" Tokelau = TokelauCountry,\n")
|
for pair in sorted(country_aliases.items())) +
|
||||||
qlocaleh_temp_file.write(" Tuvalu = TuvaluCountry,\n")
|
",\n")
|
||||||
# renamings
|
|
||||||
qlocaleh_temp_file.write(" DemocraticRepublicOfCongo = CongoKinshasa,\n")
|
|
||||||
qlocaleh_temp_file.write(" PeoplesRepublicOfCongo = CongoBrazzaville,\n")
|
|
||||||
qlocaleh_temp_file.write(" DemocraticRepublicOfKorea = NorthKorea,\n")
|
|
||||||
qlocaleh_temp_file.write(" RepublicOfKorea = SouthKorea,\n")
|
|
||||||
qlocaleh_temp_file.write(" RussianFederation = Russia,\n")
|
|
||||||
qlocaleh_temp_file.write(" SyrianArabRepublic = Syria,\n")
|
|
||||||
qlocaleh_temp_file.write(" LatinAmericaAndTheCaribbean = LatinAmerica,\n")
|
|
||||||
qlocaleh_temp_file.write("\n")
|
qlocaleh_temp_file.write("\n")
|
||||||
qlocaleh_temp_file.write(" LastCountry = " + country + "\n")
|
qlocaleh_temp_file.write(" LastCountry = " + country + "\n")
|
||||||
qlocaleh_temp_file.write(" };\n")
|
qlocaleh_temp_file.write(" };\n")
|
||||||
@ -836,7 +817,7 @@ def main():
|
|||||||
qlocaleqdoc_temp_file = os.fdopen(qlocaleqdoc_temp_file, "w")
|
qlocaleqdoc_temp_file = os.fdopen(qlocaleqdoc_temp_file, "w")
|
||||||
qlocaleqdoc_file = open(qtsrcdir + "/src/corelib/tools/qlocale.qdoc", "r")
|
qlocaleqdoc_file = open(qtsrcdir + "/src/corelib/tools/qlocale.qdoc", "r")
|
||||||
s = qlocaleqdoc_file.readline()
|
s = qlocaleqdoc_file.readline()
|
||||||
DOCSTRING=" QLocale's data is based on Common Locale Data Repository "
|
DOCSTRING = " QLocale's data is based on Common Locale Data Repository "
|
||||||
while s:
|
while s:
|
||||||
if DOCSTRING in s:
|
if DOCSTRING in s:
|
||||||
qlocaleqdoc_temp_file.write(DOCSTRING + "v" + cldr_version + ".\n")
|
qlocaleqdoc_temp_file.write(DOCSTRING + "v" + cldr_version + ".\n")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user