countrymap = {}
scriptmap = {}
localemap = {}
+# main lists
+imperiallist = []
# cross-reference maps
localescriptmap = {}
localefirstdaymap = {}
# locale to script parsing
tree = ET.parse('common/supplemental/supplementalData.xml')
root = tree.getroot()
-for supllanguage in root.findall('./languageData/language'):
- supllanguagetype = supllanguage.get('type')
- supllanguagescripts = supllanguage.get('scripts')
- localescriptmap[supllanguagetype] = supllanguagescripts
+for suppllanguage in root.findall('./languageData/language'):
+ suppllanguagetype = suppllanguage.get('type')
+ suppllanguagescripts = suppllanguage.get('scripts')
+ localescriptmap[suppllanguagetype] = suppllanguagescripts
# locale to first day parsing
for firstday in root.findall('./weekData/firstDay'):
if defaultnumbersystem is not None:
numbertype = defaultnumbersystem.text
- # find values from suplemental maps
+ # find values from supplemental maps
if langtype:
for key in scriptmap.keys():
if localescriptmap[langtype] == scriptmap[key][0]:
printlocaledata(localemap, key)
print('};')
-print('static const qint16 localeTblSize = sizeof(localeTbl) / sizeof(QLocalePrivate);')
+print('static const qint16 localeTblSize = sizeof(localeTbl) / sizeof(QLocalePrivate);\n')
+
+# imperial parsing
+tree = ET.parse('common/supplemental/supplementalData.xml')
+root = tree.getroot()
+for measurementsystem in root.findall('./measurementData/measurementSystem'):
+ measurementsystemtype = measurementsystem.get('type')
+ if measurementsystemtype in ('UK', 'US'):
+ territories = measurementsystem.get('territories')
+ for territory in territories.split(' '):
+ countryenum = None
+ languageenum = None
+ for key in countrymap.keys():
+ countrycode = countrymap[key][0]
+ if countrycode == territory:
+ countryenum = key
+ break
+ imperiallist.append(countryenum)
+
+print('''static const QLocale::Country imperialTbl[] = {''')
+
+for string in sorted(imperiallist):
+ print(' QLocale::Country::%s,' % string)
+
+print('};')
+print('static const qint16 imperialTblSize = sizeof(imperialTbl);')
\ No newline at end of file
QLocale::MeasurementSystem QLocalePrivate::measurementSystem() const
{
- for (int i = 0; i < ImperialMeasurementSystemsCount; ++i) {
- if (ImperialMeasurementSystems[i].languageId == m_language
- && ImperialMeasurementSystems[i].countryId == m_country) {
+ for (int i = 0; i < imperialTblSize; ++i) {
+ if (imperialTbl[i] == m_country) {
return QLocale::ImperialSystem;
}
}
QT_BEGIN_NAMESPACE
-/* This part of the file isn't generated, but written by hand since
- * Unicode CLDR doesn't contain measurement system information.
- */
-struct CountryLanguage
-{
- const quint16 languageId;
- const quint16 countryId;
-};
-static const CountryLanguage ImperialMeasurementSystems[] = {
- { 31, 225 },
- { 31, 226 },
- { 111, 225 },
- { 163, 225 }
-};
-static const short ImperialMeasurementSystemsCount =
- sizeof(ImperialMeasurementSystems)/sizeof(ImperialMeasurementSystems[0]);
-
/*
This part of the file was generated from Common Locale Data Repository v35
};
static const qint16 localeTblSize = sizeof(localeTbl) / sizeof(QLocalePrivate);
+static const QLocale::Country imperialTbl[] = {
+ QLocale::Country::Bahamas,
+ QLocale::Country::Belize,
+ QLocale::Country::CaymanIslands,
+ QLocale::Country::Liberia,
+ QLocale::Country::MyanmarBurma,
+ QLocale::Country::Palau,
+ QLocale::Country::PuertoRico,
+ QLocale::Country::UnitedKingdom,
+ QLocale::Country::UnitedStates,
+};
+static const qint16 imperialTblSize = sizeof(imperialTbl);
+
// GENERATED PART ENDS HERE
QT_END_NAMESPACE