Skip to content

Commit 677f720

Browse files
committed
Cosmetic improvements after review.
PO test files are changed to the generic like other po files.
1 parent d51ad50 commit 677f720

File tree

7 files changed

+20
-26
lines changed

7 files changed

+20
-26
lines changed
3 Bytes
Binary file not shown.
3 Bytes
Binary file not shown.

Lib/test/test_tools/msgfmt_data/file1_fr_crlf.po

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
# French translations for python package.
2-
# Copyright (C) 2018 THE python\'S COPYRIGHT HOLDER
3-
# This file is distributed under the same license as the python package.
4-
# s-ball <[email protected]>, 2018.
1+
# Example of French translations, crlf end of lines
52
#
63
msgid ""
74
msgstr ""
8-
"Project-Id-Version: python 3.8\n"
5+
"Project-Id-Version: PACKAGE VERSION\n"
96
"Report-Msgid-Bugs-To: \n"
107
"POT-Creation-Date: 2018-11-30 23:46+0100\n"
11-
"PO-Revision-Date: 2018-11-30 23:47+0100\n"
12-
"Last-Translator: s-ball <[email protected]>\n"
8+
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
9+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1310
"Language-Team: French\n"
1411
"Language: fr\n"
1512
"MIME-Version: 1.0\n"
3 Bytes
Binary file not shown.

Lib/test/test_tools/msgfmt_data/file2_fr_lf.po

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
# French translations for python package.
2-
# Copyright (C) 2018 THE python'S COPYRIGHT HOLDER
3-
# This file is distributed under the same license as the python package.
4-
# s-ball <[email protected]>, 2018.
1+
# Example of French translations, lf end of lines
52
#
63
msgid ""
74
msgstr ""
8-
"Project-Id-Version: python 3.8\n"
5+
"Project-Id-Version: PACKAGE VERSION\n"
96
"Report-Msgid-Bugs-To: \n"
107
"POT-Creation-Date: 2018-11-30 23:57+0100\n"
11-
"PO-Revision-Date: 2018-11-30 23:57+0100\n"
12-
"Last-Translator: s-ball <[email protected]>\n"
8+
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
9+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1310
"Language-Team: French\n"
1411
"Language: fr\n"
1512
"MIME-Version: 1.0\n"

Lib/test/test_tools/test_msgfmt.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Tests for the Tools/i18n/msgfmt.py tool."""
2+
23
import filecmp
34
import os
45
import shutil
@@ -174,6 +175,7 @@ def update_catalog_snapshots():
174175
for po_file in data_dir.glob('*.po'):
175176
mo_file = po_file.with_suffix('.mo')
176177
compile_messages(po_file, mo_file)
178+
# cannot use compile_message because of both input files
177179
assert_python_ok(msgfmt, '-o', data_dir /'file12_fr.mo',
178180
data_dir / 'file1_fr_crlf.po',
179181
data_dir / 'file2_fr_lf.po')

Tools/i18n/msgfmt.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@
1414
-o file
1515
--output-file=file
1616
Specify the output file to write to. If omitted, output will go to a
17-
file named filename.mo (based off the input file name).
17+
file named filename.mo (based off the input file name(s)).
18+
If more than one input file is given, and if an output file is passed
19+
with -o option, then all the input files are merged. If keys are
20+
repeated (common for "" key for the header) the one from last file is used.
21+
If more than one input file is given, and no -o option is present, then
22+
every input file is compiled in its corresponding mo file (same name
23+
with mo replacing po)
1824
1925
-h
2026
--help
@@ -23,14 +29,6 @@
2329
-V
2430
--version
2531
Display version information and exit.
26-
27-
If more than one input file is given, and if an output file is passed with
28-
-o option, then all the input files are merged. If keys are repeated (common
29-
for "" key for the header) the one from last file is used.
30-
31-
If more than one input file is given, and no -o option is present, then
32-
every input file is compiled in its corresponding mo file (same name with mo
33-
replacing po)
3432
"""
3533

3634
import os
@@ -255,9 +253,9 @@ def writefile(outfile, output):
255253
print(msg, file=sys.stderr)
256254

257255

258-
def main(argv):
256+
def main():
259257
try:
260-
opts, args = getopt.getopt(argv, 'hVo:',
258+
opts, args = getopt.getopt(sys.argv[1:], 'hVo:',
261259
['help', 'version', 'output-file='])
262260
except getopt.error as msg:
263261
usage(1, msg)
@@ -285,4 +283,4 @@ def main(argv):
285283

286284

287285
if __name__ == '__main__':
288-
main(sys.argv[1:])
286+
main()

0 commit comments

Comments
 (0)