• Hello.

    I’m testing ERP 1.17.10 on WordPress 7.1.2 and the translation files generated by translate.wordpress.org (I tried with Spanish) and I noticed the following.

    The “Accounting”, “Create Invoice” and “Settings” screens are not displayed and the following errors are reported in the browser console:

    For "Accounting":

    [Error] SyntaxError: JSON Parse error: Unrecognized token '\'
    parse (admin.php:762)
    Codice globale (admin.php:762)

    [Error] ReferenceError: Can't find variable: erpAcct
    798 (bootstrap.js:1:73282)
    o (vendor.js:1:417)
    797 (bootstrap.js:1:71767)
    o (vendor.js:1:417)
    (funzione anonima) (vendor.js:1:288)
    Codice globale (bootstrap.js:1)

    [Error] ReferenceError: Can't find variable: __
    (funzione anonima) (admin.js:1:3918)
    o (vendor.js:1:417)
    (funzione anonima) (admin.js:1:467)
    o (vendor.js:1:417)
    (funzione anonima) (admin.js:1:168955)
    o (vendor.js:1:417)
    (funzione anonima) (admin.js:1:478946)
    o (vendor.js:1:417)
    (funzione anonima) (admin.js:1:470554)
    o (vendor.js:1:417)
    (funzione anonima) (admin.js:1:383639)
    o (vendor.js:1:417)
    (funzione anonima) (vendor.js:1:288)
    Codice globale (admin.js:1)

    For "Settings":

    [Error] SyntaxError: JSON Parse error: Unrecognized token '\'
    parse (admin.php:18)
    Codice globale (admin.php:18)

    [Error] SyntaxError: JSON Parse error: Unrecognized token '\'
    parse (admin.php:768)
    Codice globale (admin.php:768)

    [Error] ReferenceError: Can't find variable: erpLocale
    (funzione anonima) (i18n.js:821:90)
    __webpack_require__ (i18n.js:20)
    (funzione anonima) (i18n.js:63)
    Codice globale (i18n.js:64)

    [Error] ReferenceError: Can't find variable: erpSettings
    348 (erp-settings-bootstrap.js:1:19171)
    o (vendor.js:1:417)
    347 (erp-settings-bootstrap.js:1:17774)
    o (vendor.js:1:417)
    (funzione anonima) (vendor.js:1:288)
    Codice globale (erp-settings-bootstrap.js:1)

    [Error] ReferenceError: Can't find variable: __
    (funzione anonima) (erp-settings.js:1:4275)
    o (vendor.js:1:417)
    (funzione anonima) (erp-settings.js:1:258)
    o (vendor.js:1:417)
    (funzione anonima) (erp-settings.js:1:6682)
    o (vendor.js:1:417)
    (funzione anonima) (erp-settings.js:1:997)
    o (vendor.js:1:417)
    (funzione anonima) (erp-settings.js:1:4522)
    o (vendor.js:1:417)
    (funzione anonima) (erp-settings.js:1)
    o (vendor.js:1:417)
    (funzione anonima) (erp-settings.js:1:122943)
    o (vendor.js:1:417)
    (funzione anonima) (erp-settings.js:1:180747)
    o (vendor.js:1:417)
    (funzione anonima) (erp-settings.js:1:178632)
    o (vendor.js:1:417)
    (funzione anonima) (erp-settings.js:1:147888)
    o (vendor.js:1:417)
    (funzione anonima) (vendor.js:1:288)
    Codice globale (erp-settings.js:1)

    At the moment, the only solution that seems to work is to replace the script contained in the function erp_accounting_page() in the file /modules/accounting/includes/Classes/Admin.php with this command:

    window.erpAcct = {};

    and the script contained in the file /includes/Settings/views/settings.php with this command:

    window.erpSettings = {};

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter itapress

    (@itapress)

    Hello.

    I found the solution.

    These substitutions need to be made in the following files.

    In /modules/accounting/includes/Classes/Admin.php

    <script>
    window.erpAcct = <?php echo wp_json_encode(
    apply_filters( 'erp_localized_data', [] ),
    JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT
    ); ?>;
    </script>

    In /modules/hrm/HRM.php

    <script>
    window.erpLocale = <?php echo wp_json_encode(
    apply_filters( 'erp_localized_data', [] ),
    JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT
    ); ?>;
    </script>

    In /modules/crm/CRM.php

    <script>
    window.erpLocale = <?php echo wp_json_encode(
    apply_filters( 'erp_localized_data', [] ),
    JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT
    ); ?>;
    </script>

    In /includes/Settings/views/settings.php

    <script>
    window.erpSettings = <?php echo wp_json_encode(
    apply_filters( 'erp_localized_data', [] ),
    JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT
    ); ?>;
    </script>

    In /includes/ERP_i18n.php

    foreach ( $translations->entries as $msgid => $entry ) {
    $locale[ $entry->singular ] = $entry->translations;
    }

    Thanks

    P.S. I noticed that a similar solution had already been published on GitHub by the developers a short while ago.

    Plugin Support Md. Anower Hossain

    (@anowerhossain16)

    Hi @itapress,

    Thank you very much for the detailed report and for taking the time to investigate this issue.

    We’re glad to confirm that this issue has already been fixed by our developers, and the solution is available in our public GitHub repository here:

    https://github.com/wp-erp/wp-erp/pull/1652

    The fix addresses the JSON encoding/escaping issue with translated strings and prevents the affected Accounting, Settings, HRM, and CRM screens from failing to load when using translation files from translate.wordpress.org.

    So, there’s no need to manually replace the scripts with empty objects such as window.erpAcct = {}; or window.erpSettings = {};. We recommend updating to the version containing the fix once it is available.

    Thanks again for reporting the issue and, especially, for confirming the solution on your end. Your detailed investigation was very helpful!

    Thanks and have a nice day.

Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.