.po files don't contain comments for translators

Bug #1375607 reported by Ying Chun Guo
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Fix Released
Medium
Akihiro Motoki

Bug Description

It looks like Horizon developers write many comments in their codes to tanslators.
According to https://docs.djangoproject.com/en/1.7/topics/i18n/translation/#comments-for-translators,
these comments should show up in the po files.

Yet I checked English version po files and found no comments there.
I think the problem may be caused by the po file generation method.

I have sent the issue to I18n mailing list.
It might related with the po file generation scripts in infrastructure env.

Regards
Daisy

Tags: i18n
description: updated
Revision history for this message
Matthias Runge (mrunge) wrote :
Changed in horizon:
status: New → Confirmed
importance: Undecided → Medium
Revision history for this message
Ying Chun Guo (daisy-ycguo) wrote :

From the web UI of Transifex ( the translation tool ), I could see two comments to translators :
api/neutron.py:993
api/neutron.py:1011

So the comments which are not shown up might be caused by:
the format of translation note is not correct. It MUST be just before a string.

Need to check all translators comments carefully.

Regards
Daisy

Revision history for this message
Yves-Gwenael Bourhis (yves-gwenael-bourhis) wrote :
Revision history for this message
Akihiro Motoki (amotoki) wrote :

The following simple diff fixes the problem.
We need to place translator note just before a string.
If we use multi-line strings, we need to place notes after *gettext*.

diff --git a/horizon/test/test_dashboards/dogs/puppies/tables.py
b/horizon/test/test_dashboards/dogs/puppies/tables.py
index 460bd91..d090bfe 100644
--- a/horizon/test/test_dashboards/dogs/puppies/tables.py
+++ b/horizon/test/test_dashboards/dogs/puppies/tables.py
@@ -26,8 +26,8 @@ class EagerPuppiesTable(tables.DataTable):
 class SellPuppy(tables.DeleteAction):
     @staticmethod
     def action_present(count):
- # Translators: test code, don't really have to translate
         return ungettext_lazy(
+ # Translators: test code, don't really have to translate
             u"Sell Puppy",
             u"Sell Puppies",
             count
@@ -35,8 +35,8 @@ class SellPuppy(tables.DeleteAction):

     @staticmethod
     def action_past(count):
- # Translators: test code, don't really have to translate
         return ungettext_lazy(
+ # Translators: test code, don't really have to translate
             u"Sold Puppy",
             u"Sold Puppies",
             count

Changed in horizon:
assignee: nobody → Akihiro Motoki (amotoki)
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/125329

Changed in horizon:
status: Confirmed → In Progress
Revision history for this message
Yves-Gwenael Bourhis (yves-gwenael-bourhis) wrote :

I only found 4 python file with comments for translators:

    $ grep --include=*.py -rns 'Translators:' *
    horizon/test/test_dashboards/dogs/puppies/tables.py:29: # Translators: test code, don't really have to translate
    horizon/test/test_dashboards/dogs/puppies/tables.py:38: # Translators: test code, don't really have to translate
    openstack_dashboard/api/neutron.py:992: # Translators: Only used inside Horizon code and invisible to users
    openstack_dashboard/api/neutron.py:1010: # Translators: Only used inside Horizon code and invisible to users
    openstack_dashboard/dashboards/project/routers/views.py:93: # Translators: The usage is "<UUID of ext_net> (Not Found)"
    openstack_dashboard/dashboards/project/routers/tables.py:176: # Translators: High Availability mode of Neutron router

Are the other missing comments formatted properly or is there only these ones?

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

Reviewed: https://review.openstack.org/125329
Committed: https://git.openstack.org/cgit/openstack/horizon/commit/?id=8d89f09bfd502aa42e8a83c2c5e5c7e4a2d8aefb
Submitter: Jenkins
Branch: master

commit 8d89f09bfd502aa42e8a83c2c5e5c7e4a2d8aefb
Author: Akihiro Motoki <email address hidden>
Date: Wed Oct 1 20:46:30 2014 +0900

    Move translator notes just before translatable strings

    Translator notes must be placed just before strings.
    Otherwise translator notes are ignored when generating POT files.
    We need to be careful when we use multiline *gettext* methods.
    How to detect them is a future topic in I18N team.

    Change-Id: I808271c76b1669b15ecc20b291493a4f751d546e
    Closes-Bug: #1375607

Changed in horizon:
status: In Progress → Fix Committed
Akihiro Motoki (amotoki)
Changed in horizon:
milestone: none → kilo-1
Thierry Carrez (ttx)
Changed in horizon:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in horizon:
milestone: kilo-1 → 2015.1.0
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.