Skip to content

bpo-10536: Enhancements to gettext docs#10324

Merged
JulienPalard merged 3 commits intopython:masterfrom
matrixise:bpo-10536
Nov 4, 2018
Merged

bpo-10536: Enhancements to gettext docs#10324
JulienPalard merged 3 commits intopython:masterfrom
matrixise:bpo-10536

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 merwok@netwok.org

https://bugs.python.org/issue10536

Port of a patch for 2.x to master

Co-authored-by: Éric Araujo <merwok@netwok.org>
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

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

defaults; instead its default is :file:`{sys.prefix}/share/locale`. For this
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!

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.

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.

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 <stephane@wirtel.be>
@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
(cherry picked from commit 55f3317)


Co-authored-by: Stéphane Wirtel <stephane@wirtel.be>


https://bugs.python.org/issue10536
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