Пример #1
0
Файл: po.py Проект: eher04/FRP
 def produceNiceDefault(self):
     '''Transforms self.default into a nice msg.'''
     self.default = produceNiceMessage(self.default)
Пример #2
0
 def walkAppyType(self):
     """Walks into the Appy type definition and gathers data about the
        i18n labels."""
     # Manage things common to all Appy types
     # - optional ?
     if self.appyType.optional:
         self.generator.tool.addOptionalField(self)
     # - edit default value ?
     if self.appyType.editDefault:
         self.generator.tool.addDefaultField(self)
     # - put an index on this field?
     if self.appyType.indexed and (self.fieldName != "title"):
         self.classDescr.addIndexMethod(self)
     # i18n labels
     messages = self.generator.labels
     if not self.appyType.label:
         # Create labels for generating them in i18n files, only if required.
         i18nPrefix = "%s_%s" % (self.classDescr.name, self.fieldName)
         if self.appyType.hasLabel:
             messages.append(self.produceMessage(i18nPrefix))
         if self.appyType.hasDescr:
             descrId = i18nPrefix + "_descr"
             messages.append(self.produceMessage(descrId, isLabel=False))
         if self.appyType.hasHelp:
             helpId = i18nPrefix + "_help"
             messages.append(self.produceMessage(helpId, isLabel=False))
     # Create i18n messages linked to pages and phases, only if there is more
     # than one page/phase for the class.
     ppMsgs = []
     if len(self.classDescr.getPhases()) > 1:
         # Create the message for the name of the phase
         phaseName = self.appyType.page.phase
         msgId = "%s_phase_%s" % (self.classDescr.name, phaseName)
         ppMsgs.append(PoMessage(msgId, "", produceNiceMessage(phaseName)))
     if len(self.classDescr.getPages()) > 1:
         # Create the message for the name of the page
         pageName = self.appyType.page.name
         msgId = "%s_page_%s" % (self.classDescr.name, pageName)
         ppMsgs.append(PoMessage(msgId, "", produceNiceMessage(pageName)))
     for poMsg in ppMsgs:
         if poMsg not in messages:
             messages.append(poMsg)
             self.classDescr.labelsToPropagate.append(poMsg)
     # Create i18n messages linked to groups
     group = self.appyType.group
     if group and not group.label:
         group.generateLabels(messages, self.classDescr, set())
     # Manage things which are specific to String types
     if self.appyType.type == "String":
         self.walkString()
     # Manage things which are specific to Actions
     elif self.appyType.type == "Action":
         self.walkAction()
     # Manage things which are specific to Ref types
     elif self.appyType.type == "Ref":
         self.walkRef()
     # Manage things which are specific to Pod types
     elif self.appyType.type == "Pod":
         self.walkPod()
     # Manage things which are specific to List types
     elif self.appyType.type == "List":
         self.walkList()
Пример #3
0
 def produceNiceDefault(self):
     '''Transforms self.default into a nice msg.'''
     self.default = produceNiceMessage(self.default)
Пример #4
0
 def walkAppyType(self):
     '''Walks into the Appy type definition and gathers data about the
        i18n labels.'''
     # Manage things common to all Appy types
     # - optional ?
     if self.appyType.optional:
         self.generator.tool.addOptionalField(self)
     # - edit default value ?
     if self.appyType.editDefault:
         self.generator.tool.addDefaultField(self)
     # - put an index on this field?
     if self.appyType.indexed and (self.fieldName != 'title'):
         self.classDescr.addIndexMethod(self)
     # i18n labels
     messages = self.generator.labels
     if not self.appyType.label:
         # Create labels for generating them in i18n files, only if required.
         i18nPrefix = "%s_%s" % (self.classDescr.name, self.fieldName)
         if self.appyType.hasLabel:
             messages.append(self.produceMessage(i18nPrefix))
         if self.appyType.hasDescr:
             descrId = i18nPrefix + '_descr'
             messages.append(self.produceMessage(descrId, isLabel=False))
         if self.appyType.hasHelp:
             helpId = i18nPrefix + '_help'
             messages.append(self.produceMessage(helpId, isLabel=False))
     # Create i18n messages linked to pages and phases, only if there is more
     # than one page/phase for the class.
     ppMsgs = []
     if len(self.classDescr.getPhases()) > 1:
         # Create the message for the name of the phase
         phaseName = self.appyType.page.phase
         msgId = '%s_phase_%s' % (self.classDescr.name, phaseName)
         ppMsgs.append(PoMessage(msgId, '', produceNiceMessage(phaseName)))
     if len(self.classDescr.getPages()) > 1:
         # Create the message for the name of the page
         pageName = self.appyType.page.name
         msgId = '%s_page_%s' % (self.classDescr.name, pageName)
         ppMsgs.append(PoMessage(msgId, '', produceNiceMessage(pageName)))
     for poMsg in ppMsgs:
         if poMsg not in messages:
             messages.append(poMsg)
             self.classDescr.labelsToPropagate.append(poMsg)
     # Create i18n messages linked to groups
     group = self.appyType.group
     if group and not group.label:
         group.generateLabels(messages, self.classDescr, set())
     # Manage things which are specific to String types
     if self.appyType.type == 'String':
         self.walkString()
         # Manage things which are specific to Actions
     elif self.appyType.type == 'Action':
         self.walkAction()
         # Manage things which are specific to Ref types
     elif self.appyType.type == 'Ref':
         self.walkRef()
         # Manage things which are specific to Pod types
     elif self.appyType.type == 'Pod':
         self.walkPod()
         # Manage things which are specific to List types
     elif self.appyType.type == 'List':
         self.walkList()