i18n: babel_extract_angular should trim whitespaces in AngularJS templates

Bug #1592965 reported by Akihiro Motoki
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Confirmed
Medium
Unassigned

Bug Description

This is "AngularJS templates" version of bug 1583757.

At now, 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.

For Django templates, Django provides 'trimmed' option to trim whitespaces in extracted messages. It would be nice if we have the similar behavior to Django 'trimmed' option for AngularJS template message extraction. In HTML case, we don't need to care consecutive whitespaces, so we can simply trim whitespaces in AngularJS HTML templates.

#: openstack_dashboard/dashboards/project/static/dashboard/project/containers/create-container-modal.html:40
msgid ""
"A container is a storage compartment for your data and provides a way\n"
" for you to organize your data. You can think of a container as "
"a\n"
" folder in Windows® or a directory in UNIX®. The primary "
"difference\n"
" between a container and these other file system concepts is "
"that\n"
" containers cannot be nested. You can, however, create an "
"unlimited\n"
" number of containers within your account. Data must be stored "
"in a\n"
" container so you must have at least one container defined in "
"your\n"
" account prior to uploading data."
msgstr ""

We would like to have a string like:

#: openstack_dashboard/dashboards/project/static/dashboard/project/containers/create-container-modal.html:40
msgid ""
"A container is a storage compartment for your data and provides a way for"
" you to organize your data. You can think of a container as a folder in "
"Windows® or a directory in UNIX®. The primary difference between a "
"container and these other file system concepts is that containers cannot "
"be nested. You can, however, create an unlimited number of containers "
"within your account. Data must be stored in a container so you must have "
"at least one container defined in your account prior to uploading data."
msgstr ""

Tags: i18n
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/330183

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/330183
Committed: https://git.openstack.org/cgit/openstack/horizon/commit/?id=f87b58fcabf84c9b73b07b587416cc0b6cc814b1
Submitter: Jenkins
Branch: master

commit f87b58fcabf84c9b73b07b587416cc0b6cc814b1
Author: Akihiro Motoki <email address hidden>
Date: Thu Jun 16 05:06:32 2016 +0900

    i18n: trim whitespaces in extracted messages from AngularJS templates

    When extracting translation messages from AngularJS templates,
    there is no need to keep whitespaces in the messages as there is
    no meaning of repeated whitespaces in HTML.
    This will make translation effort much simpler.
    More detail is described in the bug report.

    This commit trims such whitespaces. Django provides a convenient method
    to do the same purpose for 'trimmed' option in Django templates.
    This method is reused in this commit as well.

    Closes-Bug: #1592965
    Change-Id: I9b7ce54452f3db2350eecc3115db2e4173df5167

Changed in horizon:
status: In Progress → Fix Released
Revision history for this message
Doug Hellmann (doug-hellmann) wrote : Fix included in openstack/horizon 10.0.0.0b2

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

Revision history for this message
Rob Cresswell (robcresswell-deactivatedaccount) wrote :

Original patch reverted in https://review.openstack.org/#/c/349758/

Reopened bug and reset status.

Changed in horizon:
status: Fix Released → Confirmed
milestone: newton-2 → newton-3
Akihiro Motoki (amotoki)
Changed in horizon:
assignee: Akihiro Motoki (amotoki) → nobody
Revision history for this message
Akihiro Motoki (amotoki) wrote :

I would like to share my understanding and the background of the revert.

IIUC, while we use babel to extract messages for translations, we use angular-gettext to display translated messages. A source string extraction logic in both (babel and angular-gettext) should match for angular-gettext looks for translated messages successfully. The reverted patch https://review.openstack.org/330183 changes only the babel extractor and as a result we fail to show translated message for multi-line text.

As translator perspective, it would be nice if this bug is fixed, but we need to be careful. To fix this bug, I think angular-gettext needs to support 'trimmed' option provided by Django for Django templates.

Changed in horizon:
milestone: newton-3 → next
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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