From 4a115ab4ae7b6bf0327d35ce23bccab23eb7e460 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Wed, 21 Nov 2012 05:56:21 +0200 Subject: Update Qlocale data up to CLDR 2.0.1 Change-Id: I4279fac57436d7009a6d61dab5936b72fd39fc14 Reviewed-by: Lars Knoll --- util/local_database/enumdata.py | 20 ++++++++++++++++++- util/local_database/xpathlite.py | 42 +++++++++++++++++++++++++++++++++++----- 2 files changed, 56 insertions(+), 6 deletions(-) (limited to 'util/local_database') diff --git a/util/local_database/enumdata.py b/util/local_database/enumdata.py index 06fcb58be5..49f6579648 100644 --- a/util/local_database/enumdata.py +++ b/util/local_database/enumdata.py @@ -281,7 +281,25 @@ language_list = { 233 : [ "Ndonga", "ng" ], 234 : [ "Ojibwa", "oj" ], # macrolanguage 235 : [ "Pali", "pi" ], # macrolanguage - 236 : [ "Walloon", "wa" ] + 236 : [ "Walloon", "wa" ], + 237 : [ "Aghem", "agq" ], + 238 : [ "Basaa", "bas" ], + 239 : [ "Zarma", "dje" ], + 240 : [ "Duala", "dua" ], + 241 : [ "JolaFonyi", "dyo" ], + 242 : [ "Ewondo", "ewo" ], + 243 : [ "Bafia", "ksf" ], + 244 : [ "MakhuwaMeetto", "mgh" ], + 245 : [ "Mundang", "mua" ], + 246 : [ "Kwasio", "nmg" ], + 247 : [ "Nuer", "nus" ], + 248 : [ "Sakha", "sah" ], + 249 : [ "Sangu", "sbp" ], + 250 : [ "Congo Swahili", "swc" ], + 251 : [ "Tasawaq", "twq" ], + 252 : [ "Vai", "vai" ], + 253 : [ "Walser", "wae" ], + 254 : [ "Yangben", "yav" ] } country_list = { diff --git a/util/local_database/xpathlite.py b/util/local_database/xpathlite.py index 5bea6ce63a..02cdc65e04 100644 --- a/util/local_database/xpathlite.py +++ b/util/local_database/xpathlite.py @@ -178,7 +178,11 @@ def _findEntryInFile(file, path, draft=None, attribute=None): if elt.attributes.has_key(attribute): return (elt.attributes[attribute].nodeValue, None) return (None, None) - return (elt.firstChild.nodeValue, None) + try: + return (elt.firstChild.nodeValue, None) + except: + pass + return (None, None) def findAlias(file): doc = False @@ -195,6 +199,36 @@ def findAlias(file): return False return alias_elt.attributes['source'].nodeValue +parent_locales = {} +def _fixedLookupChain(dirname, name): + # see http://www.unicode.org/reports/tr35/#Parent_Locales + if not parent_locales: + for ns in findTagsInFile(dirname + "/../supplemental/supplementalData.xml", "parentLocales"): + tmp = {} + parent_locale = "" + for data in ns[1:][0]: # ns looks like this: [u'parentLocale', [(u'parent', u'root'), (u'locales', u'az_Cyrl bs_Cyrl en_Dsrt ..')]] + tmp[data[0]] = data[1] + if data[0] == u"parent": + parent_locale = data[1] + parent_locales[parent_locale] = tmp[u"locales"].split(" ") + + items = name.split("_") + # split locale name into items and iterate through them from back to front + # example: az_Latn_AZ => [az_Latn_AZ, az_Latn, az] + items = list(reversed(map(lambda x: "_".join(items[:x+1]), range(len(items))))) + + for i in range(len(items)): + item = items[i] + for parent_locale in parent_locales.keys(): + for locale in parent_locales[parent_locale]: + if item == locale: + if parent_locale == u"root": + items = items[:i+1] + else: + items = items[:i+1] + parent_locale.split() + items[i+1:] + return items + return items + def _findEntry(base, path, draft=None, attribute=None): file = base if base.endswith(".xml"): @@ -203,10 +237,8 @@ def _findEntry(base, path, draft=None, attribute=None): else: file = base + ".xml" (dirname, filename) = os.path.split(base) - items = filename.split("_") - # split locale name into items and iterate through them from back to front - # example: az_Latn_AZ => [az_Latn_AZ, az_Latn, az] - items = reversed(map(lambda x: "_".join(items[:x+1]), range(len(items)))) + + items = _fixedLookupChain(dirname, filename) for item in items: file = dirname + "/" + item + ".xml" if os.path.isfile(file): -- cgit v1.2.3