Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
bded4d3b
Commit
bded4d3b
authored
Jul 17, 2008
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make gettext Unicode interface consistent and clean up the docs.
parent
6a9475f6
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
112 deletions
+89
-112
Doc/library/gettext.rst
Doc/library/gettext.rst
+79
-92
Lib/gettext.py
Lib/gettext.py
+8
-18
Misc/NEWS
Misc/NEWS
+2
-2
No files found.
Doc/library/gettext.rst
View file @
bded4d3b
This diff is collapsed.
Click to expand it.
Lib/gettext.py
View file @
bded4d3b
...
...
@@ -304,26 +304,16 @@ class GNUTranslations(NullTranslations):
# cause no problems since us-ascii should always be a subset of
# the charset encoding. We may want to fall back to 8-bit msgids
# if the Unicode conversion fails.
charset
=
self
.
_charset
or
'ascii'
if
b'
\
x00
'
in
msg
:
# Plural forms
msgid1
,
msgid2
=
msg
.
split
(
b'
\
x00
'
)
tmsg
=
tmsg
.
split
(
b'
\
x00
'
)
if
self
.
_charset
:
msgid1
=
str
(
msgid1
,
self
.
_charset
)
tmsg
=
[
str
(
x
,
self
.
_charset
)
for
x
in
tmsg
]
else
:
msgid1
=
str
(
msgid1
)
tmsg
=
[
str
(
x
)
for
x
in
tmsg
]
for
i
in
range
(
len
(
tmsg
)):
catalog
[(
msgid1
,
i
)]
=
tmsg
[
i
]
msgid1
=
str
(
msgid1
,
charset
)
for
i
,
x
in
enumerate
(
tmsg
):
catalog
[(
msgid1
,
i
)]
=
str
(
x
,
charset
)
else
:
if
self
.
_charset
:
msg
=
str
(
msg
,
self
.
_charset
)
tmsg
=
str
(
tmsg
,
self
.
_charset
)
else
:
msg
=
str
(
msg
)
tmsg
=
str
(
tmsg
)
catalog
[
msg
]
=
tmsg
catalog
[
str
(
msg
,
charset
)]
=
str
(
tmsg
,
charset
)
# advance to next entry in the seek tables
masteridx
+=
8
transidx
+=
8
...
...
@@ -359,7 +349,7 @@ class GNUTranslations(NullTranslations):
if
tmsg
is
missing
:
if
self
.
_fallback
:
return
self
.
_fallback
.
gettext
(
message
)
return
str
(
message
)
return
message
return
tmsg
def
ngettext
(
self
,
msgid1
,
msgid2
,
n
):
...
...
@@ -369,9 +359,9 @@ class GNUTranslations(NullTranslations):
if
self
.
_fallback
:
return
self
.
_fallback
.
ngettext
(
msgid1
,
msgid2
,
n
)
if
n
==
1
:
tmsg
=
str
(
msgid1
)
tmsg
=
msgid1
else
:
tmsg
=
str
(
msgid2
)
tmsg
=
msgid2
return
tmsg
...
...
Misc/NEWS
View file @
bded4d3b
...
...
@@ -47,8 +47,8 @@ Library
code of every single module of the standard library, including invalid files
used in the test suite.
-
All the u* variant functions and methods in gettext have been renamed to their
none u* siblings
.
-
The gettext library now consistently uses Unicode strings for message ids
and message strings, and ``ugettext()`` and the like don't exist anymore
.
- The traceback module has been expanded to handle chained exceptions.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment