Wrong title on Angular index page

Bug #1762089 reported by hongbin
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Magnum UI
New
Undecided
Unassigned
OpenStack Dashboard (Horizon)
Fix Released
High
Radomir Dopieralski
Zun UI
New
Undecided
Unassigned

Bug Description

Install the zun-ui and horizon with latest devstack. The title of the containers page is displayed as "O". In before, the title is "Containers"

  https://ibb.co/cQvLjx

When use en-au or en-gb, the title for Angularized index page shows only second character.

Revision history for this message
Shu Muto (shu-mutou) wrote :

This title is set by https://github.com/openstack/zun-ui/blob/master/zun_ui/static/dashboard/container/containers/containers.module.js#L85 , and this will be translated by *.po files in https://github.com/openstack/zun-ui/tree/master/zun_ui/locale if language is set except English on horizon.

I could not reproduce this phenomenon, and could not find the cause for this. Could you let me know your situation?

Revision history for this message
hongbin (hongbin034) wrote :
Download full text (8.0 KiB)

@Shu,

Below is the information of my environment. What is yours?

Horizon version
===============

$ git log -1
commit 7c09346e08251a8c5a5f8ae4311b132405d7e1c9
Merge: 368d942 f343212
Author: Zuul <email address hidden>
Date: Fri Apr 6 10:08:07 2018 +0000

    Merge "Improve mocking in REST API tests (test_network)"

Pip freeze
==========

$ pip freeze
alabaster==0.7.10
alembic==0.9.9
amqp==2.2.2
aodhclient==1.0.0
appdirs==1.4.3
asn1crypto==0.24.0
astroid==1.3.8
attrs==17.4.0
automaton==1.14.0
Babel==2.5.3
backports.ssl-match-hostname==3.5.0.1
bandit==1.4.0
bashate==0.5.1
bcrypt==3.1.4
beautifulsoup4==4.6.0
cachetools==2.0.1
castellan==0.17.0
certifi==2018.1.18
cffi==1.11.5
chardet==3.0.4
-e git://git.openstack.org/openstack/cinder.git@a8a9dda3003f5df77dc17db72167e49200790e88#egg=cinder
click==6.7
cliff==2.11.0
cmd2==0.8.2
colorama==0.3.9
contextlib2==0.5.5
coverage==4.5.1
croniter==0.3.20
cryptography==2.2.2
cursive==0.2.1
ddt==1.1.2
debtcollector==1.19.0
decorator==4.2.1
defusedxml==0.5.0
deprecation==2.0
Django==1.11.11
django-appconf==1.0.2
django-babel==0.6.2
django-compressor==2.2
django-nose==1.4.5
django-pyscss==2.0.2
dnspython==1.15.0
doc8==0.8.0
docker==3.2.0
docker-pycreds==0.2.2
docutils==0.14
dogpile.cache==0.6.5
dulwich==0.19.0
enum-compat==0.0.2
enum34==1.1.6
etcd3==0.7.0
etcd3gw==0.2.1
eventlet==0.20.0
extras==1.0.0
fasteners==0.14.1
fixtures==3.0.0
flake8==2.5.5
flake8-docstrings==0.2.1.post1
flake8-import-order==0.11
Flask==0.12.2
freezegun==0.3.10
funcsigs==1.0.2
functools32==3.2.3.post2
future==0.16.0
futures==3.2.0
futurist==1.6.0
gabbi==1.40.1
git-review==1.25.0
gitdb2==2.0.3
GitPython==2.1.9
-e git://git.openstack.org/openstack/glance.git@67d35f61661b68aa96553ba90535de039130b5fc#egg=glance
glance-store==0.23.0
google-api-python-client==1.6.6
greenlet==0.4.13
grpcio==1.10.0
hacking==0.12.0
-e git+https://git.openstack.org/openstack/heat@a09bce8c5ebbda67344d53d7f53f25f5a7455375#egg=heat
-e git://git.openstack.org/openstack/horizon.git@7c09346e08251a8c5a5f8ae4311b132405d7e1c9#egg=horizon
httplib2==0.11.3
idna==2.6
imagesize==1.0.0
ipaddress==1.0.19
iso8601==0.1.12
itsdangerous==0.24
Jinja2==2.10
jmespath==0.9.3
jsonpatch==1.21
jsonpath-rw==1.4.0
jsonpath-rw-ext==1.1.3
jsonpointer==2.0
jsonschema==2.6.0
-e git://git.openstack.org/openstack/keystone.git@0c5242b6184aa37968266a2fbb1d490208d6a580#egg=keystone
keystoneauth1==3.4.0
keystonemiddleware==4.21.0
kombu==4.1.0
kuryr-lib==0.7.0
-e git+http://git.openstack.org/openstack/kuryr-libnetwork@5bf52b6b14138b9568e86dd20301c9cba93f2e5f#egg=kuryr_libnetwork
libvirt-python==4.0.0
linecache2==1.0.0
logilab-common==1.4.1
logutils==0.3.5
lxml==4.2.1
Mako==1.0.7
MarkupSafe==1.0
mccabe==0.2.1
microversion-parse==0.2.1
mock==2.0.0
monotonic==1.4
more-itertools==4.1.0
mox3==0.25.0
msgpack==0.5.6
msgpack-python==0.5.6
munch==2.2.0
mysqlclient==1.3.7
netaddr==0.7.19
netifaces==0.10.6
networkx==1.11
-e git://git.openstack.org/openstack/neutron.git@1ce070c8e2edcdd58b2c032c3223bde318ec1ee9#egg=neutron
neutron-lib==1.13.0
nodeenv==1.3.0
nose==1.3.7
nose-exclude==0.5.0
nosehtmloutput==0.0.5
nosexcover==1.0.11
-e git://git.openstack.org/openstack/nova.git@8b081453c5ab065932da7ca0b1f663263a...

Read more...

Revision history for this message
Shu Muto (shu-mutou) wrote :

@Hongbin,

Thanks for information of your environment.
I could not find the commit hash[1], i.e. 7e4bad2c2c994fb42d4b1a4dbd2751767ae4da9f, for zun-ui on github.

[1] -e git+https://git.openstack.org/openstack/zun-ui@7e4bad2c2c994fb42d4b1a4dbd2751767ae4da9f#egg=zun_ui

Could you check your zun-ui repository on your devstack?

Revision history for this message
hongbin (hongbin034) wrote :

@Shu,

I have pull down the latest version of zun-ui. Unfortunately, the problem is still there.

Let's try to find another person to see if he/she can reproduce this bug. If he/she cannot, it is possibly due to issues from my environment.

Revision history for this message
Shu Muto (shu-mutou) wrote :

@Hongbin,

I found that this issue causes when use British English (en-gb) as Language on User Settings panel.

Revision history for this message
Shu Muto (shu-mutou) wrote :

But I could not find which project have such a translation on djangojs.po file. At least, Zun UI does not have such a translation on djangojs.po for en-gb.

Revision history for this message
Shu Muto (shu-mutou) wrote :

Australian English also shows "o".

Revision history for this message
Shu Muto (shu-mutou) wrote :

.po files on horizon and zun seem to have no problem, and `gettext("Containers")` returns "Containers" as expected on chrome console.

Revision history for this message
Shu Muto (shu-mutou) wrote :

Also, Admin - Container - Images panel shows "m" instead "Images".

Revision history for this message
Shu Muto (shu-mutou) wrote :

And following panels too.

# Horizon
Project - Compute - Images
Project - Compute - Key Pairs
Admin - Compute - Images

# Magnum UI
Project - Cluster Infra - Clusters
Project - Cluster Infra - Cluster Templates

Revision history for this message
Shu Muto (shu-mutou) wrote :

These panels show only second character....

summary: - Wrong title on "containers" page
+ Wrong title on Angular index page
Shu Muto (shu-mutou)
description: updated
Changed in horizon:
status: New → Confirmed
assignee: nobody → Radomir Dopieralski (deshipu)
milestone: none → ongoing
importance: Undecided → High
Revision history for this message
Radomir Dopieralski (deshipu) wrote :

The problem is quite tricky and is only visible sometimes, but I think I have figured it out. The culprit is in this code: https://github.com/openstack/horizon/blob/3aa3cc934bf77fd656c53f160125ffa69b1e9b81/horizon/static/framework/conf/resource-type-registry.service.js#L397-L433

As you can see, the function getName() uses ngettext() to translate and return the correct singular or plural name for the given resource. There are several problems with it, however:

* it is being called with already translated strings for singular and plural, which means that most of the time it will not find a translation, and fall back to using those translated strings directly — which is fine as long as your language has only one plural form, like English does, but will break horribly in other languages, producing gibberish
* in the rare case where the translation is the same as the translated string, it will find the translation. However, since those strings have been marked for translation using gettext and not ngettext, they will have two separate translations for singular and for plural, instead of a single translation with singular and plural forms
* ngettext expects a list of translations for the different plural forms, but because the string has been marked for translation with gettext and not ngettext, that translation will be a single string instead. The way ngettext is implemented, it will still try to treat that string as a list of translations, and take the second character from it.

I am working on a fix for this, but it involves changing how setNames() is called everywhere.

Changed in horizon:
milestone: ongoing → ussuri-1
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to horizon (master)

Fix proposed to branch: master
Review: https://review.opendev.org/696321

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

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

commit ef4055e2888bb0fe67d64e9c422a31f925469200
Author: Radomir Dopieralski <email address hidden>
Date: Wed Nov 27 15:07:41 2019 +0100

    Fix use of ngettext in registry getName

    The setNames and getNames functions in the resource registry were
    calling ngettext() on already translated strings that were marked for
    translation with gettext() and not ngetttext(). That lead to some
    page titles in some locales being displayed as single characters.

    Closes-Bug: #1762089
    Change-Id: I0ef365e0c0de6ae27a2e80bcb5257132f8c6ba29

Changed in horizon:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/horizon 18.0.0

This issue was fixed in the openstack/horizon 18.0.0 release.

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

Fix proposed to branch: stable/train
Review: https://review.opendev.org/749291

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

Reviewed: https://review.opendev.org/749291
Committed: https://git.openstack.org/cgit/openstack/horizon/commit/?id=63214ab177c0e4120558be5516709905b91cb6a8
Submitter: Zuul
Branch: stable/train

commit 63214ab177c0e4120558be5516709905b91cb6a8
Author: Radomir Dopieralski <email address hidden>
Date: Wed Nov 27 15:07:41 2019 +0100

    Fix use of ngettext in registry getName

    The setNames and getNames functions in the resource registry were
    calling ngettext() on already translated strings that were marked for
    translation with gettext() and not ngetttext(). That lead to some
    page titles in some locales being displayed as single characters.

    Closes-Bug: #1762089
    Change-Id: I0ef365e0c0de6ae27a2e80bcb5257132f8c6ba29
    (cherry picked from commit ef4055e2888bb0fe67d64e9c422a31f925469200)

tags: added: in-stable-train
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/horizon 16.2.1

This issue was fixed in the openstack/horizon 16.2.1 release.

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.