0

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; ?>
  • show us the code where oyu are rendering the text. i assume you are just printing the text and not using one of magentos translation functionalities – Philipp Sander Aug 14 '19 at 13:53
  • it is core in magento 2, i not custom it – TN98 Aug 14 '19 at 13:54
  • have you cleaned your translation cache? – Philipp Sander Aug 14 '19 at 13:59
  • yes, i clean cache, flush, deploy – TN98 Aug 14 '19 at 14:00
0

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

  • can i do it but not run php bin/magento setup:static-content:deploy de_DE ? – TN98 Aug 14 '19 at 13:55
  • Why? You couldn't run deploying content? because without deploying static content your translation changes will not work – Mitro Aug 14 '19 at 13:56
  • yes, i tryed, but it not translate, i tryed create custom magento_cookies in custom theme but it not apply – TN98 Aug 14 '19 at 13:58
  • What is your csv file path? can you share it? – Mitro Aug 14 '19 at 13:59
  • Yes, i can, it ad link docs.google.com/document/d/… – TN98 Aug 14 '19 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.