Cannot translate messages in network_qos edit-rule form

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

Bug Description

There are strings which cannot be translated in network_qos edit-rule form.

It is because strings passed to gettext() contains variables. Such variables are evaluated as empty when generating the POT file. For example, a string in [1] will be "Bandwidth Limit - , , , " in the djangojs POT file.

On the other hand, when displaying the form these variables are evaluated and the corresponding string in PO file cannot be found.

edit-rule.controller.js contains the similar strings as [1].

When we need to pass variables to a translatable string, we should use interpolate() as we do in many files.

[1] https://opendev.org/openstack/horizon/src/branch/master/openstack_dashboard/static/app/core/network_qos/actions/edit-rule.controller.js#L42-L43

Tags: i18n
Akihiro Motoki (amotoki)
Changed in horizon:
assignee: nobody → Akihiro Motoki (amotoki)
status: New → Triaged
importance: Undecided → Low
Akihiro Motoki (amotoki)
tags: added: i18n
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/c/openstack/horizon/+/896978

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

Reviewed: https://review.opendev.org/c/openstack/horizon/+/896978
Committed: https://opendev.org/openstack/horizon/commit/783b2039f043d37156eb0c8a9697930e63aee2da
Submitter: "Zuul (22348)"
Branch: master

commit 783b2039f043d37156eb0c8a9697930e63aee2da
Author: Akihiro Motoki <email address hidden>
Date: Sun Oct 1 17:55:40 2023 +0900

    i18n: Avoid using variables in gettext() in network QoS edit rule

    If an argument to gettext() contains variables, strings extracted
    and strings used when rendered will be different (as variables are
    evaluated as empty during string extraction to POT).
    As a result, translations for these strings aree never used.

    This commit fixes the issue by defining strings with variable
    substitions (like%(id)s) in gettext() combined with interpolate().

    Labels of "Rule to edit" pulldown menu in "Edit Rule" form are
    updated to match the format used in "Delete Rule" form.

    Closes-Bug: #2037278
    Change-Id: I06cb56ada2c842e5a445026b4649260bf9893841

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

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

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.