Can't translate text in cookie popup in magento 2

by TN98   Last Updated August 14, 2019 14:09 PM

Can't translate text in cookie popup in magento 2

I tryed add this text to de_DE.csv, but it not translate

"We use cookies to make your experience better.","Wir verwenden Cookies, um Ihre Erfahrungen besser machen.",module,Magento_Cookie
"We use cookies to make your experience better.","Wir verwenden Cookies, um Ihnen ein besseres Erlebnis zu ermöglichen."
"To comply with the new e-Privacy directive, we need to ask for your consent to set the cookies.","Um der neuen e-Privacy-Richtlinie zu entsprechen, müssen wir um Ihre Zustimmung bitten, die Cookies zu setzen.",module,Magento_Cookie
"<a href=""%1"">Learn more</a>.","<a href=""%1""> Erfahren Sie mehr</a>.",module,Magento_Cookie
"Allow Cookies","Cookies setzen erlauben",module,Magento_Cookie

My cookie

enter image description here

UPDATE

I tryed create a file notices.phtml in custom theme but it not apply in popup

<?php if ($this->helper(\Magento\Cookie\Helper\Cookie::class)->isCookieRestrictionModeEnabled()): ?>
    <div role="alertdialog"
         tabindex="-1"
         class="message global cookie"
         id="notice-cookie-block"
         style="display: none;">
        <div role="document" class="content" tabindex="0">
            <p>
                <strong><?= $block->escapeHtml(__('We use cookies to make your experience better...')) ?></strong>
                <span><?= $block->escapeHtml(__('To comply with the new e-Privacy directive, we need to ask for your consent to set the cookies.')) ?></span>
                <?= $block->escapeHtml(__('<a href="%1">Learn more</a>.', $block->getPrivacyPolicyLink()), ['a']) ?>
            </p>
            <div class="actions">
                <button id="btn-cookie-allow" class="action allow primary">
                    <span><?= $block->escapeHtml(__('Allow Cookies')) ?></span>
                </button>
            </div>
        </div>
    </div>
    <script type="text/x-magento-init">
        {
            "#notice-cookie-block": {
                "cookieNotices": {
                    "cookieAllowButtonSelector": "#btn-cookie-allow",
                    "cookieName": "<?= /* @noEscape */ \Magento\Cookie\Helper\Cookie::IS_USER_ALLOWED_SAVE_COOKIE ?>",
                    "cookieValue": <?= /* @noEscape */ $this->helper(\Magento\Cookie\Helper\Cookie::class)->getAcceptedSaveCookiesWebsiteIds() ?>,
                    "cookieLifetime": <?= /* @noEscape */ $this->helper(\Magento\Cookie\Helper\Cookie::class)->getCookieRestrictionLifetime() ?>,
                    "noCookiesUrl": "<?= $block->escapeJs($block->escapeUrl($block->getUrl('cookie/index/noCookies'))) ?>"
                }
            }
        }
    </script>
<?php endif; ?>


Answers 1


Follow this steps.

  1. go to /pub/static/frontend/your_theme_vendor/theme/de_DE

  2. Find js-translation.json and delete it (make a copy of it just in case!)

  3. Go back to your magento root folder and run php bin/magento setup:static-content:deploy de_DE

  4. Then run php bin/magento cache:flush

Mitro
Mitro
August 14, 2019 13:50 PM

Related Questions


hi magento error when translate

Updated May 05, 2018 13:09 PM

Differents translate packs in magento 2

Updated July 11, 2018 09:09 AM

translate csv - using multiple website (magento 1.9x)

Updated October 19, 2018 15:09 PM

Translate is not working

Updated June 29, 2015 15:04 PM

translating a string with html elements in it

Updated June 29, 2017 12:09 PM