Skip to content

Commit d5f02cd

Browse files
committed
feat: make msgfmt.py a simple CLI replacement for msgfmt(1)
Simplify testing .po files if the tester doesn't have access to GNU gettest tools or doesn't want to install the python Babel package. Also mentioned in developers.txt.
1 parent fdced12 commit d5f02cd

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

CHANGES.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ Features:
121121
document. (John Rouillard)
122122
- multiple scripts/... updates - Python3, linting, enhancements:
123123
weekly-report,schema-dump.py, roundup-reminder, copy-user.py,
124-
dump_dbm_sessions_db.py, contributors.py (John Rouillard)c
124+
dump_dbm_sessions_db.py, contributors.py (John Rouillard)
125+
- roundup/msgfile.py can now be called as 'python msgfmt.py de.po de.mo'
126+
to compile a translation file if msgfmt is missing. (John Rouillard)
125127

126128

127129
2023-07-13 2.3.0

doc/developers.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@ which will compile the ``.po`` source files into binary
131131
German this will be
132132
``locale/locale/de/LC_MESSAGES/roundup.mo``. You will need
133133
``msgfmt`` from the the GNU gettext tools to be installed on
134-
your system.
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.
135138

136139
Submitting Changes
137140
------------------

roundup/msgfmt.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,3 +282,15 @@ def read(self, header_only=False):
282282

283283
def getAsFile(self):
284284
return BytesIO(self.get())
285+
286+
287+
if __name__ == '__main__':
288+
# a really dumb attempt to make this into a command
289+
# Usage: python msgfmy.py <input_file>.po <output_file>.mo
290+
import sys
291+
292+
mo = Msgfmt(sys.argv[1]).get()
293+
with open(sys.argv[2], 'wb') as mofile:
294+
mofile.write(mo)
295+
mofile.close()
296+

0 commit comments

Comments
 (0)