Skip to content

translation data load after price-box.js #7363

Closed
@gabs77

Description

@gabs77

Preconditions

Magento 2.1
The translation-js load after some javascript.

Steps to reproduce

  1. I override the price-box.js like following method : app/design/frontend/vendor/package/Magento_Catalog/web/js/price-box.js
  2. i add in define array the following line :
    'mage/translate'
  3. in reloaPrice function, i add the following line :
    var regexResult = $.mage.__('$1$2.$3');
    and i add in i18n file the translation
    For example :
    "$1$2.$3","my custom regex"

For debug, I edit the following file: lib/web/mage/translate.js
this.translate = function (text) { console.log(text); console.log(_data[text]); console.log(_data); return _data[text] ? _data[text] : text; };

Expected result

in console log, we have :
Translate translate.js (ligne 45) undefined translate.js (ligne 46) Object {} translate.js (ligne 47) Submit translate.js (ligne 45) undefined translate.js (ligne 46) Object {} translate.js (ligne 47) Close translate.js (ligne 45) undefined translate.js (ligne 46) Object {} translate.js (ligne 47) $1$2.$3 translate.js (ligne 45) undefined translate.js (ligne 46) Object {} translate.js (ligne 47) GET http://xxx/pub/static/frontend/vendor/package/fr_CA/js-translation.json GET http://xxx/pub/static/frontend/vendor/package/fr_CA/Magento_Ui/templates/tooltip/tooltip.html text.js (ligne 131) Select Date translate.js (ligne 45) Sélectionner une date translate.js (ligne 46) Object { Method %s does not exist on jQuery.decorate="La méthode %s n’existe p...ie dans jQuery.decorate", Close="Fermer", Please wait...="Veuillez patienter...", plus...} translate.js (ligne 47)

Actual result

Object {} must be filled with translation data before the javascript pass to reloadPrice function in price-box.js file

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions