#!/usr/bin/env python # -*- mode: python; coding: iso-8859-1 -*- # Copyright © 1996, 1999, 2000 Progiciels Bourbeau-Pinard inc. # François Pinard , 1996. """\ Tripotage temporaire, un fichier `.po' de plusieurs `.scm'. """ import os, sys sys.path.insert(0, os.path.expanduser('~/po/web/lib')) import re, string import FP argv = FP.Argv(sys.argv) def _(text): return text array = [] dict = {} while 1: line = argv.readline() if not line: break while 1: match = re.search('/\(_ ?"', line) if not match: break reference = '%s:%d' % (argv.filename, argv.counter) line = line[match.end():] match = re.match(r'((\\"|[^"])*)"', line) if match: msgid = match.group(1) line = line[match.end():] else: msgid = line while 1: line = argv.readline() if not line: break match = re.match(r'((\\"|[^"])*)"', line) if match: msgid = msgid + match.group(1) line = line[match.end():] break else: msgid = msgid + line if dict.has_key(msgid): dict[msgid].append(reference) else: array.append(msgid) dict[msgid] = [reference] write = sys.stdout.write write(_("""\ # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR Free Software Foundation, Inc. # FIRST AUTHOR , YEAR. # #, fuzzy msgid '' msgstr '' 'Project-Id-Version: PACKAGE VERSION\\n' 'PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n' 'Last-Translator: FULL NAME \\n' 'Language-Team: LANGUAGE \\n' 'MIME-Version: 1.0\\n' 'Content-Type: text/plain; charset=CHARSET\\n' 'Content-Transfer-Encoding: ENCODING\\n' """)) for msgid in array: write('\n') write('#: %s\n' % string.join(dict[msgid])) match = re.search('[^\n]\n+[^\n]', msgid) if match: write('msgid ""\n') msgid = re.sub('\n', r'\\n"\n\"', msgid) msgid = re.sub(r'"\n"$', '', msgid) write('"%s"\n' % msgid) else: msgid = re.sub('\n', r'\n', msgid) write('msgid "%s"\n' % msgid) write('msgstr ""\n')