Comment 12 for bug 1762089

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.