Mercurial > boomslang
annotate scripts/msgfmt.py @ 846:72aa6ca3fddc pyntnclick
Remove stray debugging print
author | Neil Muller <neil@dip.sun.ac.za> |
---|---|
date | Wed, 30 Jan 2013 17:34:58 +0200 |
parents | 99e1e67f3916 |
children |
rev | line source |
---|---|
779
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
1 #! /usr/bin/env python |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
2 # -*- coding: iso-8859-1 -*- |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
3 # Written by Martin v. Löwis <loewis@informatik.hu-berlin.de> |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
4 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
5 """Generate binary message catalog from textual translation description. |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
6 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
7 This program converts a textual Uniforum-style message catalog (.po file) into |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
8 a binary GNU catalog (.mo file). This is essentially the same function as the |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
9 GNU msgfmt program, however, it is a simpler implementation. |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
10 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
11 Usage: msgfmt.py [OPTIONS] filename.po |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
12 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
13 Options: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
14 -o file |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
15 --output-file=file |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
16 Specify the output file to write to. If omitted, output will go to a |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
17 file named filename.mo (based off the input file name). |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
18 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
19 -h |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
20 --help |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
21 Print this message and exit. |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
22 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
23 -V |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
24 --version |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
25 Display version information and exit. |
839
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
26 |
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
27 -s |
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
28 --statistics |
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
29 Display fuzzy and untranslated counts |
779
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
30 """ |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
31 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
32 import os |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
33 import sys |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
34 import ast |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
35 import getopt |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
36 import struct |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
37 import array |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
38 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
39 __version__ = "1.1" |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
40 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
41 MESSAGES = {} |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
42 |
839
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
43 total_fuzzy = 0 |
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
44 total_untrans = 0 |
779
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
45 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
46 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
47 def usage(code, msg=''): |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
48 print >> sys.stderr, __doc__ |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
49 if msg: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
50 print >> sys.stderr, msg |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
51 sys.exit(code) |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
52 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
53 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
54 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
55 def add(id, str, fuzzy): |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
56 "Add a non-fuzzy translation to the dictionary." |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
57 global MESSAGES |
839
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
58 global total_fuzzy |
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
59 global total_untrans |
779
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
60 if not fuzzy and str: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
61 MESSAGES[id] = str |
839
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
62 if fuzzy and str: |
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
63 total_fuzzy += 1 |
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
64 elif not str: |
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
65 total_untrans += 1 |
779
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
66 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
67 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
68 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
69 def generate(): |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
70 "Return the generated output." |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
71 global MESSAGES |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
72 keys = MESSAGES.keys() |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
73 # the keys are sorted in the .mo file |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
74 keys.sort() |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
75 offsets = [] |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
76 ids = strs = '' |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
77 for id in keys: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
78 # For each string, we need size and file offset. Each string is NUL |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
79 # terminated; the NUL does not count into the size. |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
80 offsets.append((len(ids), len(id), len(strs), len(MESSAGES[id]))) |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
81 ids += id + '\0' |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
82 strs += MESSAGES[id] + '\0' |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
83 output = '' |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
84 # The header is 7 32-bit unsigned integers. We don't use hash tables, so |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
85 # the keys start right after the index tables. |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
86 # translated string. |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
87 keystart = 7*4+16*len(keys) |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
88 # and the values start after the keys |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
89 valuestart = keystart + len(ids) |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
90 koffsets = [] |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
91 voffsets = [] |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
92 # The string table first has the list of keys, then the list of values. |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
93 # Each entry has first the size of the string, then the file offset. |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
94 for o1, l1, o2, l2 in offsets: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
95 koffsets += [l1, o1+keystart] |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
96 voffsets += [l2, o2+valuestart] |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
97 offsets = koffsets + voffsets |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
98 output = struct.pack("Iiiiiii", |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
99 0x950412deL, # Magic |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
100 0, # Version |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
101 len(keys), # # of entries |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
102 7*4, # start of key index |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
103 7*4+len(keys)*8, # start of value index |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
104 0, 0) # size and offset of hash table |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
105 output += array.array("i", offsets).tostring() |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
106 output += ids |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
107 output += strs |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
108 return output |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
109 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
110 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
111 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
112 def make(filename, outfile): |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
113 ID = 1 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
114 STR = 2 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
115 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
116 # Compute .mo name from .po name and arguments |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
117 if filename.endswith('.po'): |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
118 infile = filename |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
119 else: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
120 infile = filename + '.po' |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
121 if outfile is None: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
122 outfile = os.path.splitext(infile)[0] + '.mo' |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
123 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
124 try: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
125 lines = open(infile).readlines() |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
126 except IOError, msg: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
127 print >> sys.stderr, msg |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
128 sys.exit(1) |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
129 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
130 section = None |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
131 fuzzy = 0 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
132 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
133 # Parse the catalog |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
134 lno = 0 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
135 for l in lines: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
136 lno += 1 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
137 # If we get a comment line after a msgstr, this is a new entry |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
138 if l[0] == '#' and section == STR: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
139 add(msgid, msgstr, fuzzy) |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
140 section = None |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
141 fuzzy = 0 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
142 # Record a fuzzy mark |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
143 if l[:2] == '#,' and 'fuzzy' in l: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
144 fuzzy = 1 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
145 # Skip comments |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
146 if l[0] == '#': |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
147 continue |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
148 # Now we are in a msgid section, output previous section |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
149 if l.startswith('msgid') and not l.startswith('msgid_plural'): |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
150 if section == STR: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
151 add(msgid, msgstr, fuzzy) |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
152 section = ID |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
153 l = l[5:] |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
154 msgid = msgstr = '' |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
155 is_plural = False |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
156 # This is a message with plural forms |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
157 elif l.startswith('msgid_plural'): |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
158 if section != ID: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
159 print >> sys.stderr, 'msgid_plural not preceeded by msgid on %s:%d' %\ |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
160 (infile, lno) |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
161 sys.exit(1) |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
162 l = l[12:] |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
163 msgid += '\0' # separator of singular and plural |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
164 is_plural = True |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
165 # Now we are in a msgstr section |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
166 elif l.startswith('msgstr'): |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
167 section = STR |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
168 if l.startswith('msgstr['): |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
169 if not is_plural: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
170 print >> sys.stderr, 'plural without msgid_plural on %s:%d' %\ |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
171 (infile, lno) |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
172 sys.exit(1) |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
173 l = l.split(']', 1)[1] |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
174 if msgstr: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
175 msgstr += '\0' # Separator of the various plural forms |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
176 else: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
177 if is_plural: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
178 print >> sys.stderr, 'indexed msgstr required for plural on %s:%d' %\ |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
179 (infile, lno) |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
180 sys.exit(1) |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
181 l = l[6:] |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
182 # Skip empty lines |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
183 l = l.strip() |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
184 if not l: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
185 continue |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
186 l = ast.literal_eval(l) |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
187 if section == ID: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
188 msgid += l |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
189 elif section == STR: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
190 msgstr += l |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
191 else: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
192 print >> sys.stderr, 'Syntax error on %s:%d' % (infile, lno), \ |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
193 'before:' |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
194 print >> sys.stderr, l |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
195 sys.exit(1) |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
196 # Add last entry |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
197 if section == STR: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
198 add(msgid, msgstr, fuzzy) |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
199 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
200 # Compute output |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
201 output = generate() |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
202 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
203 try: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
204 open(outfile,"wb").write(output) |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
205 except IOError,msg: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
206 print >> sys.stderr, msg |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
207 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
208 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
209 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
210 def main(): |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
211 try: |
839
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
212 opts, args = getopt.getopt(sys.argv[1:], 'hVso:', |
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
213 ['help', 'version', 'output-file=', |
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
214 'statistics']) |
779
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
215 except getopt.error, msg: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
216 usage(1, msg) |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
217 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
218 outfile = None |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
219 # parse options |
839
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
220 stats = False |
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
221 global total_fuzzy |
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
222 global total_untrans |
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
223 |
779
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
224 for opt, arg in opts: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
225 if opt in ('-h', '--help'): |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
226 usage(0) |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
227 elif opt in ('-V', '--version'): |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
228 print >> sys.stderr, "msgfmt.py", __version__ |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
229 sys.exit(0) |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
230 elif opt in ('-o', '--output-file'): |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
231 outfile = arg |
839
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
232 elif opt in ('-s', '--statistics'): |
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
233 stats = True |
779
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
234 # do it |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
235 if not args: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
236 print >> sys.stderr, 'No input file given' |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
237 print >> sys.stderr, "Try `msgfmt --help' for more information." |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
238 return |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
239 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
240 for filename in args: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
241 make(filename, outfile) |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
242 |
839
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
243 if stats: |
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
244 print '%s: %d fuzzy strings, %d untranslated strings' % (filename, |
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
245 total_fuzzy, total_untrans) |
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
246 |
779
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
247 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
248 if __name__ == '__main__': |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
249 main() |