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

Wrong reading of literal-block content in PO files #120

Open
rffontenelle opened this issue Sep 18, 2024 · 2 comments
Open

Wrong reading of literal-block content in PO files #120

rffontenelle opened this issue Sep 18, 2024 · 2 comments

Comments

@rffontenelle
Copy link
Contributor

rffontenelle commented Sep 18, 2024

CPython enabled literal-block in gettext_additional_targets, so literal blocks are being extracted to translation files by the gettext builder. Since then, incorrect reports are showing up when running sphinx-lint 1.0.0, pointing to lines of msgids/source messages (English) instead of the msgstr/translation message.

Examples (make sure to rename removing .txt of the upload filename if want to test):

license.po (doc) shows:

license.po:998: found an unbalanced inline literal markup. (unbalanced-inline-literals-delimiters)
license.po:1410: found an unbalanced inline literal markup. (unbalanced-inline-literals-delimiters)
license.po:2029: found an unbalanced inline literal markup. (unbalanced-inline-literals-delimiters)
license.po:2038: found an unbalanced inline literal markup. (unbalanced-inline-literals-delimiters)
license.po:2503: found an unbalanced inline literal markup. (unbalanced-inline-literals-delimiters)

and library/datetime.po (doc) shows:

library/datetime.po:1601: trailing whitespace (trailing-whitespace)
library/datetime.po:1613: trailing whitespace (trailing-whitespace)
library/datetime.po:2056: trailing whitespace (trailing-whitespace)
library/datetime.po:2159: trailing whitespace (trailing-whitespace)
library/datetime.po:2931: trailing whitespace (trailing-whitespace)
library/datetime.po:3029: trailing whitespace (trailing-whitespace)
library/datetime.po:3031: trailing whitespace (trailing-whitespace)
library/datetime.po:3041: trailing whitespace (trailing-whitespace)
library/datetime.po:3056: trailing whitespace (trailing-whitespace)
@m-aciek
Copy link

m-aciek commented Oct 31, 2024

The messages for literal-blocks in PO files are no different than regular messages. We could try to use a custom flag to mark literal-blocks to change sphinx-lint behaviour (will a non-standard flag break gettext?). It would need to be added by Sphinx. Alternatively try to mark in the translator comment.

white-space
#  translator-comments
#. extracted-comments
#: reference…
#, flag…
#| msgctxt previous-context
#| msgid previous-untranslated-string
msgctxt context
msgid untranslated-string
msgstr translated-string

@JulienPalard
Copy link
Collaborator

I'm really not a fan of having Python code in po files, we disabled it french-side by adding -Dgettext_additional_targets=['index'] to our sphinx-build invocation. I think I would have preferred for this to be enabled explicitly language by language instead of upstream.

I don't think a non-standard flag would break the po format, I've seen #, python-format flags, I bet those are not standard, but ... reading the po spec would probably be a better solution than guessing :D

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

3 participants