Nomenclature change: s/countr/territor/g in locale scripts

Change the nomenclature used in the scripts and the QLocaleXML data
format to use "territory" and "territories" in place of "country" and
"countries". Does not change the generated source files.

Change-Id: I4b208d8d01ad2bfc70d289fa6551f7e0355df5ef
Reviewed-by: JiDe Zhang <zhangjide@uniontech.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Edward Welbourne 2021-05-04 13:20:32 +02:00
parent 21e0ef3ccf
commit e51831260a
7 changed files with 103 additions and 103 deletions

View File

@ -67,7 +67,7 @@ class CldrReader (object):
Yields pairs (have, give) of 4-tuples; if what you have
matches the left member, giving the right member is probably
sensible. Each 4-tuple's entries are the full names of a
language, a script, a country (strictly territory) and a
language, a script, a territory (usually a country) and a
variant (currently ignored)."""
skips = []
for got, use in self.root.likelySubTags():
@ -100,7 +100,7 @@ class CldrReader (object):
def readLocales(self, calendars = ('gregorian',)):
locales = tuple(self.__allLocales(calendars))
return dict(((k.language_id, k.script_id, k.country_id, k.variant_code),
return dict(((k.language_id, k.script_id, k.territory_id, k.variant_code),
k) for k in locales)
def __allLocales(self, calendars):
@ -109,38 +109,38 @@ class CldrReader (object):
for locale in self.root.defaultContentLocales:
try:
language, script, country, variant = self.__splitLocale(locale)
language, script, territory, variant = self.__splitLocale(locale)
except ValueError:
self.whitter(skip(locale, 'only language tag'))
continue
if not (script or country):
if not (script or territory):
self.grumble(skip(locale, 'second tag is neither script nor territory'))
continue
if not (language and country):
if not (language and territory):
continue
try:
yield self.__getLocaleData(self.root.locale(locale), calendars,
language, script, country, variant)
language, script, territory, variant)
except Error as e:
self.grumble(skip(locale, e.message))
for locale in self.root.fileLocales:
try:
chain = self.root.locale(locale)
language, script, country, variant = chain.tagCodes()
language, script, territory, variant = chain.tagCodes()
assert language
# TODO: this skip should probably be based on likely
# sub-tags, instead of empty country: if locale has a
# sub-tags, instead of empty territory: if locale has a
# likely-subtag expansion, that's what QLocale uses,
# and we'll be saving its data for the expanded locale
# anyway, so don't need to record it for itself.
# See also QLocaleXmlReader.loadLocaleMap's grumble.
if not country:
if not territory:
continue
yield self.__getLocaleData(chain, calendars, language, script, country, variant)
yield self.__getLocaleData(chain, calendars, language, script, territory, variant)
except Error as e:
self.grumble('Skipping file locale "{}" ({})\n'.format(locale, e.message))
@ -154,12 +154,12 @@ class CldrReader (object):
def __parseTags(self, locale):
tags = self.__splitLocale(locale)
language = tags.next()
script = country = variant = ''
script = territory = variant = ''
try:
script, country, variant = tags
script, territory, variant = tags
except ValueError:
pass
return tuple(p[1] for p in self.root.codesToIdName(language, script, country, variant))
return tuple(p[1] for p in self.root.codesToIdName(language, script, territory, variant))
def __splitLocale(self, name):
"""Generate (language, script, territory, variant) from a locale name
@ -206,16 +206,16 @@ class CldrReader (object):
tag = tags.next()
self.grumble('Ignoring unparsed cruft {} in {}\n'.format('_'.join(tag + tuple(tags)), name))
def __getLocaleData(self, scan, calendars, language, script, country, variant):
ids, names = zip(*self.root.codesToIdName(language, script, country, variant))
assert ids[0] > 0 and ids[2] > 0, (language, script, country, variant)
def __getLocaleData(self, scan, calendars, language, script, territory, variant):
ids, names = zip(*self.root.codesToIdName(language, script, territory, variant))
assert ids[0] > 0 and ids[2] > 0, (language, script, territory, variant)
locale = Locale(
language = names[0], language_code = language, language_id = ids[0],
script = names[1], script_code = script, script_id = ids[1],
country = names[2], country_code = country, country_id = ids[2],
territory = names[2], territory_code = territory, territory_id = ids[2],
variant_code = variant)
firstDay, weStart, weEnd = self.root.weekData(country)
firstDay, weStart, weEnd = self.root.weekData(territory)
assert all(day in ('mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun')
for day in (firstDay, weStart, weEnd))
@ -223,7 +223,7 @@ class CldrReader (object):
weekendStart = weStart,
weekendEnd = weEnd)
iso, digits, rounding = self.root.currencyData(country)
iso, digits, rounding = self.root.currencyData(territory)
locale.update(currencyIsoCode = iso,
currencyDigits = int(digits),
currencyRounding = int(rounding))
@ -231,7 +231,7 @@ class CldrReader (object):
locale.update(scan.currencyData(iso))
locale.update(scan.numericData(self.root.numberSystem, self.whitter))
locale.update(scan.textPatternData())
locale.update(scan.endonyms(language, script, country, variant))
locale.update(scan.endonyms(language, script, territory, variant))
locale.update(scan.unitData()) # byte, kB, MB, GB, ..., KiB, MiB, GiB, ...
locale.update(scan.calendarNames(calendars)) # Names of days and months
@ -312,36 +312,36 @@ class CldrAccess (object):
except KeyError:
raise Error('Unsupported number system: {}'.format(system))
def weekData(self, country):
def weekData(self, territory):
"""Data on the weekly cycle.
Returns a triple (W, S, E) of en's short names for week-days;
W is the first day of the week, S the start of the week-end
and E the end of the week-end. Where data for a country is
and E the end of the week-end. Where data for a territory is
unavailable, the data for CLDR's territory 001 (The World) is
used."""
try:
return self.__weekData[country]
return self.__weekData[territory]
except KeyError:
return self.__weekData['001']
def currencyData(self, country):
"""Returns currency data for the given country code.
def currencyData(self, territory):
"""Returns currency data for the given territory code.
Return value is a tuple (ISO4217 code, digit count, rounding
mode). If CLDR provides no data for this country, ('', 2, 1)
mode). If CLDR provides no data for this territory, ('', 2, 1)
is the default result.
"""
try:
return self.__currencyData[country]
return self.__currencyData[territory]
except KeyError:
return '', 2, 1
def codesToIdName(self, language, script, country, variant = ''):
def codesToIdName(self, language, script, territory, variant = ''):
"""Maps each code to the appropriate ID and name.
Returns a 4-tuple of (ID, name) pairs corresponding to the
language, script, country and variant given. Raises a
language, script, territory and variant given. Raises a
suitable error if any of them is unknown, indicating all that
are unknown plus suitable names for any that could sensibly be
added to enumdata.py to make them known.
@ -353,13 +353,13 @@ class CldrAccess (object):
try:
return (enum('language')[language],
enum('script')[script],
enum('country')[country],
enum('territory')[territory],
enum('variant')[variant])
except KeyError:
pass
parts, values = [], [language, script, country, variant]
for index, key in enumerate(('language', 'script', 'country', 'variant')):
parts, values = [], [language, script, territory, variant]
for index, key in enumerate(('language', 'script', 'territory', 'variant')):
naming, enums = self.__codeMap(key), enum(key)
value = values[index]
if value not in enums:
@ -372,7 +372,7 @@ class CldrAccess (object):
parts[-1] = 'and ' + parts[-1]
assert parts
raise Error('Unknown ' + ', '.join(parts),
language, script, country, variant)
language, script, territory, variant)
@staticmethod
def __checkEnum(given, proper, scraps,
@ -410,12 +410,12 @@ class CldrAccess (object):
for k in self.__parentLocale.keys():
for f in k.split('_'):
scraps.add(f)
from enumdata import language_map, country_map, script_map
from enumdata import language_map, territory_map, script_map
language = dict((v, k) for k, v in language_map.values() if not v.isspace())
country = dict((v, k) for k, v in country_map.values() if v != 'ZZ')
territory = dict((v, k) for k, v in territory_map.values() if v != 'ZZ')
script = dict((v, k) for k, v in script_map.values() if v != 'Zzzz')
lang = dict(self.__checkEnum(language, self.__codeMap('language'), scraps))
land = dict(self.__checkEnum(country, self.__codeMap('country'), scraps))
land = dict(self.__checkEnum(territory, self.__codeMap('territory'), scraps))
text = dict(self.__checkEnum(script, self.__codeMap('script'), scraps))
if lang or land or text:
grumble("""\
@ -427,7 +427,7 @@ enumdata.py (keeping the old name as an alias):
+ '\n\t'.join('{} -> {}'.format(k, v) for k, v in lang.items())
+ '\n')
if land:
grumble('Country:\n\t'
grumble('Territory:\n\t'
+ '\n\t'.join('{} -> {}'.format(k, v) for k, v in land.items())
+ '\n')
if text:
@ -460,7 +460,7 @@ enumdata.py (keeping the old name as an alias):
</supplementalData>
"""
zones = self.supplement('windowsZones.xml')
enum = self.__enumMap('country')
enum = self.__enumMap('territory')
badZones, unLands, defaults, windows = set(), set(), {}, {}
for name, attrs in zones.find('windowsZones/mapTimezones'):
@ -469,7 +469,7 @@ enumdata.py (keeping the old name as an alias):
wid, code = attrs['other'], attrs['territory']
data = dict(windowsId = wid,
countryCode = code,
territoryCode = code,
ianaList = attrs['type'])
try:
@ -487,11 +487,11 @@ enumdata.py (keeping the old name as an alias):
except KeyError:
unLands.append(code)
continue
data.update(countryId = cid, country = name)
data.update(territoryId = cid, territory = name)
windows[key, cid] = data
if unLands:
raise Error('Unknown country codes, please add to enumdata.py: '
raise Error('Unknown territory codes, please add to enumdata.py: '
+ ', '.join(sorted(unLands)))
if badZones:
@ -580,7 +580,7 @@ enumdata.py (keeping the old name as an alias):
for elt in source.findNodes('currencyData/region'):
iso, digits, rounding = '', 2, 1
try:
country = elt.dom.attributes['iso3166'].nodeValue
territory = elt.dom.attributes['iso3166'].nodeValue
except KeyError:
continue
for child in elt.findAllChildren('currency'):
@ -599,7 +599,7 @@ enumdata.py (keeping the old name as an alias):
'currencyData/fractions/info[iso4217={}]'.format(iso)):
digits = data['digits']
rounding = data['rounding']
cache[country] = iso, digits, rounding
cache[territory] = iso, digits, rounding
assert cache
return cache
@ -673,10 +673,10 @@ enumdata.py (keeping the old name as an alias):
# They're not actually lists: mappings from numeric value
# to pairs of full name and short code. What we want, in
# each case, is a mapping from code to the other two.
from enumdata import language_map, script_map, country_map
from enumdata import language_map, script_map, territory_map
for form, book, empty in (('language', language_map, 'AnyLanguage'),
('script', script_map, 'AnyScript'),
('country', country_map, 'AnyTerritory')):
('territory', territory_map, 'AnyTerritory')):
cache[form] = dict((pair[1], (num, pair[0]))
for num, pair in book.items() if pair[0] != 'C')
# (Have to filter out the C locale, as we give it the
@ -693,7 +693,7 @@ enumdata.py (keeping the old name as an alias):
def __codeMap(self, key, cache = {},
# Maps our name for it to CLDR's name:
naming = {'language': 'languages', 'script': 'scripts',
'country': 'territories', 'variant': 'variants'}):
'territory': 'territories', 'variant': 'variants'}):
if not cache:
root = self.xml('common', 'main', 'en.xml').root.findUniqueChild('localeDisplayNames')
for dst, src in naming.items():

View File

@ -42,7 +42,7 @@ standard output. This file is the input needed by
When you update the CLDR data, be sure to also update
src/corelib/text/qt_attribution.json's entry for unicode-cldr. Check
this script's output for unknown language, country or script messages;
this script's output for unknown language, territory or script messages;
if any can be resolved, use their entry in common/main/en.xml to
append new entries to enumdata.py's lists and update documentation in
src/corelib/text/qlocale.qdoc, adding the new entries in alphabetic

View File

@ -291,13 +291,13 @@ class ZoneIdWriter (SourceFileEditor):
windowsIdData, ianaIdData = ByteArrayData(), ByteArrayData()
# Write Windows/IANA table
out('// Windows ID Key, Country Enum, IANA ID Index\n')
out('// Windows ID Key, Territory Enum, IANA ID Index\n')
out('static const QZoneData zoneDataTable[] = {\n')
for index, data in sorted(windowsIds.items()):
out(' {{ {:6d},{:6d},{:6d} }}, // {} / {}\n'.format(
data['windowsKey'], data['countryId'],
data['windowsKey'], data['territoryId'],
ianaIdData.append(data['ianaList']),
data['windowsId'], data['country']))
data['windowsId'], data['territory']))
out(' { 0, 0, 0 } // Trailing zeroes\n')
out('};\n\n')

View File

@ -28,7 +28,7 @@
#############################################################################
# A run of cldr2qlocalexml.py will produce output reporting any
# language, script and country codes it sees, in data, for which it
# language, script and territory codes it sees, in data, for which it
# can find a name (taken always from en.xml) that could potentially be
# used. There is no point adding a mapping for such a code unless the
# CLDR's common/main/ contains an XML file for at least one locale
@ -36,7 +36,7 @@
# 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 need to be *appended* to this list (for compatibility
# territories 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.
@ -408,7 +408,7 @@ language_aliases = {
'Kirghiz': 'Kyrgyz'
}
country_map = {
territory_map = {
0: ("AnyTerritory", "ZZ"),
1: ("Afghanistan", "AF"),
@ -677,7 +677,7 @@ country_map = {
261: ("Zimbabwe", "ZW"),
}
country_aliases = {
territory_aliases = {
# Renamings prior to Qt 6.0 (CLDR v37):
'DemocraticRepublicOfCongo': 'CongoKinshasa',
'PeoplesRepublicOfCongo': 'CongoBrazzaville',

View File

@ -227,7 +227,7 @@ class LocaleScanner (object):
def tagCodes(self):
"""Yields four tag codes
The tag codes are language, script, country and variant; an
The tag codes are language, script, territory and variant; an
empty value for any of them indicates that no value was
provided. The values are obtained from the primary file's
top-level <identity> element. An Error is raised if any
@ -259,7 +259,7 @@ class LocaleScanner (object):
"""Fetches currency data for this locale.
Single argument, isoCode, is the ISO currency code for the
currency in use in the country. See also numericData, which
currency in use in the territory. See also numericData, which
includes some currency formats.
"""
if isoCode:
@ -347,10 +347,10 @@ class LocaleScanner (object):
stem + '{}Formats/{}FormatLength[{}]/{}Format/pattern'.format(
key, key, pair[1], key))))
def endonyms(self, language, script, country, variant):
def endonyms(self, language, script, territory, variant):
# TODO: take variant into account ?
for seq in ((language, script, country),
(language, script), (language, country), (language,)):
for seq in ((language, script, territory),
(language, script), (language, territory), (language,)):
if not all(seq):
continue
try:
@ -365,9 +365,9 @@ class LocaleScanner (object):
# grumble(failed to find endonym for language)
yield 'languageEndonym', ''
yield ('countryEndonym',
yield ('territoryEndonym',
self.find('localeDisplayNames/territories/territory[{}]'
.format(country), ''))
.format(territory), ''))
def unitData(self):
yield ('byte_unit',

View File

@ -121,18 +121,18 @@ class QLocaleXmlReader (object):
# Lists of (id, name, code) triples:
languages = tuple(self.__loadMap('language'))
scripts = tuple(self.__loadMap('script'))
countries = tuple(self.__loadMap('country'))
territories = tuple(self.__loadMap('territory'))
self.__likely = tuple(self.__likelySubtagsMap())
# Mappings {ID: (name, code)}
self.languages = dict((v[0], v[1:]) for v in languages)
self.scripts = dict((v[0], v[1:]) for v in scripts)
self.countries = dict((v[0], v[1:]) for v in countries)
self.territories = dict((v[0], v[1:]) for v in territories)
# Private mappings {name: (ID, code)}
self.__langByName = dict((v[1], (v[0], v[2])) for v in languages)
self.__textByName = dict((v[1], (v[0], v[2])) for v in scripts)
self.__landByName = dict((v[1], (v[0], v[2])) for v in countries)
self.__landByName = dict((v[1], (v[0], v[2])) for v in territories)
# Other properties:
self.dupes = set(v[1] for v in languages) & set(v[1] for v in countries)
self.dupes = set(v[1] for v in languages) & set(v[1] for v in territories)
self.cldrVersion = self.__firstChildText(self.root, "version")
def loadLocaleMap(self, calendars, grumble = lambda text: None):
@ -142,18 +142,18 @@ class QLocaleXmlReader (object):
locale = Locale.fromXmlData(lambda k: kid(elt, k), calendars)
language = self.__langByName[locale.language][0]
script = self.__textByName[locale.script][0]
country = self.__landByName[locale.country][0]
territory = self.__landByName[locale.territory][0]
if language != 1: # C
if country == 0:
grumble('loadLocaleMap: No country id for "{}"\n'.format(locale.language))
if territory == 0:
grumble('loadLocaleMap: No territory id for "{}"\n'.format(locale.language))
if script == 0:
# Find default script for the given language and country - see:
# Find default script for the given language and territory - see:
# http://www.unicode.org/reports/tr35/#Likely_Subtags
try:
try:
to = likely[(locale.language, 'AnyScript', locale.country)]
to = likely[(locale.language, 'AnyScript', locale.territory)]
except KeyError:
to = likely[(locale.language, 'AnyScript', 'AnyTerritory')]
except KeyError:
@ -162,7 +162,7 @@ class QLocaleXmlReader (object):
locale.script = to[1]
script = self.__textByName[locale.script][0]
yield (language, script, country), locale
yield (language, script, territory), locale
def languageIndices(self, locales):
index = 0
@ -190,11 +190,11 @@ class QLocaleXmlReader (object):
'_'.join(tag(give)), ids(give))
def defaultMap(self):
"""Map language and script to their default country by ID.
"""Map language and script to their default territory by ID.
Yields ((language, script), country) wherever the likely
Yields ((language, script), territory) wherever the likely
sub-tags mapping says language's default locale uses the given
script and country."""
script and territory."""
for have, give in self.__likely:
if have[1:] == ('AnyScript', 'AnyTerritory') and give[2] != 'AnyTerritory':
assert have[0] == give[0], (have, give)
@ -209,7 +209,7 @@ class QLocaleXmlReader (object):
yield int(kid(element, 'id')), kid(element, 'name'), kid(element, 'code')
def __likelySubtagsMap(self):
def triplet(element, keys=('language', 'script', 'country'), kid = self.__firstChildText):
def triplet(element, keys=('language', 'script', 'territory'), kid = self.__firstChildText):
return tuple(kid(element, key) for key in keys)
kid = self.__firstChildElt
@ -334,10 +334,10 @@ class QLocaleXmlWriter (object):
# Output of various sections, in their usual order:
def enumData(self):
from enumdata import language_map, script_map, country_map
from enumdata import language_map, script_map, territory_map
self.__enumTable('language', language_map)
self.__enumTable('script', script_map)
self.__enumTable('country', country_map)
self.__enumTable('territory', territory_map)
def likelySubTags(self, entries):
self.__openTag('likelySubtags')
@ -394,7 +394,7 @@ class QLocaleXmlWriter (object):
self.__openTag(tag)
self.inTag('language', likely[0])
self.inTag('script', likely[1])
self.inTag('country', likely[2])
self.inTag('territory', likely[2])
# self.inTag('variant', likely[3])
self.__closeTag(tag)
@ -436,7 +436,7 @@ class Locale (object):
# Convert from CLDR format-strings to QDateTimeParser ones:
__asfmt = ("longDateFormat", "shortDateFormat", "longTimeFormat", "shortTimeFormat")
# Just use the raw text:
__astxt = ("language", "languageEndonym", "script", "country", "countryEndonym",
__astxt = ("language", "languageEndonym", "script", "territory", "territoryEndonym",
"decimal", "group", "zero",
"list", "percent", "minus", "plus", "exp",
"quotationStart", "quotationEnd",
@ -494,7 +494,7 @@ class Locale (object):
form used by CLDR; its default is ('gregorian',).
"""
get = lambda k: getattr(self, k)
for key in ('language', 'script', 'country'):
for key in ('language', 'script', 'territory'):
write(key, get(key))
write('{}code'.format(key), get('{}_code'.format(key)))
@ -502,7 +502,7 @@ class Locale (object):
'percent', 'minus', 'plus', 'exp'):
write(key, get(key))
for key in ('languageEndonym', 'countryEndonym',
for key in ('languageEndonym', 'territoryEndonym',
'quotationStart', 'quotationEnd',
'alternateQuotationStart', 'alternateQuotationEnd',
'listPatternPartStart', 'listPatternPartMiddle',
@ -591,7 +591,7 @@ class Locale (object):
return cls(cls.__monthNames(calendars),
language='C', language_code='0', languageEndonym='',
script='AnyScript', script_code='0',
country='AnyTerritory', country_code='0', countryEndonym='',
territory='AnyTerritory', territory_code='0', territoryEndonym='',
groupSizes=(3, 3, 1),
decimal='.', group=',', list=';', percent='%',
zero='0', minus='-', plus='+', exp='e',

View File

@ -47,28 +47,28 @@ def compareLocaleKeys(key1, key2):
return key1[0] - key2[0]
defaults = compareLocaleKeys.default_map
# maps {(language, script): country} by ID
# maps {(language, script): territory} by ID
try:
country = defaults[key1[:2]]
territory = defaults[key1[:2]]
except KeyError:
pass
else:
if key1[2] == country:
if key1[2] == territory:
return -1
if key2[2] == country:
if key2[2] == territory:
return 1
if key1[1] == key2[1]:
return key1[2] - key2[2]
try:
country = defaults[key2[:2]]
territory = defaults[key2[:2]]
except KeyError:
pass
else:
if key2[2] == country:
if key2[2] == territory:
return 1
if key1[2] == country:
if key1[2] == territory:
return -1
return key1[1] - key2[1]
@ -327,7 +327,7 @@ class LocaleDataWriter (LocaleSourceEditor):
currency_format_data.append(locale.currencyFormat),
currency_format_data.append(locale.currencyNegativeFormat),
endonyms_data.append(locale.languageEndonym),
endonyms_data.append(locale.countryEndonym)) # 6 entries
endonyms_data.append(locale.territoryEndonym)) # 6 entries
) # Total: 37 entries
assert len(ranges) == 37
@ -341,7 +341,7 @@ class LocaleDataWriter (LocaleSourceEditor):
locale.firstDayOfWeek, locale.weekendStart, locale.weekendEnd,
locale.groupTop, locale.groupHigher, locale.groupLeast) ))
+ ', // {}/{}/{}\n'.format(
locale.language, locale.script, locale.country))
locale.language, locale.script, locale.territory))
self.writer.write(formatLine(*( # All zeros, matching the format:
(0,) * 3 + (0,) * 37 * 2
+ (currencyIsoCodeData(0),)
@ -393,8 +393,8 @@ class LocaleDataWriter (LocaleSourceEditor):
def scriptNames(self, scripts):
self.__writeNameData(self.writer.write, scripts, 'script')
def countryNames(self, countries):
self.__writeNameData(self.writer.write, countries, 'territory')
def territoryNames(self, territories):
self.__writeNameData(self.writer.write, territories, 'territory')
# TODO: unify these next three into the previous three; kept
# separate for now to verify we're not changing data.
@ -405,8 +405,8 @@ class LocaleDataWriter (LocaleSourceEditor):
def scriptCodes(self, scripts):
self.__writeCodeList(self.writer.write, scripts, 'script', 4)
def countryCodes(self, countries): # TODO: unify with countryNames()
self.__writeCodeList(self.writer.write, countries, 'territory', 3)
def territoryCodes(self, territories): # TODO: unify with territoryNames()
self.__writeCodeList(self.writer.write, territories, 'territory', 3)
class CalendarDataWriter (LocaleSourceEditor):
formatCalendar = (
@ -444,7 +444,7 @@ class CalendarDataWriter (LocaleSourceEditor):
(locale.standaloneShortMonths, locale.shortMonths,
locale.standaloneNarrowMonths, locale.narrowMonths)))
except ValueError as e:
e.args += (locale.language, locale.script, locale.country, stem)
e.args += (locale.language, locale.script, locale.territory, stem)
raise
self.writer.write(
@ -452,7 +452,7 @@ class CalendarDataWriter (LocaleSourceEditor):
key +
tuple(r.index for r in ranges) +
tuple(r.length for r in ranges) ))
+ '// {}/{}/{}\n'.format(locale.language, locale.script, locale.country))
+ '// {}/{}/{}\n'.format(locale.language, locale.script, locale.territory))
self.writer.write(self.formatCalendar(*( (0,) * (3 + 6 * 2) ))
+ '// trailing zeros\n')
self.writer.write('};\n')
@ -468,9 +468,9 @@ class LocaleHeaderWriter (SourceFileEditor):
self.__enum('Language', languages, self.__language)
self.writer.write('\n')
def countries(self, countries):
def territories(self, territories):
self.writer.write(" // ### Qt 7: Rename to Territory\n")
self.__enum('Country', countries, self.__country, 'Territory')
self.__enum('Country', territories, self.__territory, 'Territory')
def scripts(self, scripts):
self.__enum('Script', scripts, self.__script)
@ -478,7 +478,7 @@ class LocaleHeaderWriter (SourceFileEditor):
# Implementation details
from enumdata import (language_aliases as __language,
country_aliases as __country,
territory_aliases as __territory,
script_aliases as __script)
def __enum(self, name, book, alias, suffix = None):
@ -562,11 +562,11 @@ def main(args, out, err):
writer.writer.write('\n')
writer.languageNames(reader.languages)
writer.scriptNames(reader.scripts)
writer.countryNames(reader.countries)
writer.territoryNames(reader.territories)
# TODO: merge the next three into the previous three
writer.languageCodes(reader.languages)
writer.scriptCodes(reader.scripts)
writer.countryCodes(reader.countries)
writer.territoryCodes(reader.territories)
except Error as e:
writer.cleanup()
err.write('\nError updating locale data: ' + e.message + '\n')
@ -605,7 +605,7 @@ def main(args, out, err):
try:
writer.languages(reader.languages)
writer.scripts(reader.scripts)
writer.countries(reader.countries)
writer.territories(reader.territories)
except Error as e:
writer.cleanup()
err.write('\nError updating qlocale.h: ' + e.message + '\n')