File tree Expand file tree Collapse file tree 3 files changed +42
-61
lines changed
app/code/Magento/Translation Expand file tree Collapse file tree 3 files changed +42
-61
lines changed Original file line number Diff line number Diff line change 88
99use Magento \Framework \View \Element \Template ;
1010use Magento \Translation \Model \Js \Config ;
11- use Magento \Framework \Escaper ;
1211
1312/**
1413 * @api
Original file line number Diff line number Diff line change 99/** @var \Magento\Translation\Block\Js $block */
1010?>
1111<?php if ($ block ->dictionaryEnabled ()): ?>
12+ <script>
13+ require.config({
14+ deps: [
15+ 'jquery',
16+ 'mage/translate',
17+ 'jquery/jquery-storageapi'
18+ ],
19+ callback: function ($) {
20+ 'use strict';
21+
22+ var dependencies = [],
23+ versionObj;
24+
25+ $.initNamespaceStorage('mage-translation-storage');
26+ $.initNamespaceStorage('mage-translation-file-version');
27+ versionObj = $.localStorage.get('mage-translation-file-version');
28+
29+ <?php $ version = $ block ->getTranslationFileVersion (); ?>
30+
31+ if (versionObj.version !== '<?= /* @escapeNotVerified */ $ block ->escapeJsQuote ($ version ) ?> ') {
32+ dependencies.push(
33+ 'text!<?= /* @noEscape */ Magento \Translation \Model \Js \Config::DICTIONARY_FILE_NAME ?> '
34+ );
1235
13- <?php
14- $ version = $ block ->getTranslationFileVersion ();
15- $ fileName = Magento \Translation \Model \Js \Config::DICTIONARY_FILE_NAME ;
16- ?>
17- <script type="text/x-magento-init">
18- {
19- "*": {
20- "mage/translate-init": {
21- "dictionaryFile": "text!<?= $ block ->escapeJs ($ fileName ); ?> ",
22- "version": "<?= $ block ->escapeJs ($ version ) ?> "
2336 }
37+
38+ require.config({
39+ deps: dependencies,
40+ callback: function (string) {
41+ if (typeof string === 'string') {
42+ $.mage.translate.add(JSON.parse(string));
43+ $.localStorage.set('mage-translation-storage', string);
44+ $.localStorage.set(
45+ 'mage-translation-file-version',
46+ {
47+ version: '<?= /* @escapeNotVerified */ $ block ->escapeJsQuote ($ version ) ?> '
48+ }
49+ );
50+ } else {
51+ $.mage.translate.add($.localStorage.get('mage-translation-storage'));
52+ }
53+ }
54+ });
2455 }
25- }
56+ });
2657 </script>
2758<?php endif ; ?>
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments