File tree 7 files changed +47
-22
lines changed
Braintree/view/frontend/web/js/view/payment/method-renderer
Catalog/view/adminhtml/web/catalog
dev/tests/integration/testsuite/Magento/Translation/Model/Js
7 files changed +47
-22
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ define(
78
78
* @param {Object } response
79
79
*/
80
80
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 ( ) ) ) ;
82
82
this . isPlaceOrderActionAllowed ( true ) ;
83
83
throw response . message ;
84
84
} ,
Original file line number Diff line number Diff line change @@ -428,7 +428,7 @@ define([
428
428
Braintree . checkout . paypal . initAuthFlow ( ) ;
429
429
} catch ( e ) {
430
430
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 ( ) )
432
432
} ) ;
433
433
}
434
434
} ,
Original file line number Diff line number Diff line change @@ -171,8 +171,7 @@ define([
171
171
if ( data . files . length > this . options . maxImageUploadCount ) {
172
172
$ ( 'body' ) . notification ( 'clear' ) . notification ( 'add' , {
173
173
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 ) ,
176
175
177
176
/**
178
177
* @param {* } message
Original file line number Diff line number Diff line change 3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+ declare (strict_types=1 );
7
+
6
8
namespace Magento \Translation \Model \Js ;
7
9
8
10
use Magento \Framework \App \AreaList ;
Original file line number Diff line number Diff line change 3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+ declare (strict_types=1 );
7
+
6
8
namespace Magento \Translation \Test \Unit \Model \Js ;
7
9
8
10
use Magento \Translation \Model \Js \PreProcessor ;
9
11
use Magento \Translation \Model \Js \Config ;
10
12
use Magento \Framework \App \AreaList ;
11
13
use Magento \Framework \TranslateInterface ;
12
14
15
+ /**
16
+ * Class with unit tests for PreProcessor
17
+ */
13
18
class PreProcessorTest extends \PHPUnit \Framework \TestCase
14
19
{
15
20
/**
Original file line number Diff line number Diff line change 65
65
<argument name =" patterns" xsi : type =" array" >
66
66
<item name =" i18n_translation" xsi : type =" string" ><![CDATA[ ~i18n\:\s*(["'])(.*?)(?<!\\)\1~]]> </item >
67
67
<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 >
70
70
<item name =" translate_args" xsi : type =" string" ><![CDATA[ ~translate args\=("|'|"')([^\'].*?)('"|'|")~]]> </item >
71
71
</argument >
72
72
</arguments >
73
73
</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 >
87
74
<virtualType name =" AssetPreProcessorPool" >
88
75
<arguments >
89
76
<argument name =" preprocessors" xsi : type =" array" >
Original file line number Diff line number Diff line change @@ -125,22 +125,54 @@ public function contentForTranslateDataProvider()
125
125
<<<EOT
126
126
title: $.mage.__(
127
127
'Original value for Magento_Store module'
128
- )
128
+ ),
129
129
EOT
130
130
,
131
131
<<<EOT
132
- title: 'Translated value for Magento_Store module in en_AU'
132
+ title: 'Translated value for Magento_Store module in en_AU',
133
133
EOT
134
134
],
135
135
[
136
136
<<<EOT
137
137
title: \$t(
138
138
'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.'
139
164
)
140
165
EOT
141
166
,
142
167
<<<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
+ )
144
176
EOT
145
177
],
146
178
];
You can’t perform that action at this time.
0 commit comments