10000 gh-131725: Generate GNU hash table in `msgfmt.py` by StanFromIreland · Pull Request #131727 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-131725: Generate GNU hash table in msgfmt.py #131727

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Merge branch 'main' into msgfmt-hash
# Conflicts:
#	Lib/test/test_tools/msgfmt_data/general.mo
#	Lib/test/test_tools/test_msgfmt.py
  • Loading branch information
StanFromIreland committed Mar 27, 2025
commit c123d29dd5d75245fadf704678e39b319845835d
22 changes: 22 additions & 0 deletions Lib/test/test_tools/test_msgfmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,28 @@ def test_compilation(self):
def test_hash_table(self):
pass

def test_translations(self):
with open(data_dir / 'general.mo', 'rb') as f:
t = GNUTranslations(f)

self.assertEqual(t.gettext('foo'), 'foo')
self.assertEqual(t.gettext('bar'), 'baz')
self.assertEqual(t.pgettext('abc', 'foo'), 'bar')
self.assertEqual(t.pgettext('xyz', 'foo'), 'bar')
self.assertEqual(t.gettext('Multilinestring'), 'Multilinetranslation')
self.assertEqual(t.gettext('"escapes"'), '"translated"')
self.assertEqual(t.gettext('\n newlines \n'), '\n translated \n')
self.assertEqual(t.ngettext('One email sent.', '%d emails sent.', 1),
'One email sent.')
self.assertEqual(t.ngettext('One email sent.', '%d emails sent.', 2),
'%d emails sent.')
self.assertEqual(t.npgettext('abc', 'One email sent.',
'%d emails sent.', 1),
'One email sent.')
self.assertEqual(t.npgettext('abc', 'One email sent.',
'%d emails sent.', 2),
'%d emails sent.')

def test_po_with_bom(self):
with temp_cwd():
Path('bom.po').write_bytes(b'\xef\xbb\xbfmsgid "Python"\nmsgstr "Pioton"\n')
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.
0