File tree Expand file tree Collapse file tree 11 files changed +124
-43
lines changed
Checkout/Test/Mftf/Section
dev/tests/js/jasmine/tests/lib/mage Expand file tree Collapse file tree 11 files changed +124
-43
lines changed Original file line number Diff line number Diff line change 6
6
var config = {
7
7
map : {
8
8
'*' : {
9
- 'mediaUploader' : 'Magento_Backend/js/media-uploader'
9
+ 'mediaUploader' : 'Magento_Backend/js/media-uploader' ,
10
+ 'mage/translate' : 'Magento_Backend/js/translate'
10
11
}
11
12
}
12
13
} ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Copyright © Magento, Inc. All rights reserved.
3
+ * See COPYING.txt for license details.
4
+ */
5
+
6
+ /* eslint-disable strict */
7
+ ( function ( factory ) {
8
+ if ( typeof define === 'function' && define . amd ) {
9
+ define ( [
10
+ 'jquery' ,
11
+ 'mage/mage'
12
+ ] , factory ) ;
13
+ } else {
14
+ factory ( jQuery ) ;
15
+ }
16
+ } ( function ( $ ) {
17
+ $ . extend ( true , $ , {
18
+ mage : {
19
+ translate : ( function ( ) {
20
+ /**
21
+ * Key-value translations storage
22
+ * @type {Object }
23
+ * @private
24
+ */
25
+ var _data = { } ;
26
+
27
+ /**
28
+ * Add new translation (two string parameters) or several translations (object)
29
+ */
30
+ this . add = function ( ) {
31
+ if ( arguments . length > 1 ) {
32
+ _data [ arguments [ 0 ] ] = arguments [ 1 ] ;
33
+ } else if ( typeof arguments [ 0 ] === 'object' ) {
34
+ $ . extend ( _data , arguments [ 0 ] ) ;
35
+ }
36
+ } ;
37
+
38
+ /**
39
+ * Make a translation with parsing (to handle case when _data represents tuple)
40
+ * @param {String } text
41
+ * @return {String }
42
+ */
43
+ this . translate = function ( text ) {
44
+ return _data [ text ] ? _data [ text ] : text ;
45
+ } ;
46
+
47
+ return this ;
48
+ } ( ) )
49
+ }
50
+ } ) ;
51
+ $ . mage . __ = $ . proxy ( $ . mage . translate . translate , $ . mage . translate ) ;
52
+
53
+ return $ . mage . __ ;
54
+ } ) ) ;
Original file line number Diff line number Diff line change 31
31
<element name =" cartItemsAreaActive" type =" textarea" selector =" div.block.items-in-cart.active" timeout =" 30" />
32
32
<element name =" checkMoneyOrderPayment" type =" radio" selector =" input#checkmo.radio" timeout =" 30" />
33
33
<element name =" placeOrder" type =" button" selector =" .payment-method._active button.action.primary.checkout" timeout =" 30" />
34
- <element name =" paymentSectionTitle" type =" text" selector =" //*[@id='checkout-payment-method-load']//div[text()='Payment Method ']" />
34
+ <element name =" paymentSectionTitle" type =" text" selector =" //*[@id='checkout-payment-method-load']//div[@data-role='title ']" />
35
35
<element name =" orderSummarySubtotal" type =" text" selector =" //tr[@class='totals sub']//span[@class='price']" />
36
36
<element name =" orderSummaryShippingTotal" type =" text" selector =" //tr[@class='totals shipping excl']//span[@class='price']" />
37
37
<element name =" orderSummaryShippingMethod" type =" text" selector =" //tr[@class='totals shipping excl']//span[@class='value']" />
Original file line number Diff line number Diff line change 19
19
"magento/module-widget" : " *"
20
20
},
21
21
"suggest" : {
22
- "magento/module-translation" : " *" ,
23
22
"magento/module-theme-sample-data" : " *" ,
24
23
"magento/module-deploy" : " *" ,
25
24
"magento/module-directory" : " *"
Original file line number Diff line number Diff line change 11
11
<block name =" require.js" class =" Magento\Framework\View\Element\Template" template =" Magento_Theme::page/js/require_js.phtml" />
12
12
<referenceContainer name =" after.body.start" >
13
13
<block class =" Magento\RequireJs\Block\Html\Head\Config" name =" requirejs-config" />
14
- <block class =" Magento\Translation\Block\Html\Head\Config" name =" translate-config" />
15
- <block class =" Magento\Translation\Block\Js" name =" translate" template =" Magento_Translation::translate.phtml" />
16
14
<block class =" Magento\Framework\View\Element\Js\Cookie" name =" js_cookies" template =" Magento_Theme::js/cookie.phtml" />
17
15
<block class =" Magento\Theme\Block\Html\Notices" name =" global_notices" template =" Magento_Theme::html/notices.phtml" />
18
16
</referenceContainer >
Original file line number Diff line number Diff line change 6
6
7
7
/** @var \Magento\Translation\Block\Js $block */
8
8
?>
9
+ <!--
10
+ For frontend area dictionary file is inserted into html head in Magento/Translation/view/base/templates/dictionary.phtml
11
+ Same translation mechanism should be introduced for admin area in 2.4 version.
12
+ -->
9
13
<?php if ($ block ->dictionaryEnabled ()) : ?>
10
14
<script>
11
15
require.config({
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Copyright © Magento, Inc. All rights reserved.
3
+ * See COPYING.txt for license details.
4
+ */
5
+
6
+ define ( [
7
+ 'text!js-translation.json'
8
+ ] , function ( dict ) {
9
+ 'use strict' ;
10
+
11
+ return JSON . parse ( dict ) ;
12
+ } ) ;
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" ?>
2
+ <!--
3
+ /**
4
+ * Copyright © Magento, Inc. All rights reserved.
5
+ * See COPYING.txt for license details.
6
+ */
7
+ -->
8
+ <page xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : noNamespaceSchemaLocation =" urn:magento:framework:View/Layout/etc/page_configuration.xsd" >
9
+ <body >
10
+ <referenceBlock name =" head.additional" >
11
+ <block class =" Magento\Translation\Block\Html\Head\Config" name =" translate-config" />
12
+ </referenceBlock >
13
+ </body >
14
+ </page >
Original file line number Diff line number Diff line change @@ -8,10 +8,12 @@ var config = {
8
8
'*' : {
9
9
editTrigger : 'mage/edit-trigger' ,
10
10
addClass : 'Magento_Translation/js/add-class' ,
11
- 'Magento_Translation/add-class' : 'Magento_Translation/js/add-class'
11
+ 'Magento_Translation/add-class' : 'Magento_Translation/js/add-class' ,
12
+ mageTranslationDictionary : 'Magento_Translation/js/mage-translation-dictionary'
12
13
}
13
14
} ,
14
15
deps : [
15
- 'mage/translate-inline'
16
+ 'mage/translate-inline' ,
17
+ 'mageTranslationDictionary'
16
18
]
17
19
} ;
Original file line number Diff line number Diff line change @@ -9,11 +9,16 @@ define([
9
9
] , function ( $ ) {
10
10
'use strict' ;
11
11
12
+ // be careful with test variation order as one variation can affect another one
12
13
describe ( 'Test for mage/translate jQuery plugin' , function ( ) {
13
14
it ( 'works with one string as parameter' , function ( ) {
14
15
$ . mage . translate . add ( 'Hello World!' ) ;
15
16
expect ( 'Hello World!' ) . toEqual ( $ . mage . translate . translate ( 'Hello World!' ) ) ;
16
17
} ) ;
18
+ it ( 'works with translation alias __' , function ( ) {
19
+ $ . mage . translate . add ( 'Hello World!' ) ;
20
+ expect ( 'Hello World!' ) . toEqual ( $ . mage . __ ( 'Hello World!' ) ) ;
21
+ } ) ;
17
22
it ( 'works with one array as parameter' , function ( ) {
18
23
$ . mage . translate . add ( [ 'Hello World!' , 'Bonjour tout le monde!' ] ) ;
19
24
expect ( 'Hello World!' ) . toEqual ( $ . mage . translate . translate ( 'Hello World!' ) ) ;
@@ -40,10 +45,6 @@ define([
40
45
$ . mage . translate . add ( 'Hello World!' , 'Bonjour tout le monde!' ) ;
41
46
expect ( 'Bonjour tout le monde!' ) . toEqual ( $ . mage . translate . translate ( 'Hello World!' ) ) ;
42
47
} ) ;
43
- it ( 'works with translation alias __' , function ( ) {
44
- $ . mage . translate . add ( 'Hello World!' ) ;
45
- expect ( 'Hello World!' ) . toEqual ( $ . mage . __ ( 'Hello World!' ) ) ;
46
- } ) ;
47
48
} ) ;
48
49
49
50
} ) ;
You can’t perform that action at this time.
0 commit comments