build/buildutils/extractJavaLocFiles_qt.py
changeset 79 2f468c1958d0
parent 26 dc7c549001d5
child 80 d6dafc5d983f
equal deleted inserted replaced
76:4ad59aaee882 79:2f468c1958d0
     9 # Initial Contributors:
     9 # Initial Contributors:
    10 # Nokia Corporation - initial contribution.
    10 # Nokia Corporation - initial contribution.
    11 #
    11 #
    12 # Contributors:
    12 # Contributors:
    13 #
    13 #
    14 # Description: 
    14 # Description:
    15 #
    15 #
    16 #!/usr/bin/python
    16 #!/usr/bin/python
    17 #
    17 #
    18 # This script creates java specific loc zip files from S60 loc zip files
    18 # This script creates java specific loc zip files from S60 loc zip files
    19 # and also creates a "resources.jar" file where all the java loc files
    19 # and also creates a "resources.jar" file where all the java loc files
    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):