Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-79516: allow msgfmt.py to compile multiple input po files#10875

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
s-ball wants to merge68 commits intopython:main
base:main
Choose a base branch
Loading
froms-ball:multi_inputs
Open
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
68 commits
Select commitHold shift + click to select a range
73b5ac8
Add test for current behaviour of msgfmt.py
s-ballDec 2, 2018
5fb1575
Final fix for bpo-9741, with tests proving it.
s-ballDec 2, 2018
b1968e9
Update docstrings for the script and make function
s-ballDec 2, 2018
0bc4ad3
Give make a simpler and more consistent interface.
s-ballDec 4, 2018
a9e67b4
Add a Misc/NEWS.d entry.
s-ballDec 5, 2018
6c59d6c
Merge branch 'multi_inputs' of https://github.com/s-ball/cpython into…
s-ballDec 5, 2018
1ce22c0
Merge branch 'main' into multi_inputs
s-ballJan 23, 2025
863bd97
Merge branch 'main' into multi_inputs
s-ballJan 23, 2025
4390ede
Fix an import error in test_i18n.py .
s-ballJan 23, 2025
008ea27
Fix another import error.
s-ballJan 23, 2025
8744743
Merge branch 'main' into multi_inputs
s-ballJan 23, 2025
93a6eb7
Merge branch 'main' into multi_inputs
s-ballFeb 23, 2025
ba26b80
Revert version number to 1.2
s-ballFeb 23, 2025
150cea1
Merge branch 'main' into multi_inputs
s-ballFeb 23, 2025
d9afabb
Merge branch 'main' into multi_inputs
s-ballFeb 24, 2025
9004387
Merge branch 'main' into multi_inputs
s-ballFeb 24, 2025
7556f79
Merge branch 'multi_inputs' of https://github.com/s-ball/cpython into…
s-ballFeb 27, 2025
80947d1
Merge branch 'main' into multi_inputs
s-ballFeb 27, 2025
12acb83
Merge branch 'main' into multi_inputs
s-ballFeb 27, 2025
1ecc1f3
Fix a merge error
s-ballFeb 27, 2025
e59ba68
Merge branch 'multi_inputs' of https://github.com/s-ball/cpython into…
s-ballFeb 27, 2025
4ffd20a
Merge branch 'main' into multi_inputs
s-ballFeb 27, 2025
7505f2b
Merge branch 'main' into multi_inputs
s-ballFeb 28, 2025
2c27120
Merge branch 'main' into multi_inputs
s-ballFeb 28, 2025
1f4e5ac
fix details
merwokFeb 28, 2025
4170796
Merge branch 'main' into multi_inputs
s-ballMar 1, 2025
46c08c5
Move tests for the gh-79516 issue to test_msgfmt.py
s-ballMar 1, 2025
24d89a6
Cosmetic improvements after review.
s-ballMar 1, 2025
17b4e05
Fix an import error
s-ballMar 1, 2025
bfc8a44
Merge branch 'main' into multi_inputs
s-ballMar 1, 2025
106dd40
Apply suggestions from code review
s-ballMar 2, 2025
9cb9395
Cosmetic improvements after review.
s-ballMar 2, 2025
08bc8d7
In test_msgfmt move data files to the data folder.
s-ballMar 2, 2025
9d992cd
Remove duplicate tests from test_msgfmt.
s-ballMar 2, 2025
31fd434
Merge branch 'main' into multi_inputs
s-ballMar 2, 2025
916aec7
Merge branch 'main' into multi_inputs
s-ballMar 2, 2025
51fcf09
Rename data files for test_msgfmt.Test_multi_input
s-ballMar 3, 2025
d51ad50
Apply suggestions from code review
s-ballMar 3, 2025
677f720
Cosmetic improvements after review.
s-ballMar 3, 2025
b4ea80a
compile_messages now accepts several input files
s-ballMar 4, 2025
3120add
whitespace nit
merwokMar 4, 2025
d642923
Merge branch 'main' into multi_inputs
s-ballMar 4, 2025
9d91f12
Make explicit how mo files can be re-generated.
s-ballMar 4, 2025
4d83cb7
Merge branch 'multi_inputs' of https://github.com/s-ball/cpython into…
s-ballMar 4, 2025
421272b
Apply suggestions from code review
s-ballMar 4, 2025
09b97d9
Update Lib/test/test_tools/test_msgfmt.py
s-ballMar 4, 2025
12cae51
Merge branch 'main' into multi_inputs
s-ballMar 5, 2025
3760851
Merge branch 'main' into multi_inputs
s-ballMar 15, 2025
d45039c
Generate json files for MultiInputTest data files.
s-ballMar 16, 2025
dde5ef1
Apply suggestions from code review
s-ballMar 16, 2025
bb6e0c5
Cosmetic improvements (long lines...)
s-ballMar 16, 2025
797990a
Merge branch 'multi_inputs' of https://github.com/s-ball/cpython into…
s-ballMar 16, 2025
c95af16
Merge branch 'main' into multi_inputs
s-ballMar 17, 2025
905ec70
Revert an unwanted change.
s-ballMar 17, 2025
b7a7c48
Simplifies the general logic of msgfmt.py
s-ballMar 18, 2025
1b3b73e
Update Tools/i18n/msgfmt.py
s-ballMar 18, 2025
1db2c66
Changes per review.
s-ballMar 18, 2025
3a6e1ef
Merge branch 'multi_inputs' of https://github.com/s-ball/cpython into…
s-ballMar 18, 2025
743bdc5
Removes the now unused get_names function.
s-ballMar 19, 2025
50e7145
Tests for extension corner cases for msgfmt.py
s-ballMar 19, 2025
caa8955
Merge branch 'main' into multi_inputs
s-ballApr 4, 2025
a4f1769
Fix a parameter inversion in test_msgfmt.py
s-ballApr 4, 2025
11f6e69
Merge branch 'main' into multi_inputs
s-ballApr 4, 2025
0ed3107
Merge branch 'main' into multi_inputs
s-ballApr 8, 2025
d1e0a26
Merge branch 'main' into multi_inputs
s-ballApr 8, 2025
213afcb
Merge branch 'main' into multi_inputs
s-ballMay 20, 2025
4d54e50
Merge main into multi_inputs
s-ballMay 22, 2025
ab97edd
Merge branch 'main' into multi_inputs
s-ballMay 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Cosmetic improvements after review.
PO test files are changed to the generic like other po files.
  • Loading branch information
@s-ball
s-ball committedMar 3, 2025
commit677f720c0540613d15d06356f7a9cafffe5c2e4a
Binary file modifiedLib/test/test_tools/msgfmt_data/file12_fr.mo
View file
Open in desktop
Binary file not shown.
Binary file modifiedLib/test/test_tools/msgfmt_data/file1_fr_crlf.mo
View file
Open in desktop
Binary file not shown.
11 changes: 4 additions & 7 deletionsLib/test/test_tools/msgfmt_data/file1_fr_crlf.po
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
# French translations for python package.
# Copyright (C) 2018 THE python\'S COPYRIGHT HOLDER
# This file is distributed under the same license as the python package.
# s-ball <s-ball@laposte.net>, 2018.
# Example of French translations, crlf end of lines
#
msgid ""
msgstr ""
"Project-Id-Version:python 3.8\n"
"Project-Id-Version:PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-11-30 23:46+0100\n"
"PO-Revision-Date:2018-11-30 23:47+0100\n"
"Last-Translator:s-ball <s-ball@laposte.net>\n"
"PO-Revision-Date:YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator:FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: French\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
Expand Down
Binary file modifiedLib/test/test_tools/msgfmt_data/file2_fr_lf.mo
View file
Open in desktop
Binary file not shown.
11 changes: 4 additions & 7 deletionsLib/test/test_tools/msgfmt_data/file2_fr_lf.po
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
# French translations for python package.
# Copyright (C) 2018 THE python'S COPYRIGHT HOLDER
# This file is distributed under the same license as the python package.
# s-ball <s-ball@laposte.net>, 2018.
# Example of French translations, lf end of lines
#
msgid ""
msgstr ""
"Project-Id-Version:python 3.8\n"
"Project-Id-Version:PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-11-30 23:57+0100\n"
"PO-Revision-Date:2018-11-30 23:57+0100\n"
"Last-Translator:s-ball <s-ball@laposte.net>\n"
"PO-Revision-Date:YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator:FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: French\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
Expand Down
2 changes: 2 additions & 0 deletionsLib/test/test_tools/test_msgfmt.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
"""Tests for the Tools/i18n/msgfmt.py tool."""

import filecmp
import os
import shutil
Expand DownExpand Up@@ -174,6 +175,7 @@ def update_catalog_snapshots():
for po_file in data_dir.glob('*.po'):
mo_file = po_file.with_suffix('.mo')
compile_messages(po_file, mo_file)
# cannot use compile_message because of both input files
assert_python_ok(msgfmt, '-o', data_dir /'file12_fr.mo',
data_dir / 'file1_fr_crlf.po',
data_dir / 'file2_fr_lf.po')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I would use compile_messages, not assert_python_ok

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The problem is that compile_message only supports one single input po file. Do you suggest that I should change the behavior ofcompile_message?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Ah… would it be a big change?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Not so big. It should be ready before end of today.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Done. It was enough to swap parameters and allow an arbitrary number for the second through a*...

merwok reacted with hooray emoji
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Ah, I assumed that compile_messages came from the tool being tested or the gettext module, but now I see it’s also a test helper – and it calls assert_python_ok!
So it didn’t matter after all. But it’s nice (in a very minor way) that the same function is used here.

Expand Down
22 changes: 10 additions & 12 deletionsTools/i18n/msgfmt.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,7 +14,13 @@
-o file
--output-file=file
Specify the output file to write to. If omitted, output will go to a
file named filename.mo (based off the input file name).
file named filename.mo (based off the input file name(s)).
If more than one input file is given, and if an output file is passed
with -o option, then all the input files are merged. If keys are
repeated (common for "" key for the header) the one from last file is used.
If more than one input file is given, and no -o option is present, then
every input file is compiled in its corresponding mo file (same name
with mo replacing po)

-h
--help
Expand All@@ -23,14 +29,6 @@
-V
--version
Display version information and exit.

If more than one input file is given, and if an output file is passed with
-o option, then all the input files are merged. If keys are repeated (common
for "" key for the header) the one from last file is used.

If more than one input file is given, and no -o option is present, then
every input file is compiled in its corresponding mo file (same name with mo
replacing po)
"""

import os
Expand DownExpand Up@@ -255,9 +253,9 @@ def writefile(outfile, output):
print(msg, file=sys.stderr)


def main(argv):
def main():
try:
opts, args = getopt.getopt(argv, 'hVo:',
opts, args = getopt.getopt(sys.argv[1:], 'hVo:',
['help', 'version', 'output-file='])
except getopt.error as msg:
usage(1, msg)
Expand DownExpand Up@@ -285,4 +283,4 @@ def main(argv):


if __name__ == '__main__':
main(sys.argv[1:])
main()
Loading

[8]ページ先頭

©2009-2025 Movatter.jp