Skip to content

Commit 26409ac

Browse files
MAGETWO-70599: Product Edit Page Can't Load
- Refactoring code and change regexp pattern;
1 parent c56d933 commit 26409ac

File tree

7 files changed

+47
-22
lines changed

7 files changed

+47
-22
lines changed

app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/cc-form.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ define(
7878
* @param {Object} response
7979
*/
8080
onError: function (response) {
81-
braintree.showError($t('Payment ' + this.getTitle() + ' can\'t be initialized'));
81+
braintree.showError($t('Payment {title} can\'t be initialized').replace('{title}', this.getTitle()));
8282
this.isPlaceOrderActionAllowed(true);
8383
throw response.message;
8484
},

app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/paypal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ define([
428428
Braintree.checkout.paypal.initAuthFlow();
429429
} catch (e) {
430430
this.messageContainer.addErrorMessage({
431-
message: $t('Payment ' + this.getTitle() + ' can\'t be initialized.')
431+
message: $t('Payment {title} can\'t be initialized').replace('{title}', this.getTitle())
432432
});
433433
}
434434
},

app/code/Magento/Catalog/view/adminhtml/web/catalog/base-image-uploader.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,7 @@ define([
171171
if (data.files.length > this.options.maxImageUploadCount) {
172172
$('body').notification('clear').notification('add', {
173173
error: true,
174-
message: $.mage.__('You can\'t upload more than ' + this.options.maxImageUploadCount +
175-
' images in one time'),
174+
message: $.mage.__('You can\'t upload more than {count} images in one time').replace('{count}', this.options.maxImageUploadCount),
176175

177176
/**
178177
* @param {*} message

app/code/Magento/Translation/Model/Js/PreProcessor.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Translation\Model\Js;
79

810
use Magento\Framework\App\AreaList;

app/code/Magento/Translation/Test/Unit/Model/Js/PreProcessorTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Translation\Test\Unit\Model\Js;
79

810
use Magento\Translation\Model\Js\PreProcessor;
911
use Magento\Translation\Model\Js\Config;
1012
use Magento\Framework\App\AreaList;
1113
use Magento\Framework\TranslateInterface;
1214

15+
/**
16+
* Class with unit tests for PreProcessor
17+
*/
1318
class PreProcessorTest extends \PHPUnit\Framework\TestCase
1419
{
1520
/**

app/code/Magento/Translation/etc/di.xml

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,25 +65,12 @@
6565
<argument name="patterns" xsi:type="array">
6666
<item name="i18n_translation" xsi:type="string"><![CDATA[~i18n\:\s*(["'])(.*?)(?<!\\)\1~]]></item>
6767
<item name="translate_wrapping" xsi:type="string"><![CDATA[~translate\=("')([^\'].*?)\'\"~]]></item>
68-
<item name="mage_translation_widget" xsi:type="string"><![CDATA[~(?:\$|jQuery)\.mage\.__\((?s)[^'"]*?(['"])(?P<translate>.+?)(?<!\\)\1(?s).*?\)~]]></item>
69-
<item name="mage_translation_static" xsi:type="string"><![CDATA[~\$t\((?s)[^'")]*?(["'])(?P<translate>.+?)\1(?s).*?\)~]]></item>
68+
<item name="mage_translation_widget" xsi:type="string"><![CDATA[~(?:\$|jQuery)\.mage\.__\((?s)\s*(['"])(?<translate>.+?)(?<!\\)\1\s*(?s)\)(?:(?!\.))~]]></item>
69+
<item name="mage_translation_static" xsi:type="string"><![CDATA[~\$t\((?s)\s*(["'])(?<translate>[^']+(?!\s*\+\s*')+?)\1\s*(?s)\)~]]></item>
7070
<item name="translate_args" xsi:type="string"><![CDATA[~translate args\=("|'|"')([^\'].*?)('"|'|")~]]></item>
7171
</argument>
7272
</arguments>
7373
</type>
74-
<virtualType name="embeddedJsConfig" type="Magento\Translation\Model\Js\Config">
75-
<arguments>
76-
<argument name="patterns" xsi:type="array">
77-
<item name="mage_translation_widget" xsi:type="string"><![CDATA[~(?:\$|jQuery)\.mage\.__\((?s)[^'")]*?(['"])(?P<translate>.+?)(?<!\\)\1(?s).*?\)~]]></item>
78-
<item name="mage_translation_static" xsi:type="string"><![CDATA[~\$t\((?s)[^'")]*?(["'])(?P<translate>.+?)\1(?s).*?\)~]]></item>
79-
</argument>
80-
</arguments>
81-
</virtualType>
82-
<type name="Magento\Translation\Model\Js\PreProcessor">
83-
<arguments>
84-
<argument name="config" xsi:type="object">embeddedJsConfig</argument>
85-
</arguments>
86-
</type>
8774
<virtualType name="AssetPreProcessorPool">
8875
<arguments>
8976
<argument name="preprocessors" xsi:type="array">

dev/tests/integration/testsuite/Magento/Translation/Model/Js/PreProcessorTest.php

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,22 +125,54 @@ public function contentForTranslateDataProvider()
125125
<<<EOT
126126
title: $.mage.__(
127127
'Original value for Magento_Store module'
128-
)
128+
),
129129
EOT
130130
,
131131
<<<EOT
132-
title: 'Translated value for Magento_Store module in en_AU'
132+
title: 'Translated value for Magento_Store module in en_AU',
133133
EOT
134134
],
135135
[
136136
<<<EOT
137137
title: \$t(
138138
'Original value for Magento_Store module'
139+
);
140+
EOT
141+
,
142+
<<<EOT
143+
title: 'Translated value for Magento_Store module in en_AU';
144+
EOT
145+
],
146+
[
147+
<<<EOT
148+
$.mage.__('The maximum you may purchase is %1.').replace('%1', params.maxAllowed);
149+
EOT
150+
,
151+
<<<EOT
152+
$.mage.__('The maximum you may purchase is %1.').replace('%1', params.maxAllowed);
153+
EOT
154+
],
155+
[
156+
<<<EOT
157+
\$t("text double quote");
158+
\$t('text "some');
159+
\$t('Payment ' + this.getTitle() + ' can\'t be initialized')
160+
\$t.__('The maximum you may purchase is %1.').replace('%1', params.maxAllowed);
161+
\$t(
162+
'Set unique country-state combinations within the same fixed product tax. ' +
163+
'Verify the combinations and try again.'
139164
)
140165
EOT
141166
,
142167
<<<EOT
143-
title: 'Translated value for Magento_Store module in en_AU'
168+
'text double quote';
169+
'text "some';
170+
\$t('Payment ' + this.getTitle() + ' can\'t be initialized')
171+
\$t.__('The maximum you may purchase is %1.').replace('%1', params.maxAllowed);
172+
\$t(
173+
'Set unique country-state combinations within the same fixed product tax. ' +
174+
'Verify the combinations and try again.'
175+
)
144176
EOT
145177
],
146178
];

0 commit comments

Comments
 (0)