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 66var config = {
77 map : {
88 '*' : {
9- 'mediaUploader' : 'Magento_Backend/js/media-uploader'
9+ 'mediaUploader' : 'Magento_Backend/js/media-uploader' ,
10+ 'mage/translate' : 'Magento_Backend/js/translate'
1011 }
1112 }
1213} ;
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 3131 <element name =" cartItemsAreaActive" type =" textarea" selector =" div.block.items-in-cart.active" timeout =" 30" />
3232 <element name =" checkMoneyOrderPayment" type =" radio" selector =" input#checkmo.radio" timeout =" 30" />
3333 <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 ']" />
3535 <element name =" orderSummarySubtotal" type =" text" selector =" //tr[@class='totals sub']//span[@class='price']" />
3636 <element name =" orderSummaryShippingTotal" type =" text" selector =" //tr[@class='totals shipping excl']//span[@class='price']" />
3737 <element name =" orderSummaryShippingMethod" type =" text" selector =" //tr[@class='totals shipping excl']//span[@class='value']" />
Original file line number Diff line number Diff line change 1919 "magento/module-widget" : " *"
2020 },
2121 "suggest" : {
22- "magento/module-translation" : " *" ,
2322 "magento/module-theme-sample-data" : " *" ,
2423 "magento/module-deploy" : " *" ,
2524 "magento/module-directory" : " *"
Original file line number Diff line number Diff line change 1111 <block name =" require.js" class =" Magento\Framework\View\Element\Template" template =" Magento_Theme::page/js/require_js.phtml" />
1212 <referenceContainer name =" after.body.start" >
1313 <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" />
1614 <block class =" Magento\Framework\View\Element\Js\Cookie" name =" js_cookies" template =" Magento_Theme::js/cookie.phtml" />
1715 <block class =" Magento\Theme\Block\Html\Notices" name =" global_notices" template =" Magento_Theme::html/notices.phtml" />
1816 </referenceContainer >
Original file line number Diff line number Diff line change 66
77/** @var \Magento\Translation\Block\Js $block */
88?>
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+ -->
913<?php if ($ block ->dictionaryEnabled ()) : ?>
1014 <script>
1115 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 = {
88 '*' : {
99 editTrigger : 'mage/edit-trigger' ,
1010 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'
1213 }
1314 } ,
1415 deps : [
15- 'mage/translate-inline'
16+ 'mage/translate-inline' ,
17+ 'mageTranslationDictionary'
1618 ]
1719} ;
Original file line number Diff line number Diff line change @@ -9,11 +9,16 @@ define([
99] , function ( $ ) {
1010 'use strict' ;
1111
12+ // be careful with test variation order as one variation can affect another one
1213 describe ( 'Test for mage/translate jQuery plugin' , function ( ) {
1314 it ( 'works with one string as parameter' , function ( ) {
1415 $ . mage . translate . add ( 'Hello World!' ) ;
1516 expect ( 'Hello World!' ) . toEqual ( $ . mage . translate . translate ( 'Hello World!' ) ) ;
1617 } ) ;
18+ it ( 'works with translation alias __' , function ( ) {
19+ $ . mage . translate . add ( 'Hello World!' ) ;
20+ expect ( 'Hello World!' ) . toEqual ( $ . mage . __ ( 'Hello World!' ) ) ;
21+ } ) ;
1722 it ( 'works with one array as parameter' , function ( ) {
1823 $ . mage . translate . add ( [ 'Hello World!' , 'Bonjour tout le monde!' ] ) ;
1924 expect ( 'Hello World!' ) . toEqual ( $ . mage . translate . translate ( 'Hello World!' ) ) ;
@@ -40,10 +45,6 @@ define([
4045 $ . mage . translate . add ( 'Hello World!' , 'Bonjour tout le monde!' ) ;
4146 expect ( 'Bonjour tout le monde!' ) . toEqual ( $ . mage . translate . translate ( 'Hello World!' ) ) ;
4247 } ) ;
43- it ( 'works with translation alias __' , function ( ) {
44- $ . mage . translate . add ( 'Hello World!' ) ;
45- expect ( 'Hello World!' ) . toEqual ( $ . mage . __ ( 'Hello World!' ) ) ;
46- } ) ;
4748 } ) ;
4849
4950} ) ;
You can’t perform that action at this time.
0 commit comments