Closed
Description
Numeric values in locale files are causing incorrect translations in Magento frontend.
Preconditions
- Magento version 2.2.2
- PHP 7.1.12
Steps to reproduce
- Include the translation file of the module CmsStaging (https://crowdin.com/translate/magento-2/1360/enus-nlbe, Head > app/code/Magento/CmsStaging/i18n/en_US.csv). This file contains the following key-value pairs:
"200","200"
"100","100"
"50","50"
"30","30"
"20","20"
- Create a product attribute of type dropdown
- Add the numeric value "5" as admin key and leave translations empty.
- Configure the attribute to be shown on the product page
- Select the value "5" in a product
- Browse to the PDP of the product
Expected result
- Value "5" is shown on the PDP
Actual result
- The value "200" is shown.
It seems like the array containing the translations has mixed string and numeric keys. When requesting the key "5", this is interpreted as the numeric index, causing the value "200" to be returned.
Debugged and detected this problem in magento/framework/Phrase/Renderer.
The following numeric entries were present in the $data array:
1386 = 0 -> $data0 = 123
1853 = 1 -> $data1 = 20
1854 = 2 -> $data2 = 30
1855 = 3 -> $data3 = 50
1856 = 4 -> $data4 = 100
1857 = 5 -> $data5 = 200
4431 = 6 -> $data6 = één (one)
Besides the technical issue, I'm wondering why the bundle CmsStaging contains numeric values.