Description of problem: RHV Dashboard does not show memory and storage details properly when using Spanish language. Version-Release number of selected component (if applicable): RHV-4.4.8 How reproducible: 100% Steps to Reproduce: 1. Change language for RHV web UI to Spanish. 2. Login to RHV administration portal and review the dashboard. Actual results: RHV Dashboard does not show memory and storage details properly when using Spanish language. Expected results: RHV Dashboard should show memory and storage details properly when using any language.
The problem is caused by too restrictive type checking - translation function expects a number but receives a string. Example: input(number): 100 formatted (string) : "100,0" Note that in English locale the number is formatted to "100.0" which allows automatic type conversion to number. Problem can be solved by removing the type from message template. Unfortunately this invalidates the translation. diff --git a/src/intl/messages.js b/src/intl/messages.js index ffe3814..6c1b0e7 100644 --- a/src/intl/messages.js +++ b/src/intl/messages.js @@ -270,7 +270,7 @@ const messageDescriptors = { dashboardUtilizationCardAvailableOfUnit: { id: 'dashboard.utilizationCardAvailableOfUnit', - defaultMessage: 'of {total, number} {unit}', + defaultMessage: 'of {total} {unit}', description: 'part of utilization card\'s summary', },
Note that this bug was possible because formatting is handled in 2 different layers: code and translations. In order to prevent bugs due to type-aware messages we could switch to one approach only: 1. remove typing from messages and do the formatting in the code - this works well for complex cases but adds unnecessary overhead in simple cases 2. move all formatting to the translation layer - number skeleton [1] [2] syntax seems to cover all our cases(i.e. check diff below) and handles simple cases automatically. diff --git a/src/intl/translations.json b/src/intl/translations.json index 4c91a31..e21544d 100644 --- a/src/intl/translations.json +++ b/src/intl/translations.json @@ -287,7 +287,7 @@ "dashboard.utilizationCardAmountAvailableTooltip": "{percent} disponible", "dashboard.utilizationCardAmountUsedTooltip": "{percent} utilizado", "dashboard.utilizationCardAvailableOfPercent": "de {percent}", - "dashboard.utilizationCardAvailableOfUnit": "de {total, number} {unit}", + "dashboard.utilizationCardAvailableOfUnit": "de {total, number, ::.0} {unit}", "dashboard.utilizationCardCpuDialogTitle": "Recursos más utilizados (CPU)", "dashboard.utilizationCardDialogEmptyHostList": "Actualmente no hay hosts utilizados.", "dashboard.utilizationCardDialogEmptyStorageList": "Actualmente no hay dominios utilizados.", [1] https://formatjs.io/docs/intl-messageformat/#number-skeleton [2] https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#fraction-precision
Steps: 1. Change language for RHV web UI to Spanish. 2. Login to RHV administration portal and review the dashboard. Verified in: ovirt-engine-ui-extensions-1.3.2-1.el8ev.noarch ovirt-engine-4.5.0.2-0.7.el8ev.noarch
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (Moderate: RHV Manager (ovirt-engine) [ovirt-4.5.0] security update), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHSA-2022:4711
Due to QE capacity, we are not going to cover this issue in our automation