-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-10536: Enhancements to gettext docs #10324
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
Conversation
Port of a patch for 2.x to master Co-authored-by: Éric Araujo <[email protected]>
Doc/library/gettext.rst
Outdated
fp.close() | ||
with open(filename, 'w') as fp: | ||
fp.write(message) | ||
fp.close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
close is now unnecessary :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, sure, I have updated the branch with your patch and when there was an issue, I have just changed the content. +1
Doc/library/gettext.rst
Outdated
@@ -669,7 +669,7 @@ implementations, and valuable experience to the creation of this module: | |||
.. [#] The default locale directory is system dependent; for example, on RedHat Linux | |||
it is :file:`/usr/share/locale`, but on Solaris it is :file:`/usr/lib/locale`. | |||
The :mod:`gettext` module does not try to support these system dependent | |||
defaults; instead its default is :file:`sys.prefix/share/locale`. For this | |||
defaults; instead its default is :file:`{sys.prefix}/share/locale`. For this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it would be useful to rework that line to add a linked reference to sys.prefix.
Maybe adding (see :data:`sys.prefix`)
at the end of the sentence?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not, can be useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Doc/library/gettext.rst
Outdated
reason, it is always best to call :func:`bindtextdomain` with an explicit | ||
absolute path at the start of your application. | ||
absolute path at the start of your application (see :data:`sys.prefix`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I meant two lines before:
its default is :file:`{sys.prefix}/share/locale` (see :data:`sys.prefix`)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@merwok an other point in your review? |
Thanks both of your for this nice enhancement 👍 |
You're welcome |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And perhaps replace :file:`<language-name>.po`
with :file:`{language-name}.po`
?
files, and has methods for returning strings. Instances of this "translations" | ||
class can also install themselves in the built-in namespace as the function | ||
:func:`_`. | ||
a :class:`GNUTranslations` class which implements the parsing of GNU :file:`.mo` format |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't be better to keep a "translations"
? GNUTranslations is just a concrete implementation of a "translations" class.
Otherwise perhaps it should be the
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree!
|
||
|
||
.. function:: find(domain, localedir=None, languages=None, all=False) | ||
|
||
This function implements the standard :file:`.mo` file search algorithm. It | ||
takes a *domain*, identical to what :func:`textdomain` takes. Optional | ||
*localedir* is as in :func:`bindtextdomain` Optional *languages* is a list of | ||
*localedir* is as in :func:`bindtextdomain`. Optional *languages* is a list of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A dot was missed, but it would be better to keep a double space after it.
@@ -340,15 +340,15 @@ The :mod:`gettext` module provides one additional class derived from | |||
:meth:`_parse` to enable reading GNU :program:`gettext` format :file:`.mo` files | |||
in both big-endian and little-endian format. | |||
|
|||
:class:`GNUTranslations` parses optional meta-data out of the translation | |||
catalog. It is convention with GNU :program:`gettext` to include meta-data as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double space after sentence ending period is not an error. It increases readability.
``key: value`` pairs, and should contain the ``Project-Id-Version`` key. If the | ||
key ``Content-Type`` is found, then the ``charset`` property is used to | ||
initialize the "protected" :attr:`_charset` instance variable, defaulting to | ||
``None`` if not found. If the charset encoding is specified, then all message | ||
ids and message strings read from the catalog are converted to Unicode using | ||
this encoding, else ASCII encoding is assumed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it incorrect? "ASCII encoding", "UTF-8 encoding", "Windows-1252 encoding" etc are used in other places in docs.
Thanks @matrixise for the PR, and @JulienPalard for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7. |
(cherry picked from commit 55f3317) Co-authored-by: Stéphane Wirtel <[email protected]>
GH-13224 is a backport of this pull request to the 3.7 branch. |
(cherry picked from commit 55f3317) Co-authored-by: Stéphane Wirtel <[email protected]> https://bugs.python.org/issue10536
Port of a patch for 2.x to master
Co-authored-by: Éric Araujo [email protected]
https://bugs.python.org/issue10536