Esempio n. 1
0
 def parse_inline_text(self, text):
     text = text.replace('\n', ' ')
     if not text.startswith('!'):
         result = self.probably_translate(text)
         if result:
             super(Parser, self).parse_inline_text(result)
     else:
         result = []
         for t, tx in simplemarkdown.iter_split2(text[1:], '_(', ')_'):
             if t:
                 result.append(t)
             if tx:
                 result.append(self.probably_translate(tx))
         if None not in result:
             super(Parser, self).parse_inline_text(''.join(result))
Esempio n. 2
0
 def parse_inline_text(self, text):
     text = text.replace('\n', ' ')
     if not text.startswith('!'):
         result = self.probably_translate(text)
         if result:
             super(Parser, self).parse_inline_text(result)
     else:
         result = []
         for t, tx in simplemarkdown.iter_split2(text[1:], '_(', ')_'):
             if t:
                 result.append(t)
             if tx:
                 result.append(self.probably_translate(tx))
         if None not in result:
             super(Parser, self).parse_inline_text(''.join(result))
Esempio n. 3
0
 def translate(self, s):
     self.write('#: {0}:{1}\n'.format(self._curfilename, self.lineno))
     # is there markdown formatting in the string?
     formatting = False
     for c in '[]', '**', '``':
         for t, t2 in simplemarkdown.iter_split2(s, *c):
             formatting = bool(t2)
             break
         if formatting:
             self.write('#. NOTE: markdown formatting\n')
             break
     s = s.replace('\\', '\\\\').replace('"', '\\"')
     lines = self.wrapper.wrap(s)
     if len(lines) > 1:
         self.write('msgid ""\n')
         for l in lines[:-1]:
             self.write(('"' + l + ' "\n'))
         self.write(('"' + lines[-1] + '"\n'))
     else:
         self.write(('msgid "' + lines[0] + '"\n'))
     self.write('msgstr ""\n\n')
Esempio n. 4
0
 def translate(self, s):
     self.f.write('#: {0}:{1}\n'.format(self._curfilename, self.lineno))
     # is there markdown formatting in the string?
     formatting = False
     for c in '[]', '**', '``':
         for t, t2 in simplemarkdown.iter_split2(s, *c):
             formatting = bool(t2)
             break
         if formatting:
             self.f.write('#. NOTE: markdown formatting\n')
             break
     s = s.replace('\\', '\\\\').replace('"', '\\"')
     lines = self.wrapper.wrap(s)
     if len(lines) > 1:
         self.f.write('msgid ""\n')
         for l in lines[:-1]:
             self.f.write(('"' + l + ' "\n').encode('utf8'))
         self.f.write(('"' + lines[-1] + '"\n').encode('utf8'))
     else:
         self.f.write(('msgid "' + lines[0] + '"\n').encode('utf8'))
     self.f.write('msgstr ""\n\n')