Skip to content

Commit 72567f6

Browse files
committed
Fix issue with too many cookies in admin
Port MC-19247 for adminhtml in order to not use jQuery.localStorage plugin Move translation directory definition to base theme Add deprecation notice to block and view files
1 parent d3adb7a commit 72567f6

File tree

6 files changed

+26
-64
lines changed

6 files changed

+26
-64
lines changed

app/code/Magento/Backend/view/adminhtml/layout/default.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
<argument name="bugreport_url" xsi:type="string">https://github.com/magento/magento2/issues</argument>
7171
</arguments>
7272
</block>
73-
7473
</container>
7574
</container>
7675
</referenceContainer>

app/code/Magento/Backend/view/adminhtml/requirejs-config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
var config = {
77
map: {
88
'*': {
9-
'mediaUploader': 'Magento_Backend/js/media-uploader',
10-
'mage/translate': 'Magento_Backend/js/translate'
9+
'mediaUploader': 'Magento_Backend/js/media-uploader'
1110
}
1211
}
1312
};

app/code/Magento/Translation/Block/Js.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
*
1515
* @api
1616
* @since 100.0.2
17+
* @deprecated logic was refactored in order to not use localstorage at all.
18+
*
19+
* You can see details in app/code/Magento/Translation/view/base/web/js/mage-translation-dictionary.js
20+
* These block and view file were left in order to keep backward compatibility
1721
*/
1822
class Js extends Template
1923
{
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
var config = {
7+
map: {
8+
'*': {
9+
mageTranslationDictionary: 'Magento_Translation/js/mage-translation-dictionary'
10+
}
11+
},
12+
deps: [
13+
'mageTranslationDictionary'
14+
]
15+
};

app/code/Magento/Translation/view/base/templates/translate.phtml

Lines changed: 4 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -7,61 +7,8 @@
77
/**
88
* @var \Magento\Translation\Block\Js $block
99
* @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer
10+
* @deprecated logic was refactored in order to not use localstorage at all.
11+
*
12+
* You can see details in app/code/Magento/Translation/view/base/web/js/mage-translation-dictionary.js
13+
* These block and view file were left in order to keep backward compatibility
1014
*/
11-
?>
12-
<!--
13-
For frontend area dictionary file is inserted into html head in Magento/Translation/view/base/templates/dictionary.phtml
14-
Same translation mechanism should be introduced for admin area in 2.4 version.
15-
-->
16-
<?php
17-
if ($block->dictionaryEnabled()) {
18-
$version = $block->getTranslationFileVersion();
19-
$escapedVersion = $block->escapeJs($version);
20-
$dictionaryFileName = /* @noEscape */ Magento\Translation\Model\Js\Config::DICTIONARY_FILE_NAME;
21-
22-
$scriptString = <<<script
23-
require.config({
24-
deps: [
25-
'jquery',
26-
'mage/translate',
27-
'jquery/jquery-storageapi'
28-
],
29-
callback: function ($) {
30-
'use strict';
31-
32-
var dependencies = [],
33-
versionObj;
34-
35-
$.initNamespaceStorage('mage-translation-storage');
36-
$.initNamespaceStorage('mage-translation-file-version');
37-
versionObj = $.localStorage.get('mage-translation-file-version');
38-
39-
if (versionObj.version !== '{$escapedVersion}') {
40-
dependencies.push(
41-
'text!{$dictionaryFileName}'
42-
);
43-
44-
}
45-
46-
require.config({
47-
deps: dependencies,
48-
callback: function (string) {
49-
if (typeof string === 'string') {
50-
$.mage.translate.add(JSON.parse(string));
51-
$.localStorage.set('mage-translation-storage', string);
52-
$.localStorage.set(
53-
'mage-translation-file-version',
54-
{
55-
version: '{$escapedVersion}'
56-
}
57-
);
58-
} else {
59-
$.mage.translate.add($.localStorage.get('mage-translation-storage'));
60-
}
61-
}
62-
});
63-
}
64-
});
65-
script;
66-
echo /* @noEscape */ $secureRenderer->renderTag('script', [], $scriptString, false);
67-
}

app/code/Magento/Translation/view/frontend/requirejs-config.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@ var config = {
88
'*': {
99
editTrigger: 'mage/edit-trigger',
1010
addClass: 'Magento_Translation/js/add-class',
11-
'Magento_Translation/add-class': 'Magento_Translation/js/add-class',
12-
mageTranslationDictionary: 'Magento_Translation/js/mage-translation-dictionary'
11+
'Magento_Translation/add-class': 'Magento_Translation/js/add-class'
1312
}
1413
},
1514
deps: [
16-
'mage/translate-inline',
17-
'mageTranslationDictionary'
15+
'mage/translate-inline'
1816
]
1917
};

0 commit comments

Comments
 (0)