40 'javasensor', |
40 'javasensor', |
41 'javassl', |
41 'javassl', |
42 'javausermessages', |
42 'javausermessages', |
43 'javaapplicationsettings', |
43 'javaapplicationsettings', |
44 # loc files for qt |
44 # loc files for qt |
|
45 'common_errors', |
45 'javaapplicationinstaller', |
46 'javaapplicationinstaller', |
|
47 'javaapplicationinstallererrors', |
46 'javaapplicationsecuritymessages', |
48 'javaapplicationsecuritymessages', |
47 'javaruntimeapplicationsettings', |
49 'javaruntimeapplicationsettings', |
48 'javaruntimecertificatemanagement' |
50 'javaruntimecertificatemanagement' |
49 ] |
51 ] |
50 |
52 |
104 id = message.get("id") |
106 id = message.get("id") |
105 translation = message.find("translation") |
107 translation = message.find("translation") |
106 |
108 |
107 # Sanity check - we have no good plurality support for qt-localisation |
109 # Sanity check - we have no good plurality support for qt-localisation |
108 if translation.find("numerusform") != None: |
110 if translation.find("numerusform") != None: |
109 raise Exception("Conversion error at %s / %s: numerus form (qt plurality) is not supported" % (filename, id)) |
111 print "WARNING at %s / %s: numerus form (qt plurality) is not supported" % (filename, id) |
110 |
112 |
|
113 numerusforms = translation.findall("numerusform") |
111 lengthvariant = translation.find("lengthvariant") |
114 lengthvariant = translation.find("lengthvariant") |
112 if lengthvariant != None: |
115 if lengthvariant != None: |
113 text = lengthvariant.text |
116 text = lengthvariant.text |
|
117 elif len(numerusforms) > 0: |
|
118 text = numerusforms[0].text |
114 else: |
119 else: |
115 text = translation.text |
120 text = translation.text |
116 |
121 |
117 # If text is not found, this is unlocalised engineering English file |
122 # If text is not found, this is unlocalised engineering English file |
118 if text == None: |
123 if text == None: |
119 text = message.find("source").text |
124 text = message.find("source").text |
120 |
125 |
121 # Sanity check - no newlines in text allowed |
126 # Escape characters |
122 if "\n" in text: |
127 text = text.replace("\\", "\\\\") |
123 raise Exception("Conversion error in %s / %s: newline found" % (filename, id)) |
128 text = text.replace("\n", "\\n") |
124 |
129 text = text.replace("\t", "\\t") |
|
130 text = text.replace("\"", "\\\"") |
|
131 text = text.replace("'", "\\'") |
|
132 |
125 messages.append((id, text)) |
133 messages.append((id, text)) |
126 |
134 |
127 return messages |
135 return messages |
128 |
136 |
129 def writeLoc(filename, messages): |
137 def writeLoc(filename, messages): |