Mercurial > pyntnclick
annotate scripts/msgfmt.py @ 839:99e1e67f3916 pyntnclick
Add fuzzy/untranslated stats infowhen producing mo files
author | Neil Muller <neil@dip.sun.ac.za> |
---|---|
date | Wed, 30 Jan 2013 10:33:21 +0200 |
parents | 087d3ff0aa08 |
children | 72aa6ca3fddc |
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 print 'fuzzy', str |
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
64 total_fuzzy += 1 |
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
65 elif not str: |
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
66 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
|
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 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
70 def generate(): |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
71 "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
|
72 global MESSAGES |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
73 keys = MESSAGES.keys() |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
74 # 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
|
75 keys.sort() |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
76 offsets = [] |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
77 ids = strs = '' |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
78 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
|
79 # 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
|
80 # 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
|
81 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
|
82 ids += id + '\0' |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
83 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
|
84 output = '' |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
85 # 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
|
86 # 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
|
87 # translated string. |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
88 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
|
89 # 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
|
90 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
|
91 koffsets = [] |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
92 voffsets = [] |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
93 # 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
|
94 # 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
|
95 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
|
96 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
|
97 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
|
98 offsets = koffsets + voffsets |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
99 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
|
100 0x950412deL, # Magic |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
101 0, # Version |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
102 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
|
103 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
|
104 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
|
105 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
|
106 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
|
107 output += ids |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
108 output += strs |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
109 return output |
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 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
113 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
|
114 ID = 1 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
115 STR = 2 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
116 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
117 # 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
|
118 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
|
119 infile = filename |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
120 else: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
121 infile = filename + '.po' |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
122 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
|
123 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
|
124 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
125 try: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
126 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
|
127 except IOError, msg: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
128 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
|
129 sys.exit(1) |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
130 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
131 section = None |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
132 fuzzy = 0 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
133 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
134 # Parse the catalog |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
135 lno = 0 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
136 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
|
137 lno += 1 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
138 # 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
|
139 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
|
140 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
|
141 section = None |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
142 fuzzy = 0 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
143 # 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
|
144 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
|
145 fuzzy = 1 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
146 # Skip comments |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
147 if l[0] == '#': |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
148 continue |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
149 # 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
|
150 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
|
151 if section == STR: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
152 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
|
153 section = ID |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
154 l = l[5:] |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
155 msgid = msgstr = '' |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
156 is_plural = False |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
157 # 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
|
158 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
|
159 if section != ID: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
160 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
|
161 (infile, lno) |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
162 sys.exit(1) |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
163 l = l[12:] |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
164 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
|
165 is_plural = True |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
166 # 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
|
167 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
|
168 section = STR |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
169 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
|
170 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
|
171 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
|
172 (infile, lno) |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
173 sys.exit(1) |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
174 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
|
175 if msgstr: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
176 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
|
177 else: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
178 if is_plural: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
179 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
|
180 (infile, lno) |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
181 sys.exit(1) |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
182 l = l[6:] |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
183 # Skip empty lines |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
184 l = l.strip() |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
185 if not l: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
186 continue |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
187 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
|
188 if section == ID: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
189 msgid += l |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
190 elif section == STR: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
191 msgstr += l |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
192 else: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
193 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
|
194 'before:' |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
195 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
|
196 sys.exit(1) |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
197 # Add last entry |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
198 if section == STR: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
199 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
|
200 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
201 # Compute output |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
202 output = generate() |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
203 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
204 try: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
205 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
|
206 except IOError,msg: |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
207 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
|
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 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
211 def main(): |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
212 try: |
839
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
213 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
|
214 ['help', 'version', 'output-file=', |
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
215 'statistics']) |
779
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
216 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
|
217 usage(1, msg) |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
218 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
219 outfile = None |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
220 # parse options |
839
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
221 stats = False |
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
222 global total_fuzzy |
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
223 global total_untrans |
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
224 |
779
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
225 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
|
226 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
|
227 usage(0) |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
228 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
|
229 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
|
230 sys.exit(0) |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
231 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
|
232 outfile = arg |
839
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
233 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
|
234 stats = True |
779
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
235 # do it |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
236 if not args: |
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, '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
|
238 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
|
239 return |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
240 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
241 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
|
242 make(filename, outfile) |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
243 |
839
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
244 if stats: |
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
245 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
|
246 total_fuzzy, total_untrans) |
99e1e67f3916
Add fuzzy/untranslated stats infowhen producing mo files
Neil Muller <neil@dip.sun.ac.za>
parents:
779
diff
changeset
|
247 |
779
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
248 |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
249 if __name__ == '__main__': |
087d3ff0aa08
Move po scripts into scripts. Bundle msgfmt.py from cpython too
Stefano Rivera <stefano@rivera.za.net>
parents:
diff
changeset
|
250 main() |