Skip to content

Commit 625465d

Browse files
committed
feat: make msgfmt.py support -o flag
Make msgfmt.py support -o flag like gnu msgfmt. This allows: make -C locale local_install MSGFMT="python3 ../roundup/msgfmt.py" to compile locale files for use when running roundup_server in development mode.
1 parent 914c269 commit 625465d

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

CHANGES.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ Features:
149149
weekly-report,schema-dump.py, roundup-reminder, copy-user.py,
150150
dump_dbm_sessions_db.py, contributors.py (John Rouillard)
151151
- roundup/msgfile.py can now be called as 'python msgfmt.py de.po de.mo'
152-
to compile a translation file if msgfmt is missing. (John Rouillard)
152+
or 'python msgfmt.py -o de.mo de.po' to compile a translation file if
153+
GNU msgfmt is missing. (John Rouillard)
153154
- save roundup-admin history between sessions. Load
154155
~/.roundup_admin_rlrc file to set history-size persistently. Add
155156
pragma history_length to override for a session. (John Rouillard)

doc/developers.txt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,18 @@ which will compile the ``.po`` source files into binary
129129
``.mo`` files and install them under
130130
``locale/locale/<LANGUAGE_CODE>/LC_MESSAGES/roundup.mo``. For
131131
German this will be
132-
``locale/locale/de/LC_MESSAGES/roundup.mo``. You will need
133-
``msgfmt`` from the the GNU gettext tools to be installed on
134-
your system. In a pinch you can invoke ``python roundup/msgfmt.py
135-
po_file mo_file`` to compile your .po file to a .mo file. It's slow
136-
but seems to work in basic tests. The msgfmt.py file is used by
137-
Roundup to compile out of date .po files.
132+
``locale/locale/de/LC_MESSAGES/roundup.mo``.
133+
134+
By default this requires ``msgfmt`` from the the GNU gettext tools
135+
installed on your system. If you do not have ``msgfmt`` installed, you
136+
can use:
137+
138+
make -C locale local_install MSGFMT="python3 ../roundup/msgfmt.py"
139+
140+
Also to compile a single .po file, you can invoke ``python
141+
roundup/msgfmt.py po_file mo_file`` to compile your .po file to a .mo
142+
file. It's slow but seems to work in basic tests. The msgfmt.py file
143+
is used by Roundup to compile out of date .po files.
138144

139145
Submitting Changes
140146
------------------

roundup/msgfmt.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,18 @@ def getAsFile(self):
288288
# a really dumb attempt to make this into a command
289289
# Usage: python msgfmy.py <input_file>.po <output_file>.mo
290290
import sys
291-
292-
mo = Msgfmt(sys.argv[1]).get()
293-
with open(sys.argv[2], 'wb') as mofile:
291+
input_filename = ""
292+
output_filename = ""
293+
294+
if sys.argv[1] == "-o":
295+
output_filename = sys.argv[2]
296+
input_filename = sys.argv[3]
297+
else:
298+
input_filename = sys.argv[1]
299+
output_filename = sys.argv[2]
300+
301+
mo = Msgfmt(input_filename).get()
302+
with open(output_filename, 'wb') as mofile:
294303
mofile.write(mo)
295304
mofile.close()
296305

0 commit comments

Comments
 (0)