multiline blocktrans in django templates should use 'trimmed' option

Bug #1583757 reported by Akihiro Motoki
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Fix Released
Medium
Akihiro Motoki

Bug Description

Django templates support 'trimmed' option [1]. remove newline characters from the beginning and the end of the content of the {% blocktrans %} tag, replace any whitespace at the beginning and end of a line and merge all lines into one using a space character to separate them.

Without 'trimmed' option, translators will get source strings with meaningless newlines and whitespaces like below. Zanata (translation check site) checks the number of newlines, so translators need to insert newlines to silent Zanata validations. It is really annoying and meaningless.

  #: openstack_dashboard/dashboards/admin/volumes/templates/volumes/snapshots/_update_status.html:10
  msgid ""
  "\n"
  " The status of a volume snapshot is normally managed automatically. "
  "In some circumstances\n"
  " an administrator may need to explicitly update the status value. This"
  " is equivalent to\n"
  " the <tt>cinder snapshot-reset-state</tt> command.\n"
  " "
  msgstr ""

By using 'trimmed' option in Django templates, we can get rid of meaningless newlines in extracted message strings.
The recent released version of django-bebal supports 'trimmed' option [2] and now we can move the situation forward.

[1] https://docs.djangoproject.com/ja/1.9/topics/i18n/translation/#blocktrans-template-tag
[2] https://github.com/python-babel/django-babel/commit/88b389381c0e269605311ae07029555b65a86bc5

Tags: i18n
Revision history for this message
Akihiro Motoki (amotoki) wrote :

Action items:

* Update g-r to have 'django-babel>=0.5.1' because django-babel 0.5.1 adds 'trimmed' support.
* Add 'trimmed' option to blocktrans with multi-line contents.
* Update Horizon devref docs

Revision history for this message
Akihiro Motoki (amotoki) wrote :

After 'trimmed' option is added, we will get the following string in the POT file. It is simpler than before :)

#: openstack_dashboard/dashboards/admin/volumes/templates/volumes/snapshots/_update_status.html:10
msgid ""
"The status of a volume snapshot is normally managed automatically. In "
"some circumstances an administrator may need to explicitly update the "
"status value. This is equivalent to the <tt>cinder snapshot-reset-"
"state</tt> command."
msgstr ""

Revision history for this message
Akihiro Motoki (amotoki) wrote :
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to horizon (master)

Fix proposed to branch: master
Review: https://review.openstack.org/318896

Changed in horizon:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to horizon (master)

Reviewed: https://review.openstack.org/318896
Committed: https://git.openstack.org/cgit/openstack/horizon/commit/?id=926a4513ea2cd3243567bf7f0e265f92a092e61e
Submitter: Jenkins
Branch: master

commit 926a4513ea2cd3243567bf7f0e265f92a092e61e
Author: Akihiro Motoki <email address hidden>
Date: Fri May 20 04:27:35 2016 +0900

    Use 'trimmed' for blocktrans with multi-line contents

    blocktrans trimmed option removes newlines from contents of blocktrans
    and replaces any whitespace at the beginning and end of a line into
    a single space. This makes translator life easier.
    More detail is described in the bug report.

    Closes-Bug: #1583757
    Depends-On: I534895be0d5f4bf0429b1511ee5421991386c873
    Change-Id: Idb451b7688fd5533a8315399de13bac8b8078a67

Changed in horizon:
status: In Progress → Fix Released
Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote : Fix included in openstack/horizon 10.0.0.0b1

This issue was fixed in the openstack/horizon 10.0.0.0b1 development milestone.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to horizon (master)

Fix proposed to branch: master
Review: https://review.openstack.org/531585

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to horizon (master)

Reviewed: https://review.openstack.org/531585
Committed: https://git.openstack.org/cgit/openstack/horizon/commit/?id=a1c8f6c0e2d1cf954bbd92df94d7d947258dcae5
Submitter: Zuul
Branch: master

commit a1c8f6c0e2d1cf954bbd92df94d7d947258dcae5
Author: Qian Min Chen <chen.qiaomin@99cloud.net>
Date: Sun Jan 7 19:38:28 2018 +0800

    Use 'trimmed' for blocktrans in multi-line strings

    blocktrans trimmed option removes newlines from contents of blocktrans
    and replaces any whitespace at the beginning and end of a line into
    a single space. This makes translator life easier.
    It was inspired by a previous patch:
    https://review.openstack.org/#/c/318896/

    Change-Id: Ia4f2d52aa42f4d6c84416903a87618ddff3fbd82
    Closes-Bug: #1583757

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/horizon 13.0.0.0b3

This issue was fixed in the openstack/horizon 13.0.0.0b3 development milestone.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.