summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorZeno Albisser <zeno.albisser@nokia.com>2011-02-16 13:18:22 (GMT)
committerZeno Albisser <zeno.albisser@nokia.com>2011-02-22 11:54:16 (GMT)
commitaa9bc750eb72a180f15be144d2cc6621289f59f5 (patch)
treeb562ff99bb9d7d201d75e66948c7dd9caab02a1b /util
parent42ce38bc4db41ece082fba963f483a4ebfd78a01 (diff)
downloadQt-aa9bc750eb72a180f15be144d2cc6621289f59f5.zip
Qt-aa9bc750eb72a180f15be144d2cc6621289f59f5.tar.gz
Qt-aa9bc750eb72a180f15be144d2cc6621289f59f5.tar.bz2
Implemented QLocale::quoteString(...)
Reviewed-by: Denis Dzyubenko Task-number: QTBUG-17096
Diffstat (limited to 'util')
-rwxr-xr-xutil/local_database/cldr2qlocalexml.py12
-rwxr-xr-xutil/local_database/qlocalexml2cpp.py18
2 files changed, 27 insertions, 3 deletions
diff --git a/util/local_database/cldr2qlocalexml.py b/util/local_database/cldr2qlocalexml.py
index b873565..0bc1664 100755
--- a/util/local_database/cldr2qlocalexml.py
+++ b/util/local_database/cldr2qlocalexml.py
@@ -199,6 +199,10 @@ def generateLocaleInfo(path):
result['minus'] = get_number_in_system(path, "numbers/symbols/minusSign", numbering_system)
result['plus'] = get_number_in_system(path, "numbers/symbols/plusSign", numbering_system)
result['exp'] = get_number_in_system(path, "numbers/symbols/exponential", numbering_system).lower()
+ result['quotationStart'] = findEntry(path, "delimiters/quotationStart")
+ result['quotationEnd'] = findEntry(path, "delimiters/quotationEnd")
+ result['alternateQuotationStart'] = findEntry(path, "delimiters/alternateQuotationStart")
+ result['alternateQuotationEnd'] = findEntry(path, "delimiters/alternateQuotationEnd")
result['am'] = findEntry(path, "dates/calendars/calendar[gregorian]/dayPeriods/dayPeriodContext[format]/dayPeriodWidth[wide]/dayPeriod[am]", draft)
result['pm'] = findEntry(path, "dates/calendars/calendar[gregorian]/dayPeriods/dayPeriodContext[format]/dayPeriodWidth[wide]/dayPeriod[pm]", draft)
result['longDateFormat'] = convert_date(findEntry(path, "dates/calendars/calendar[gregorian]/dateFormats/dateFormatLength[full]/dateFormat/pattern"))
@@ -600,6 +604,10 @@ print \
<minus>45</minus>\n\
<plus>43</plus>\n\
<exp>101</exp>\n\
+ <quotationStart>\"</quotationStart>\n\
+ <quotationEnd>\"</quotationEnd>\n\
+ <alternateQuotationStart>\'</alternateQuotationStart>\n\
+ <alternateQuotationEnd>\'</alternateQuotationEnd>\n\
<am>AM</am>\n\
<pm>PM</pm>\n\
<firstDayOfWeek>mon</firstDayOfWeek>\n\
@@ -644,6 +652,10 @@ for key in locale_keys:
print " <minus>" + ordStr(l['minus']) + "</minus>"
print " <plus>" + ordStr(l['plus']) + "</plus>"
print " <exp>" + fixOrdStrExp(l['exp']) + "</exp>"
+ print " <quotationStart>" + l['quotationStart'].encode('utf-8') + "</quotationStart>"
+ print " <quotationEnd>" + l['quotationEnd'].encode('utf-8') + "</quotationEnd>"
+ print " <alternateQuotationStart>" + l['alternateQuotationStart'].encode('utf-8') + "</alternateQuotationStart>"
+ print " <alternateQuotationEnd>" + l['alternateQuotationEnd'].encode('utf-8') + "</alternateQuotationEnd>"
print " <am>" + l['am'].encode('utf-8') + "</am>"
print " <pm>" + l['pm'].encode('utf-8') + "</pm>"
print " <firstDayOfWeek>" + l['firstDayOfWeek'].encode('utf-8') + "</firstDayOfWeek>"
diff --git a/util/local_database/qlocalexml2cpp.py b/util/local_database/qlocalexml2cpp.py
index 2f998f3..6b8fdb9 100755
--- a/util/local_database/qlocalexml2cpp.py
+++ b/util/local_database/qlocalexml2cpp.py
@@ -195,6 +195,10 @@ def convertToQtDayOfWeek(firstDay):
qtDayOfWeek = {"mon":1, "tue":2, "wed":3, "thu":4, "fri":5, "sat":6, "sun":7}
return qtDayOfWeek[firstDay]
+def assertSingleChar(string):
+ assert len(string) == 1, "This string is not allowed to be longer than 1 character"
+ return string
+
class Locale:
def __init__(self, elt):
self.language = eltText(firstChildElt(elt, "language"))
@@ -207,6 +211,10 @@ class Locale:
self.minus = int(eltText(firstChildElt(elt, "minus")))
self.plus = int(eltText(firstChildElt(elt, "plus")))
self.exp = int(eltText(firstChildElt(elt, "exp")))
+ self.quotationStart = ord(assertSingleChar(eltText(firstChildElt(elt, "quotationStart"))))
+ self.quotationEnd = ord(assertSingleChar(eltText(firstChildElt(elt, "quotationEnd"))))
+ self.alternateQuotationStart = ord(assertSingleChar(eltText(firstChildElt(elt, "alternateQuotationStart"))))
+ self.alternateQuotationEnd = ord(assertSingleChar(eltText(firstChildElt(elt, "alternateQuotationEnd"))))
self.am = eltText(firstChildElt(elt, "am"))
self.pm = eltText(firstChildElt(elt, "pm"))
self.firstDayOfWeek = convertToQtDayOfWeek(eltText(firstChildElt(elt, "firstDayOfWeek")))
@@ -433,7 +441,7 @@ def main():
# Locale data
data_temp_file.write("static const QLocalePrivate locale_data[] = {\n")
- data_temp_file.write("// lang terr dec group list prcnt zero minus plus exp sDtFmt lDtFmt sTmFmt lTmFmt ssMonth slMonth sMonth lMonth sDays lDays am,len pm,len\n")
+ data_temp_file.write("// lang terr dec group list prcnt zero minus plus exp quotStart quotEnd altQuotStart altQuotEnd sDtFmt lDtFmt sTmFmt lTmFmt ssMonth slMonth sMonth lMonth sDays lDays am,len pm,len\n")
locale_keys = locale_map.keys()
compareLocaleKeys.default_map = default_map
@@ -443,7 +451,7 @@ def main():
for key in locale_keys:
l = locale_map[key]
- data_temp_file.write(" { %6d,%6d,%6d,%6d,%6d,%6d,%6d,%6d,%6d,%6d,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s, {%s}, %s,%s,%s,%s,%6d,%6d,%6d }, // %s/%s\n" \
+ data_temp_file.write(" { %6d,%6d,%6d,%6d,%6d,%6d,%6d,%6d,%6d,%6d,%6d,%6d,%6d,%6d,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s, {%s}, %s,%s,%s,%s,%6d,%6d,%6d }, // %s/%s\n" \
% (key[0], key[1],
l.decimal,
l.group,
@@ -453,6 +461,10 @@ def main():
l.minus,
l.plus,
l.exp,
+ l.quotationStart,
+ l.quotationEnd,
+ l.alternateQuotationStart,
+ l.alternateQuotationEnd,
date_format_data.append(l.shortDateFormat),
date_format_data.append(l.longDateFormat),
time_format_data.append(l.shortTimeFormat),
@@ -481,7 +493,7 @@ def main():
l.firstDayOfWeek,
l.language,
l.country))
- data_temp_file.write(" { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, {0,0,0}, 0,0, 0,0, 0,0, 0,0, 0, 0, 0 } // trailing 0s\n")
+ data_temp_file.write(" { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, {0,0,0}, 0,0, 0,0, 0,0, 0,0, 0, 0, 0 } // trailing 0s\n")
data_temp_file.write("};\n")
data_temp_file.write("\n")