12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- // @codingStandardsIgnoreFile
- /** @var \Magento\Translation\Block\Js $block */
- ?>
- <?php if ($block->dictionaryEnabled()): ?>
- <script>
- require.config({
- deps: [
- 'jquery',
- 'mage/translate',
- 'jquery/jquery-storageapi'
- ],
- callback: function ($) {
- 'use strict';
- var dependencies = [],
- versionObj;
- $.initNamespaceStorage('mage-translation-storage');
- $.initNamespaceStorage('mage-translation-file-version');
- versionObj = $.localStorage.get('mage-translation-file-version');
- <?php $version = $block->getTranslationFileVersion(); ?>
- if (versionObj.version !== '<?= /* @escapeNotVerified */ $block->escapeJsQuote($version) ?>') {
- dependencies.push(
- 'text!<?= /* @noEscape */ Magento\Translation\Model\Js\Config::DICTIONARY_FILE_NAME ?>'
- );
- }
- require.config({
- deps: dependencies,
- callback: function (string) {
- if (typeof string === 'string') {
- $.mage.translate.add(JSON.parse(string));
- $.localStorage.set('mage-translation-storage', string);
- $.localStorage.set(
- 'mage-translation-file-version',
- {
- version: '<?= /* @escapeNotVerified */ $block->escapeJsQuote($version) ?>'
- }
- );
- } else {
- $.mage.translate.add($.localStorage.get('mage-translation-storage'));
- }
- }
- });
- }
- });
- </script>
- <?php endif; ?>
|