Opened 5 years ago

Closed 5 years ago

#31172 closed Bug (fixed)

Note that yesno can be affected by extra spaces in translations.

Reported by: José Antonio Ruiz Owned by: Hasan Ramezani
Component: Documentation Version: dev
Severity: Normal Keywords:
Cc: Claude Paroz Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by José Antonio Ruiz)

I've just discovered by doing something like this in a template: {{ some_boolean|yesno|capfirst }} that the translation for "yes,no,maybe" is incorrect for several languages.

For example, for Spanish language, the translation is: "sí, no, quizás", which adds an extra space before "no" and before "quizás". That makes the "no" and "maybe" translations to be wrong because they add an extra space at the beggining so "capfirst" won't work properly because it capitalizes the first letter, which is an space.

I've detected it in 2.2.9 and I've checked that this is still an issue in "master".

The affected languages in 2.2.9 are:
"bg"
"br"
"cs"
"es"
"es_CO"
"es_MX"
"es_VE"
"fr"
"ga"
"hi"
"mk"
"ml"
"ne"
"te"
"vi"

Edit 1: for spanish translation, the extra spaces where added 7 years ago in this commit: 6ca475d540361090e8b28154ce5391de718d5c63.

I will try to fix it by myself if nobody does in several weeks as it's quite easy to fix but I don't have time at the moment (as it would be my first fix and I should have to read all documentation related with contributing).

Change History (22)

comment:1 by José Antonio Ruiz, 5 years ago

Description: modified (diff)

comment:2 by José Antonio Ruiz, 5 years ago

Description: modified (diff)

comment:3 by José Antonio Ruiz, 5 years ago

Description: modified (diff)

comment:4 by José Antonio Ruiz, 5 years ago

Description: modified (diff)

comment:5 by Baptiste Mispelon, 5 years ago

Component: InternationalizationTemplate system
Triage Stage: UnreviewedAccepted

Hi and thanks for the report.

This does appear to be a bug. I guess it's not a problem most of the time because HTML doesn't care too much about spaces but the interaction with capfirst makes it more obvious.

Rather than fixing all the broken .po file, I think it might be better to change the code so it automatically removes spaces before and after each yes/no/maybe string.
For backwards compatibility with users who might deliberately want spaces, maybe we should only strip the spaces from the translated string, but not from ay user-provided string.

The code for the yesno filter is in django/templates/defaultfilters [1] if you'd like to take a look and try a pull request (make sure you assign the ticket to yourself once you start working on it).

[1] https://github.com/django/django/blob/master/django/template/defaultfilters.py#L773

comment:6 by José Antonio Ruiz, 5 years ago

Owner: changed from nobody to José Antonio Ruiz
Status: newassigned

I've already been checking the code for "yesno" filter and it hasn't changed much after those translations error were made so the code is (and was) OK.

I'll try to fix it as soon as possible (maybe next week if I have a couple of free hours).

comment:7 by Mariusz Felisiak, 5 years ago

Cc: Claude Paroz added

I think we shouldn't strip anything from translated strings. I would correct them via Transifex and close this ticket.

Claude, What do you think?

comment:8 by Baptiste Mispelon, 5 years ago

If we only fix the translation then I'd suggest adding a comment [1] to the yesno code so that the problem doesn't keep re-surfacing.

[1] https://docs.djangoproject.com/en/dev/topics/i18n/translation/#comments-for-translators

comment:9 by Claude Paroz, 5 years ago

+1 for the comment as Baptiste suggested.

comment:10 by Mariusz Felisiak, 5 years ago

Component: Template systemDocumentation
Easy pickings: set
Summary: Wrong translation for "yes,no,maybe" in several .po files.Note that yesno can be affected by extra spaces in translations.
Version: 2.2master

Agreed.

comment:11 by samuel nogueira, 5 years ago

Does someone is fixing it? i think i've solved the problem and i'd like to contribute by just adding a few things in the capfirst and yesno functions.

comment:12 by Claude Paroz, 5 years ago

The decision was to not touch the code and add a translator comment. Do you want to prepare a pull request for that?

comment:13 by José Antonio Ruiz, 5 years ago

I was going to fix it in a couple of weeks as I don't have any spare time right now.

Feel free to fix it yourself.

comment:14 by samuel nogueira, 5 years ago

I would apreciate if I could try to fix it. As soon I get accepted in the django transifex I will fix the translations myself and add the comment in the code.

comment:15 by Juan Carlos Gómez, 5 years ago

Hi, I would like to solve this issue (bc I am noob). I see that the issue is still open.

I found that the files to modify can be selected by the following grep command.

grep -w django/conf/locale/*/*/django.po -e 'yes,no,maybe' -A 1 | grep msgstr | awk '{print NF,$1,$2,$3,$4,$5}' | grep -v 2 | grep -v 3

Which shows that the affected strings are:

5 django/conf/locale/bg/LC_MESSAGES/django.po-msgstr "да, не, може би"
4 django/conf/locale/br/LC_MESSAGES/django.po-msgstr "ya, ket, marteze"
4 django/conf/locale/cs/LC_MESSAGES/django.po-msgstr "ano, ne, možná"
4 django/conf/locale/es_CO/LC_MESSAGES/django.po-msgstr "sí, no, quizás"
4 django/conf/locale/es/LC_MESSAGES/django.po-msgstr "sí, no, quizás"
5 django/conf/locale/es_MX/LC_MESSAGES/django.po-msgstr "sí, no, tal vez"
4 django/conf/locale/es_VE/LC_MESSAGES/django.po-msgstr "sí, no, quizás"
4 django/conf/locale/ga/LC_MESSAGES/django.po-msgstr "tá, níl, b'fhéidir"
4 django/conf/locale/hi/LC_MESSAGES/django.po-msgstr "हाँ, नहीं, शायद"
4 django/conf/locale/mk/LC_MESSAGES/django.po-msgstr "да, не, можеби"
4 django/conf/locale/ml/LC_MESSAGES/django.po-msgstr "ഉണ്ട്, ഇല്ല, ഉണ്ടായേക്കാം"
4 django/conf/locale/ne/LC_MESSAGES/django.po-msgstr "हो, होइन, सायद"
4 django/conf/locale/ta/LC_MESSAGES/django.po-msgstr "ஆம், இல்லை, இருக்கலாம்"
5 django/conf/locale/te/LC_MESSAGES/django.po-msgstr "అవును, కాదు , ఏమొ"
4 django/conf/locale/uz/LC_MESSAGES/django.po-msgstr "ha, yo'q, ehtimol"
5 django/conf/locale/vi/LC_MESSAGES/django.po-msgstr "Có, Không, Có thể"

I've got the corresponding change in the files, should I submit the PR?

comment:16 by Mariusz Felisiak, 5 years ago

Juan, thanks. Translations are handled at Transifex so you can fix them via Transifex, not via GitHub PR.

comment:17 by Juan Carlos Gómez, 5 years ago

Well, I am not a translator in those 20+ languages , I do not if they going to accept the changes in there.

comment:18 by Claude Paroz, 5 years ago

Resolution: fixed
Status: assignedclosed

Many thanks Juan, I used your list to fix the translations in Transifex, as I'm authorized to edit all languages.

comment:19 by Claude Paroz, 5 years ago

Resolution: fixed
Status: closednew

Oh sorry, I closed too quickly, we still need the translator comment in the code.

comment:20 by Hasan Ramezani, 5 years ago

Has patch: set
Owner: changed from José Antonio Ruiz to Hasan Ramezani
Status: newassigned
Version 0, edited 5 years ago by Hasan Ramezani (next)

comment:21 by Carlton Gibson, 5 years ago

Triage Stage: AcceptedReady for checkin

comment:22 by GitHub <noreply@…>, 5 years ago

Resolution: fixed
Status: assignedclosed

In 0538da0:

Fixed #31172 -- Added note to translators for yesno filter.

Note: See TracTickets for help on using tickets.
Back to Top