Skip to content

gh-130197: Test various encodings with pygettext #132244

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
38 changes: 38 additions & 0 deletions Lib/test/test_tools/i18n_data/encodings/latin2.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2000-01-01 00:00+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"


#. ascii text
#: latin2.py:7
msgid "foo"
msgstr ""

#. latin-2 text
#: latin2.py:10
msgid "Ř ř"
msgstr ""

#. non-latin-2 text
#: latin2.py:13
msgid "α β"
msgstr ""

#. ascii text with non-ascii comment
#. Ř ř
#: latin2.py:17
msgid "bar"
msgstr ""

17 changes: 17 additions & 0 deletions Lib/test/test_tools/i18n_data/encodings/latin2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# -*- coding: iso-8859-2 -*-

from gettext import gettext as _


# ascii text
_('foo')

# latin-2 text
_('Ø ø')

# non-latin-2 text
_('\u03b1 \u03b2')

# ascii text with non-ascii comment
# Ø ø
_('bar')
38 changes: 38 additions & 0 deletions Lib/test/test_tools/i18n_data/encodings/latin2_escaped.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2000-01-01 00:00+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"


#. ascii text
#: latin2.py:7
msgid "foo"
msgstr ""

#. latin-2 text
#: latin2.py:10
msgid "\305\230 \305\231"
msgstr ""

#. non-latin-2 text
#: latin2.py:13
msgid "\316\261 \316\262"
msgstr ""

#. ascii text with non-ascii comment
#. Ř ř
#: latin2.py:17
msgid "bar"
msgstr ""

3 changes: 3 additions & 0 deletions Lib/test/test_tools/test_i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,9 @@ def extract_from_snapshots():
'escapes.py': ('--escape', '--add-comments='),
# Escape only ascii and let unicode pass through:
('escapes.py', 'ascii-escapes.pot'): ('--add-comments=',),
# Test input files with various encodings:
('encodings/latin2.py', 'encodings/latin2.pot'): ('--add-comments=',),
('encodings/latin2.py', 'encodings/latin2_escaped.pot'): ('--add-comments=', '--escape'),
}

for filename, args in snapshots.items():
Expand Down
1 change: 1 addition & 0 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -2644,6 +2644,7 @@ TESTSUBDIRS= idlelib/idle_test \
test/test_tomllib/data/valid/multiline-basic-str \
test/test_tools \
test/test_tools/i18n_data \
test/test_tools/i18n_data/encodings \
test/test_tools/msgfmt_data \
test/test_ttk \
test/test_unittest \
Expand Down
Loading