Skip to content
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

read_mo does not decode msgctxt #1147

Open
tomasr8 opened this issue Nov 9, 2024 · 0 comments
Open

read_mo does not decode msgctxt #1147

tomasr8 opened this issue Nov 9, 2024 · 0 comments

Comments

@tomasr8
Copy link
Member

tomasr8 commented Nov 9, 2024

When reading an MO file, the message context is kept as bytes unlike the msgid and msgstr which are decoded to utf8. This is surprising because in order to use for example Catalog.get, one must pass the context encoded as bytes. I wonder if this is intentional or just an omission?

Example:
When I read an MO file compiled from this PO file:

msgctxt "fooctxt"
msgid "foo"
msgstr "bar"

The message key is ('foo', b'fooctxt') (notice the that fooctxt is a bytes object):

>>> f = open('messages.mo', 'rb')
>>> cat = read_mo(f)
>>> cat._messages
OrderedDict({('foo', b'fooctxt'): <Message 'foo' (flags: [])>})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant