#!/usr/bin/env python # -*- mode: python; coding: iso-8859-1 -*- # Copyright © 1996, 1998, 1999, 2000 Progiciels Bourbeau-Pinard inc. # François Pinard , 1996. """\ Convert an X/Open .msg file to GNU gettext .po format. """ import os, sys sys.path.insert(0, os.path.expanduser('~/po/web/lib')) from fp import * argv = Argv(sys.argv[1:]) def _(text): return text while 1: line = argv.readline() count = count + 1 if not line: break if re.match('$', line): continue match = re.match('set [0-9]+ #(.*)', line) if match: program = match.group(1) continue match = re.match(r'\$ #([0-9]+) Original Message:\((.*)\)$', line) if match: out('\n') out(_('#. Message no %s\n') % match.group(1)) if program: out('#: %s:1\n' % program) out('msgid "%s"\n' % match.group(2)) continue match = re.match(r'\$ #([0-9]+)', line) if match: out('\n') out(_('#. Message no %s\n') % match.group(1)) if program: out('#: %s:1\n' % program) out(_('msgid "*** Unknown - message no %s ***"\n') % match.group(1)) continue match = re.match(r'# (.*)\\$', line) if match: out('msgstr ""\n"%s"\n' % match.group(1)) while 1: line = sys.stdin.readline() count = count + 1 if not line: break match = re.match(r'(.*)\\$', line) if match: out('"%s"\n' % match.group(1)) else: line = line[:-1] out('"%s"\n' % line) break continue match = re.match('# (.*)$', line) if match: out('msgstr "%s"\n' % match.group(1)) continue sys.stderr.write(_(':%d: ERROR: %s') % (count, line))