[Django] #29986: ngettext_lazy result doesn't support `.format`§

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[Django] #29986: ngettext_lazy result doesn't support `.format`§

Django
#29986: ngettext_lazy result doesn't support `.format`§
-----------------------------------------+------------------------------
               Reporter:  patrick        |          Owner:  nobody
                   Type:  Bug            |         Status:  new
              Component:  Uncategorized  |        Version:  2.1
               Severity:  Normal         |       Keywords:  translations
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+------------------------------
 I was trying to use `ngettext_lazy` in combination with `str.format` and I
 discovered that it doesn't actually work,
 here's a test script that you can try with latest django:

 {{{
 import os

 os.environ.setdefault("DJANGO_SETTINGS_MODULE", "translation.settings")

 import django  # noqa

 django.setup()

 from django.utils.translation import ugettext_lazy, ngettext_lazy  # noqa

 singular_string = ugettext_lazy("this {name} will be translated")
 plural_string = ngettext_lazy(
     singular="{total} string will be translated",
     plural="{total} strings will be translated",
     number="total",
 )

 a = singular_string.format(name="string")

 b = plural_string.format(total=2)

 print()

 print("a:", a)
 print("b:", b)

 }}}

 This is the output:

 {{{
 ~/D/p/django-ngettext-lazy pipenv run python example.py

 a: this string will be translated
 b:
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29986>
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/052.4eddcc21a43d1821b5ba91523228250f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29986: ngettext_lazy result doesn't support `.format` (was: ngettext_lazy result doesn't support `.format`§)

Django
#29986: ngettext_lazy result doesn't support `.format`
-------------------------------+--------------------------------------
     Reporter:  patrick        |                    Owner:  nobody
         Type:  Bug            |                   Status:  new
    Component:  Uncategorized  |                  Version:  2.1
     Severity:  Normal         |               Resolution:
     Keywords:  translations   |             Triage Stage:  Unreviewed
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+--------------------------------------

--
Ticket URL: <https://code.djangoproject.com/ticket/29986#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/067.63768c14b2d4356b2e02a76659c02342%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29986: ngettext_lazy result doesn't support `.format`

Django
In reply to this post by Django
#29986: ngettext_lazy result doesn't support `.format`
-------------------------------+--------------------------------------
     Reporter:  patrick        |                    Owner:  nobody
         Type:  Bug            |                   Status:  new
    Component:  Uncategorized  |                  Version:  2.1
     Severity:  Normal         |               Resolution:
     Keywords:  translations   |             Triage Stage:  Unreviewed
    Has patch:  1              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+--------------------------------------
Changes (by patrick):

 * has_patch:  0 => 1


Old description:

> I was trying to use `ngettext_lazy` in combination with `str.format` and
> I discovered that it doesn't actually work,
> here's a test script that you can try with latest django:
>
> {{{
> import os
>
> os.environ.setdefault("DJANGO_SETTINGS_MODULE", "translation.settings")
>
> import django  # noqa
>
> django.setup()
>
> from django.utils.translation import ugettext_lazy, ngettext_lazy  # noqa
>
> singular_string = ugettext_lazy("this {name} will be translated")
> plural_string = ngettext_lazy(
>     singular="{total} string will be translated",
>     plural="{total} strings will be translated",
>     number="total",
> )
>
> a = singular_string.format(name="string")
>
> b = plural_string.format(total=2)
>
> print()
>
> print("a:", a)
> print("b:", b)
>
> }}}
>
> This is the output:
>
> {{{
> ~/D/p/django-ngettext-lazy pipenv run python example.py
>
> a: this string will be translated
> b:
> }}}
New description:

 I was trying to use `ngettext_lazy` in combination with `str.format` and I
 discovered that it doesn't actually work,
 here's a test script that you can try with latest django:

 {{{
 import os

 os.environ.setdefault("DJANGO_SETTINGS_MODULE", "translation.settings")

 import django  # noqa

 django.setup()

 from django.utils.translation import ugettext_lazy, ngettext_lazy  # noqa

 singular_string = ugettext_lazy("this {name} will be translated")
 plural_string = ngettext_lazy(
     singular="{total} string will be translated",
     plural="{total} strings will be translated",
     number="total",
 )

 a = singular_string.format(name="string")

 b = plural_string.format(total=2)

 print()

 print("a:", a)
 print("b:", b)

 }}}

 This is the output:

 {{{
 ~/D/p/django-ngettext-lazy pipenv run python example.py

 a: this string will be translated
 b:
 }}}

 EDIT: added a patch here:

 https://github.com/django/django/pull/10691

--

--
Ticket URL: <https://code.djangoproject.com/ticket/29986#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/067.d72ed8901aa00201457f492c41959ebb%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29986: ngettext_lazy result doesn't support `.format`

Django
In reply to this post by Django
#29986: ngettext_lazy result doesn't support `.format`
--------------------------------------+------------------------------------
     Reporter:  patrick               |                    Owner:  nobody
         Type:  Bug                   |                   Status:  new
    Component:  Internationalization  |                  Version:  2.1
     Severity:  Normal                |               Resolution:
     Keywords:  translations          |             Triage Stage:  Accepted
    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
 * component:  Uncategorized => Internationalization
 * stage:  Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/29986#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/067.9fa5a99a8602e483d896a89b2f6b745c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29986: ngettext_lazy result doesn't support `.format`

Django
In reply to this post by Django
#29986: ngettext_lazy result doesn't support `.format`
-------------------------------------+-------------------------------------
     Reporter:  patrick              |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:                       |                  Version:  2.1
  Internationalization               |
     Severity:  Normal               |               Resolution:
     Keywords:  translations         |             Triage Stage:  Ready for
                                     |  checkin
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz):

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


--
Ticket URL: <https://code.djangoproject.com/ticket/29986#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/067.0e76be87c65b07c32e48f4aab3689cd4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29986: ngettext_lazy result doesn't support `.format`

Django
In reply to this post by Django
#29986: ngettext_lazy result doesn't support `.format`
-------------------------------------+-------------------------------------
     Reporter:  patrick              |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:                       |                  Version:  2.1
  Internationalization               |
     Severity:  Normal               |               Resolution:  fixed
     Keywords:  translations         |             Triage Stage:  Ready for
                                     |  checkin
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

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


Comment:

 In [changeset:"ae180fa4b7f927a4aeae772975927c9888bb0cb0" ae180fa4]:
 {{{
 #!CommitTicketReference repository=""
 revision="ae180fa4b7f927a4aeae772975927c9888bb0cb0"
 Fixed #29986 -- Added .format() support to ngettext_lazy strings.
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29986#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/067.b7a2f8514b401c30128f5ec8332a67cb%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.