Skip to content

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

Merged
merged 3 commits into from
Nov 4, 2018

Conversation

matrixise
Copy link
Member

@matrixise matrixise commented Nov 4, 2018

Port of a patch for 2.x to master

Co-authored-by: Éric Araujo [email protected]

https://bugs.python.org/issue10536

Port of a patch for 2.x to master

Co-authored-by: Éric Araujo <[email protected]>
fp.close()
with open(filename, 'w') as fp:
fp.write(message)
fp.close()
Copy link
Member

Choose a reason for hiding this comment

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

close is now unnecessary :)

Copy link
Member Author

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

@@ -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
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

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`).
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 meant two lines before:

its default is :file:`{sys.prefix}/share/locale` (see :data:`sys.prefix`)

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@matrixise
Copy link
Member Author

matrixise commented Nov 4, 2018

@merwok an other point in your review?

@JulienPalard
Copy link
Member

Thanks both of your for this nice enhancement 👍

@matrixise
Copy link
Member Author

You're welcome

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a 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
Copy link
Member

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.

Copy link
Member

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
Copy link
Member

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
Copy link
Member

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.
Copy link
Member

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.

@miss-islington
Copy link
Contributor

Thanks @matrixise for the PR, and @JulienPalard for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 9, 2019
(cherry picked from commit 55f3317)

Co-authored-by: Stéphane Wirtel <[email protected]>
@bedevere-bot
Copy link

GH-13224 is a backport of this pull request to the 3.7 branch.

miss-islington added a commit that referenced this pull request May 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants