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

Error on compilemessages due to translations from django-debug-toolbar #1862

Open
berzi opened this issue Dec 4, 2023 · 10 comments
Open

Error on compilemessages due to translations from django-debug-toolbar #1862

berzi opened this issue Dec 4, 2023 · 10 comments

Comments

@berzi
Copy link

berzi commented Dec 4, 2023

The command django-admin compilemessages fails when I have django-debug-toolbar installed (I tried both 4.1.0 and 4.2.0 which is currently the latest release).

The full error is as follows (the #0 and timing at the start of each line are due to docker compose and should be irrelevant for the issue):

#0 5.203 Execution of msgfmt failed: /tmp/.venv/Lib/site-packages/debug_toolbar/locale/pt_BR/LC_MESSAGES/django.po:151: a format specification for argument 'cache_calls', as in 'msgstr[0]', doesn't exist in 'msgid_plural'
#0 5.203 msgfmt: found 2 fatal errors
#0 5.203 Execution of msgfmt failed: /tmp/.venv/Lib/site-packages/debug_toolbar/locale/sv_SE/LC_MESSAGES/django.po:81: number of format specifications in 'msgid' and 'msgstr' does not match
#0 5.203 msgfmt: found 1 fatal error
#0 5.203 Execution of msgfmt failed: /tmp/.venv/Lib/site-packages/debug_toolbar/locale/sk/LC_MESSAGES/django.po:162: a format specification for argument 'cache_calls', as in 'msgstr[0]', doesn't exist in 'msgid_plural'
#0 5.203 msgfmt: found 4 fatal errors
#0 5.203 Execution of msgfmt failed: /tmp/.venv/Lib/site-packages/debug_toolbar/locale/ca/LC_MESSAGES/django.po:80: number of format specifications in 'msgid' and 'msgstr' does not match
#0 5.203 msgfmt: found 1 fatal error
#0 5.203 Execution of msgfmt failed: /tmp/.venv/Lib/site-packages/debug_toolbar/locale/pt/LC_MESSAGES/django.po:80: number of format specifications in 'msgid' and 'msgstr' does not match
#0 5.203 msgfmt: found 1 fatal error
#0 5.203 Execution of msgfmt failed: /tmp/.venv/Lib/site-packages/debug_toolbar/locale/fi/LC_MESSAGES/django.po:150: a format specification for argument 'cache_calls', as in 'msgstr[0]', doesn't exist in 'msgid_plural'
#0 5.203 msgfmt: found 2 fatal errors
#0 5.203 Execution of msgfmt failed: /tmp/.venv/Lib/site-packages/debug_toolbar/locale/zh_CN/LC_MESSAGES/django.po:146: a format specification for argument 'cache_calls', as in 'msgstr[0]', doesn't exist in 'msgid_plural'
#0 5.203 msgfmt: found 1 fatal error
#0 5.212 Execution of msgfmt failed: /tmp/.venv/Lib/site-packages/debug_toolbar/locale/pl/LC_MESSAGES/django.po:155: a format specification for argument 'cache_calls', as in 'msgstr[0]', doesn't exist in 'msgid_plural'
#0 5.212 msgfmt: found 3 fatal errors
#0 5.213 Execution of msgfmt failed: /tmp/.venv/Lib/site-packages/debug_toolbar/locale/uk/LC_MESSAGES/django.po:83: number of format specifications in 'msgid' and 'msgstr' does not match
#0 5.213 msgfmt: found 1 fatal error
#0 5.215 Execution of msgfmt failed: /tmp/.venv/Lib/site-packages/debug_toolbar/locale/cs/LC_MESSAGES/django.po:154: a format specification for argument 'cache_calls', as in 'msgstr[0]', doesn't exist in 'msgid_plural'
#0 5.215 msgfmt: found 3 fatal errors

All I can find from researching the error is that this error is due to plurals being used incorrectly, but the lines I checked from the traceback don't use any syntax for plurals and in fact seem unrelated to each other (sometimes they're the same place, like for catalan and portuguese, but for other languages they point to completely different places).

Needless to say I did not modify the package after installing it, and all this is running in a clean Docker container that other colleagues have been using for ages, except I'm on Windows (but the container isn't). Any clue why this isn't working for me?

@matthiask
Copy link
Member

I see a fuzzy translation at the first location:
image

No idea why the fuzzy translation wouldn't simply be ignored.

@berzi
Copy link
Author

berzi commented Dec 5, 2023

Apologies, the command actually includes --use-fuzzy. Still, I don't see why this should make it fail.

@tim-schilling
Copy link
Contributor

@matthiask is the problem that we have query_count and sql_time vs cache_calls and time

@matthiask
Copy link
Member

@tim-schilling Yes. I don't know why that would be a fatal error when the whole translation is marked as fuzzy though.

@tim-schilling
Copy link
Contributor

@berzi would you be able to create a minimal project that reproduces this effect?

@berzi
Copy link
Author

berzi commented Dec 13, 2023

@berzi would you be able to create a minimal project that reproduces this effect?

Unfortunately I don't think so, the error comes from an old and complex project from my company and it would be quite time-consuming to try and recreate it.

@tim-schilling
Copy link
Contributor

tim-schilling commented Dec 13, 2023

@berzi I understand, but from what we can see everything should be working. The only way for us to debug this would be to reproduce it. Since this work would most benefit you in particular, it feels reasonable to ask you to help us with that effort.

If you don't have time that's totally understandable.

This is a low priority for us because it's an undefined amount of work for an undefined amount of benefit.

@berzi
Copy link
Author

berzi commented Dec 13, 2023

@berzi I understand, but from what we can see everything should be working. The only way for us to debug this would be to reproduce it. Since this work would most benefit you in particular, it feels reasonable to ask you to help us with that effort.

If you don't have time that's totally understandable.

This is a low priority for us because it's an undefined amount of work for an undefined amount of benefit.

I understand that. The error doesn't block me at the moment so it's low priority for me as well. If I get any new clue or get the time to reproduce the error I'll post here again.

I'm fairly sure it has something to do with Windows, since I'm the only one of all my colleagues who worked and this and had this issue, but there's also many outdated things all along the pipeline (the Django version, the Docker Compose version...) so who knows.

@tim-schilling
Copy link
Contributor

tim-schilling commented Dec 13, 2023 via email

@berzi
Copy link
Author

berzi commented Dec 13, 2023

Docker Compose: 3.7
Python: 3.10
Django: 3.2.20
Django debug toolbar: tried both 4.1.0 and 4.2.0

gettext and other dependencies are installed with the following command:

apt-get install --no-install-recommends -y \
      gettext \
      libgettextpo-dev \
      procps \
      locales

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