summaryrefslogtreecommitdiffstats
path: root/util/local_database/qlocalexml2cpp.py
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2012-11-19 19:12:58 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-11-19 21:18:03 +0100
commitda90a3a490b452154391676857ac2ffc269d4843 (patch)
tree9671ccef3d69ea168425d703c08ead4809bc5f4c /util/local_database/qlocalexml2cpp.py
parentb256c47d625c519a88fe9dd96611015445776434 (diff)
QLocale: replace hard-coded default country-for-language map
...with a generated one in a way similar to what http://www.unicode.org/reports/tr35/#Likely_Subtags suggests. The supplemental/likelySubtags.xml contains all the required data. This changes some default countries to a most-expected ones. Change-Id: I920a5623601d8661a943e78197d3bcc838191483 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'util/local_database/qlocalexml2cpp.py')
-rwxr-xr-xutil/local_database/qlocalexml2cpp.py34
1 files changed, 26 insertions, 8 deletions
diff --git a/util/local_database/qlocalexml2cpp.py b/util/local_database/qlocalexml2cpp.py
index cb243652fc..b225d4fba5 100755
--- a/util/local_database/qlocalexml2cpp.py
+++ b/util/local_database/qlocalexml2cpp.py
@@ -129,16 +129,29 @@ def loadCountryMap(doc):
return result
-def loadDefaultMap(doc):
+def loadLikelySubtagsMap(doc):
result = {}
- list_elt = firstChildElt(doc.documentElement, "defaultCountryList")
- elt = firstChildElt(list_elt, "defaultCountry")
+ i = 0
+ list_elt = firstChildElt(doc.documentElement, "likelySubtags")
+ elt = firstChildElt(list_elt, "likelySubtag")
while elt:
- country = eltText(firstChildElt(elt, "country"));
- language = eltText(firstChildElt(elt, "language"));
- result[language] = country;
- elt = nextSiblingElt(elt, "defaultCountry");
+ elt_from = firstChildElt(elt, "from")
+ from_language = eltText(firstChildElt(elt_from, "language"));
+ from_script = eltText(firstChildElt(elt_from, "script"));
+ from_country = eltText(firstChildElt(elt_from, "country"));
+
+ elt_to = firstChildElt(elt, "to")
+ to_language = eltText(firstChildElt(elt_to, "language"));
+ to_script = eltText(firstChildElt(elt_to, "script"));
+ to_country = eltText(firstChildElt(elt_to, "country"));
+
+ tmp = {}
+ tmp["from"] = (from_language, from_script, from_country)
+ tmp["to"] = (to_language, to_script, to_country)
+ result[i] = tmp;
+ i += 1
+ elt = nextSiblingElt(elt, "likelySubtag");
return result
def fixedScriptName(name, dupes):
@@ -459,7 +472,12 @@ def main():
language_map = loadLanguageMap(doc)
script_map = loadScriptMap(doc)
country_map = loadCountryMap(doc)
- default_map = loadDefaultMap(doc)
+ likely_subtags_map = loadLikelySubtagsMap(doc)
+ default_map = {}
+ for key in likely_subtags_map.keys():
+ tmp = likely_subtags_map[key]
+ if tmp["from"][2] == "AnyCountry" and tmp["to"][2] != "AnyCountry" and tmp["from"][1] == "AnyScript":
+ default_map[tmp["to"][0]] = tmp["to"][2]
locale_map = loadLocaleMap(doc, language_map, script_map, country_map)
dupes = findDupes(language_map, country_map)