[Django] #21408: Fallback to timesince produces erroneous translations in naturaltime

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

[Django] #21408: Fallback to timesince produces erroneous translations in naturaltime

Django
#21408: Fallback to timesince produces erroneous translations in naturaltime
------------------------------+-----------------------------------
     Reporter:  676c7473@…    |      Owner:  nobody
         Type:  Bug           |     Status:  new
    Component:  Translations  |    Version:  1.6
     Severity:  Normal        |   Keywords:  i18n l10n translation
 Triage Stage:  Unreviewed    |  Has patch:  0
Easy pickings:  0             |      UI/UX:  0
------------------------------+-----------------------------------
 The
 [[https://docs.djangoproject.com/en/dev/ref/contrib/humanize/#naturaltime|naturaltime]]
 filter in `django.contrib.humanize` composes strings for days, weeks,
 months, and years from the words "ago" and "in" and the output of the
 built-in
 [[https://docs.djangoproject.com/en/dev/ref/templates/builtins/#timesince|timesince]]
 filter. See here, where `delta` is to be supplied by `timesince`:

 {{{
 #: templatetags/humanize.py:190
 #, python-format
 msgctxt "naturaltime"
 msgid "%(delta)s ago"
 msgstr "vor %(delta)s"
 }}}

 This produces erroneous translations in German (and probably other
 inflectional languages, too).

 "3 days, 12 hours ago" is translated by Django as

 {{{
 vor 3 Tage, 12 Stunden
 }}}

 but the correct translation is (with dative inflection)

 {{{
 vor 3 Tagen, 12 Stunden
 }}}

 "3 Tage" is correct for `timesince`, but for `naturaltime` it must become
 "3 Tagen". Unfortunately, the assumption that these translations can
 simply be pieced together from translated bits in timesince.py is
 mistaken.

 I apologise if this isn't the right channel. I'd be glad to help, but so
 far I haven't seen a good way to avoid duplicating translations.

--
Ticket URL: <https://code.djangoproject.com/ticket/21408>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/061.0abd5af421e17998ea36490ae80fcac5%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #21408: Fallback to timesince produces erroneous translations in naturaltime

Django
#21408: Fallback to timesince produces erroneous translations in naturaltime
-------------------------------------+-------------------------------------
     Reporter:  676c7473@…           |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:                       |                  Version:  master
  Internationalization               |               Resolution:
     Severity:  Normal               |             Triage Stage:  Accepted
     Keywords:  i18n l10n            |      Needs documentation:  0
  translation                        |  Patch needs improvement:  0
    Has patch:  0                    |                    UI/UX:  0
  Needs tests:  0                    |
Easy pickings:  0                    |
-------------------------------------+-------------------------------------
Changes (by claudep):

 * needs_better_patch:   => 0
 * component:  Translations => Internationalization
 * needs_tests:   => 0
 * version:  1.6 => master
 * needs_docs:   => 0
 * stage:  Unreviewed => Accepted


Comment:

 Surely, this will need duplication of translatable strings. One solution
 would be to make the `django.utils.timesince` utility to accept a new
 optional argument containing a set of translatable strings. Then,
 `naturaltime` will be able to provide its own set of `npgettext_lazy`
 (with context) strings.

--
Ticket URL: <https://code.djangoproject.com/ticket/21408#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/076.dd02c07f2776e42e15c195c3542d04fd%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #21408: Fallback to timesince produces erroneous translations in naturaltime

Django
In reply to this post by Django
#21408: Fallback to timesince produces erroneous translations in naturaltime
-------------------------------------+-------------------------------------
     Reporter:  676c7473@…           |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:                       |                  Version:  master
  Internationalization               |               Resolution:
     Severity:  Normal               |             Triage Stage:  Accepted
     Keywords:  i18n l10n            |      Needs documentation:  0
  translation                        |  Patch needs improvement:  0
    Has patch:  0                    |                    UI/UX:  0
  Needs tests:  0                    |
Easy pickings:  0                    |
-------------------------------------+-------------------------------------

Comment (by 676c7473@…):

 Thank you for your answer. Slightly off-topic: I noticed a minor error in
 the docs for `npgettext_lazy` and have fixed it in
 https://github.com/django/django/pull/1895.

--
Ticket URL: <https://code.djangoproject.com/ticket/21408#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/076.9b87bbcce8f3932a7c626cb96aed0341%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #21408: Fallback to timesince produces erroneous translations in naturaltime

Django
In reply to this post by Django
#21408: Fallback to timesince produces erroneous translations in naturaltime
-------------------------------------+-------------------------------------
     Reporter:  676c7473@…           |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:                       |                  Version:  master
  Internationalization               |               Resolution:
     Severity:  Normal               |             Triage Stage:  Accepted
     Keywords:  i18n l10n            |      Needs documentation:  0
  translation                        |  Patch needs improvement:  0
    Has patch:  0                    |                    UI/UX:  0
  Needs tests:  0                    |
Easy pickings:  0                    |
-------------------------------------+-------------------------------------

Comment (by 676c7473@…):

 I'm running into some difficulties with the code and the translations.
 Could it be that the .po files are out of sync with the code?

 in `humanize.py`, line 204, there are bits like this one:

 {{{
     return ungettext(
         # Translators: \\u00a0 is non-breaking space
         'a second ago', '%(count)s\u00a0seconds ago', delta.seconds
     ) % {'count': delta.seconds}
 }}}

 There is a corresponding entry in the "en" locale, but in the "de" locale
 it looks different:

 {{{
 #. Translators: \\u00a0 is non-breaking space
 #: templatetags/humanize.py:198
 #, python-format
 msgid "a second ago"
 msgid_plural "%(count)s\\u00a0seconds ago"
 msgstr[0] ""
 msgstr[1] ""
 }}}

 {{{
 #: templatetags/humanize.py:196
 #, python-format
 msgid "a second ago"
 msgid_plural "%(count)s seconds ago"
 msgstr[0] "vor einer Sekunde"
 msgstr[1] "vor %(count)s Sekunden"
 }}}

 I guess the translation is still found because the msgid is the same, but
 the German translation doesn't have the non-breaking space.

 Also, these gettext messages in `timesince.py`, line 24,

 {{{
     chunks = (
         (60 * 60 * 24 * 365, ungettext_lazy('%d year', '%d years')),
         (60 * 60 * 24 * 30, ungettext_lazy('%d month', '%d months')),
         ...
 }}}

 don't exist in the "de" translations. As far as I can tell, the msgid
 `"year"` will not match `"%d year"`.

 {{{
 #: utils/timesince.py:23
 #, python-format
 msgid "%d year"
 msgid_plural "%d years"
 msgstr[0] ""
 msgstr[1] ""
 }}}

 {{{
 #: utils/timesince.py:22
 msgid "year"
 msgid_plural "years"
 msgstr[0] "Jahr"
 msgstr[1] "Jahre"
 }}}

 I'm not sure what's happening here. I'll experiment some more, maybe
 things will become clearer soon. If you want to share some advice, please
 do! Thanks.

--
Ticket URL: <https://code.djangoproject.com/ticket/21408#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/076.dec29b449689160805d3091b87c645e7%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #21408: Fallback to timesince produces erroneous translations in naturaltime

Django
In reply to this post by Django
#21408: Fallback to timesince produces erroneous translations in naturaltime
-------------------------------------+-------------------------------------
     Reporter:  676c7473@…           |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:                       |                  Version:  master
  Internationalization               |               Resolution:
     Severity:  Normal               |             Triage Stage:  Accepted
     Keywords:  i18n l10n            |      Needs documentation:  0
  translation                        |  Patch needs improvement:  0
    Has patch:  0                    |                    UI/UX:  0
  Needs tests:  0                    |
Easy pickings:  0                    |
-------------------------------------+-------------------------------------

Comment (by claudep):

 You might find more up-to-date translations in the 1.6.x branch. We've
 still not updated master with the more recent translations.

--
Ticket URL: <https://code.djangoproject.com/ticket/21408#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/076.2141ba1dc42846a9fe4cfd5e6ee889e9%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #21408: Fallback to timesince produces erroneous translations in naturaltime

Django
In reply to this post by Django
#21408: Fallback to timesince produces erroneous translations in naturaltime
-------------------------------------+-------------------------------------
     Reporter:  676c7473@…           |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:                       |                  Version:  master
  Internationalization               |               Resolution:
     Severity:  Normal               |             Triage Stage:  Accepted
     Keywords:  i18n l10n            |      Needs documentation:  0
  translation                        |  Patch needs improvement:  0
    Has patch:  0                    |                    UI/UX:  0
  Needs tests:  0                    |
Easy pickings:  0                    |
-------------------------------------+-------------------------------------

Comment (by 676c7473@…):

 Yes, @claudep, thank you, unfortunately there are no unit tests for those,
 and consequently the bug they introduced was overlooked: ticket:21415
 Sorry for not noticing this earlier.

 David

--
Ticket URL: <https://code.djangoproject.com/ticket/21408#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/076.ad704f22dff694d68ca9d8cc6da324eb%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #21408: Fallback to timesince produces erroneous translations in naturaltime

Django
In reply to this post by Django
#21408: Fallback to timesince produces erroneous translations in naturaltime
-------------------------------------+-------------------------------------
     Reporter:  676c7473@…           |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:                       |                  Version:  master
  Internationalization               |
     Severity:  Normal               |               Resolution:
     Keywords:  i18n l10n            |             Triage Stage:  Accepted
  translation                        |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Markus Bertheau):

 Bug still exists in 1.8.

 A workaround for German for intervals into the future is to manually
 replace 'in' with 'noch', resulting in 'noch 2 Tage, 3 Stunden', which is
 correct.

--
Ticket URL: <https://code.djangoproject.com/ticket/21408#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/076.4b305f425606c2b7ad66a9eeb85d7e88%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #21408: Fallback to timesince produces erroneous translations in naturaltime

Django
In reply to this post by Django
#21408: Fallback to timesince produces erroneous translations in naturaltime
-------------------------------------+-------------------------------------
     Reporter:  676c7473@…           |                    Owner:
                                     |  Maximilian Merz
         Type:  Bug                  |                   Status:  assigned
    Component:                       |                  Version:  master
  Internationalization               |
     Severity:  Normal               |               Resolution:
     Keywords:  i18n l10n            |             Triage Stage:  Accepted
  translation                        |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Maximilian Merz):

 * status:  new => assigned
 * owner:  nobody => Maximilian Merz


--
Ticket URL: <https://code.djangoproject.com/ticket/21408#comment:7>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/076.6a53f58aeddd7a92669accbf15611b17%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #21408: Fallback to timesince produces erroneous translations in naturaltime

Django
In reply to this post by Django
#21408: Fallback to timesince produces erroneous translations in naturaltime
-------------------------------------+-------------------------------------
     Reporter:  676c7473@…           |                    Owner:
                                     |  Maximilian Merz
         Type:  Bug                  |                   Status:  assigned
    Component:                       |                  Version:  master
  Internationalization               |
     Severity:  Normal               |               Resolution:
     Keywords:  i18n l10n            |             Triage Stage:  Accepted
  translation                        |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Maximilian Merz):

 [https://github.com/django/django/pull/9777 pull request 9777] submitted

--
Ticket URL: <https://code.djangoproject.com/ticket/21408#comment:8>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/076.24155b289d00e6586ab7187a71784631%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #21408: Fallback to timesince produces erroneous translations in naturaltime

Django
In reply to this post by Django
#21408: Fallback to timesince produces erroneous translations in naturaltime
-------------------------------------+-------------------------------------
     Reporter:  676c7473@…           |                    Owner:
                                     |  Maximilian Merz
         Type:  Bug                  |                   Status:  assigned
    Component:                       |                  Version:  master
  Internationalization               |
     Severity:  Normal               |               Resolution:
     Keywords:  i18n l10n            |             Triage Stage:  Accepted
  translation                        |
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

 * has_patch:  0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/21408#comment:9>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/076.0e51fdded3a1d3e40945d27d2f0e7235%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #21408: Fallback to timesince produces erroneous translations in naturaltime

Django
In reply to this post by Django
#21408: Fallback to timesince produces erroneous translations in naturaltime
-------------------------------------+-------------------------------------
     Reporter:  676c7473@…           |                    Owner:
                                     |  Maximilian Merz
         Type:  Bug                  |                   Status:  assigned
    Component:                       |                  Version:  master
  Internationalization               |
     Severity:  Normal               |               Resolution:
     Keywords:  i18n l10n            |             Triage Stage:  Accepted
  translation                        |
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  1
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz):

 * needs_better_patch:  0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/21408#comment:10>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/076.9f481f66de1cb88c431d1f71388cecd4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #21408: Fallback to timesince produces erroneous translations in naturaltime

Django
In reply to this post by Django
#21408: Fallback to timesince produces erroneous translations in naturaltime
-------------------------------------+-------------------------------------
     Reporter:  676c7473@…           |                    Owner:
                                     |  Maximilian Merz
         Type:  Bug                  |                   Status:  assigned
    Component:                       |                  Version:  master
  Internationalization               |
     Severity:  Normal               |               Resolution:
     Keywords:  i18n l10n            |             Triage Stage:  Ready for
  translation                        |  checkin
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

 * needs_better_patch:  1 => 0
 * stage:  Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/21408#comment:11>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/076.b9bffbef044eefb8a78201c4ffa2a3a0%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #21408: Fallback to timesince produces erroneous translations in naturaltime

Django
In reply to this post by Django
#21408: Fallback to timesince produces erroneous translations in naturaltime
-------------------------------------+-------------------------------------
     Reporter:  676c7473@…           |                    Owner:
                                     |  Maximilian Merz
         Type:  Bug                  |                   Status:  closed
    Component:                       |                  Version:  master
  Internationalization               |
     Severity:  Normal               |               Resolution:  fixed
     Keywords:  i18n l10n            |             Triage Stage:  Ready for
  translation                        |  checkin
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz <claude@…>):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"78912ccd0e1fcdfe98ca85081c9eb8acb7aa1f6d" 78912ccd]:
 {{{
 #!CommitTicketReference repository=""
 revision="78912ccd0e1fcdfe98ca85081c9eb8acb7aa1f6d"
 Fixed #21408 — German Translation for “3 days ago”

 The problem:
 “3 days ago” should translate to “vor 3 Tagen” in German, while “3 days”
 translates to “3 Tage”. #21408 describes that django always translated to
 “Tage”, even when the dative “Tagen” was correct. The same applies to
 months (“Monate”/“Monaten”) and years (“Jahre”/“Jahren”).

 The solution:
 Let `timesince` caller provide the string dict to use for the time-related
 strings.
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/21408#comment:12>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/076.145fa0509e856c8157df623f49b2bfa4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.