Skip to content

Commit d63d7e7

Browse files
authored
Merge pull request #1353 from magento-tsg/MAGETWO-67048
MAGETWO-67048: Cannot add translate attribute into the di.xml
2 parents a0428fe + 29e039b commit d63d7e7

File tree

28 files changed

+423
-243
lines changed

28 files changed

+423
-243
lines changed

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

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -181,28 +181,28 @@
181181
<type name="Magento\Analytics\Model\Config\Source\Vertical">
182182
<arguments>
183183
<argument name="verticals" xsi:type="array">
184-
<item name="0" xsi:type="string">Apps and Games</item>
185-
<item name="1" xsi:type="string">Athletic/Sporting Goods</item>
186-
<item name="2" xsi:type="string">Art and Design</item>
187-
<item name="3" xsi:type="string">Auto Parts</item>
188-
<item name="4" xsi:type="string">Baby/Children’s Apparel, Gear and Toys</item>
189-
<item name="5" xsi:type="string">Beauty and Cosmetics</item>
190-
<item name="6" xsi:type="string">Books, Music and Magazines</item>
191-
<item name="7" xsi:type="string">Crafts and Stationery</item>
192-
<item name="8" xsi:type="string">Consumer Electronics</item>
193-
<item name="9" xsi:type="string">Deal Site</item>
194-
<item name="10" xsi:type="string">Fashion Apparel and Accessories</item>
195-
<item name="11" xsi:type="string">Food, Beverage and Grocery</item>
196-
<item name="12" xsi:type="string">Home Goods and Furniture</item>
197-
<item name="13" xsi:type="string">Home Improvement</item>
198-
<item name="14" xsi:type="string">Jewelry and Watches</item>
199-
<item name="15" xsi:type="string">Mass Merchant</item>
200-
<item name="16" xsi:type="string">Office Supplies</item>
201-
<item name="17" xsi:type="string">Outdoor and Camping Gear</item>
202-
<item name="18" xsi:type="string">Pet Goods</item>
203-
<item name="19" xsi:type="string">Pharma and Medical Devices</item>
204-
<item name="20" xsi:type="string">Technology B2B</item>
205-
<item name="21" xsi:type="string">Other</item>
184+
<item name="0" xsi:type="string" translatable="true">Apps and Games</item>
185+
<item name="1" xsi:type="string" translatable="true">Athletic/Sporting Goods</item>
186+
<item name="2" xsi:type="string" translatable="true">Art and Design</item>
187+
<item name="3" xsi:type="string" translatable="true">Auto Parts</item>
188+
<item name="4" xsi:type="string" translatable="true">Baby/Children’s Apparel, Gear and Toys</item>
189+
<item name="5" xsi:type="string" translatable="true">Beauty and Cosmetics</item>
190+
<item name="6" xsi:type="string" translatable="true">Books, Music and Magazines</item>
191+
<item name="7" xsi:type="string" translatable="true">Crafts and Stationery</item>
192+
<item name="8" xsi:type="string" translatable="true">Consumer Electronics</item>
193+
<item name="9" xsi:type="string" translatable="true">Deal Site</item>
194+
<item name="10" xsi:type="string" translatable="true">Fashion Apparel and Accessories</item>
195+
<item name="11" xsi:type="string" translatable="true">Food, Beverage and Grocery</item>
196+
<item name="12" xsi:type="string" translatable="true">Home Goods and Furniture</item>
197+
<item name="13" xsi:type="string" translatable="true">Home Improvement</item>
198+
<item name="14" xsi:type="string" translatable="true">Jewelry and Watches</item>
199+
<item name="15" xsi:type="string" translatable="true">Mass Merchant</item>
200+
<item name="16" xsi:type="string" translatable="true">Office Supplies</item>
201+
<item name="17" xsi:type="string" translatable="true">Outdoor and Camping Gear</item>
202+
<item name="18" xsi:type="string" translatable="true">Pet Goods</item>
203+
<item name="19" xsi:type="string" translatable="true">Pharma and Medical Devices</item>
204+
<item name="20" xsi:type="string" translatable="true">Technology B2B</item>
205+
<item name="21" xsi:type="string" translatable="true">Other</item>
206206
</argument>
207207
</arguments>
208208
</type>

app/code/Magento/Analytics/i18n/en_US.csv

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"These arguments can't be empty ""%1""","These arguments can't be empty ""%1"""
1717
"Cannot find predefined integration user!","Cannot find predefined integration user!"
1818
"File is not ready yet.","File is not ready yet."
19+
"Your Base URL has been changed and your reports are being updated. Advanced Reporting will be available once this change has been processed. Please try again later.","Your Base URL has been changed and your reports are being updated. Advanced Reporting will be available once this change has been processed. Please try again later."
1920
"Failed to synchronize data to the Magento Business Intelligence service. ","Failed to synchronize data to the Magento Business Intelligence service. "
2021
"<a href=""%1"">Retry Synchronization</a>","<a href=""%1"">Retry Synchronization</a>"
2122
TestMessage,TestMessage
@@ -49,6 +50,24 @@ Industry,Industry
4950
href=""https://dashboard.rjmetrics.com/v2/magento/signup/"">BI Essentials</a> tier.","Magento Business Intelligence provides you with a simple and clear path to
5051
becoming more data driven.</br> Learn more about <a target=""_blank""
5152
href=""https://dashboard.rjmetrics.com/v2/magento/signup/"">BI Essentials</a> tier."
53+
"Auto Parts","Auto Parts"
54+
"Baby/Children’s Apparel, Gear and Toys","Baby/Children’s Apparel, Gear and Toys"
55+
"Beauty and Cosmetics","Beauty and Cosmetics"
56+
"Books, Music and Magazines","Books, Music and Magazines"
57+
"Crafts and Stationery","Crafts and Stationery"
58+
"Consumer Electronics","Consumer Electronics"
59+
"Deal Site","Deal Site"
60+
"Fashion Apparel and Accessories","Fashion Apparel and Accessories"
61+
"Food, Beverage and Grocery","Food, Beverage and Grocery"
62+
"Home Goods and Furniture","Home Goods and Furniture"
63+
"Home Improvement","Home Improvement"
64+
"Jewelry and Watches","Jewelry and Watches"
65+
"Mass Merchant","Mass Merchant"
66+
"Office Supplies","Office Supplies"
67+
"Outdoor and Camping Gear","Outdoor and Camping Gear"
68+
"Pet Goods","Pet Goods"
69+
"Pharma and Medical Devices","Pharma and Medical Devices"
70+
"Technology B2B","Technology B2B"
5271
"Analytics Subscription","Analytics Subscription"
5372
"powered by Magento Business Intelligence","powered by Magento Business Intelligence"
5473
"<p>When you turn on Advanced

app/code/Magento/Catalog/Model/Entity/Product/Attribute/Design/Options/Container.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function getOptionText($value)
2424
if (sizeof($options) > 0) {
2525
foreach ($options as $option) {
2626
if (isset($option['value']) && $option['value'] == $value) {
27-
return $option['label'];
27+
return __($option['label']);
2828
}
2929
}
3030
}

app/code/Magento/Catalog/etc/adminhtml/di.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@
2020
<arguments>
2121
<argument name="imageTypes" xsi:type="array">
2222
<item name="small" xsi:type="array">
23-
<item name="title" xsi:type="string">Small</item>
23+
<item name="title" xsi:type="string" translatable="true">Small</item>
2424
<item name="attribute" xsi:type="string">small_image</item>
2525
</item>
2626
<item name="main" xsi:type="array">
27-
<item name="title" xsi:type="string">Main</item>
27+
<item name="title" xsi:type="string" translatable="true">Main</item>
2828
<item name="attribute" xsi:type="string">image</item>
2929
</item>
3030
<item name="cart" xsi:type="array">
31-
<item name="title" xsi:type="string">Thumbnail</item>
31+
<item name="title" xsi:type="string" translatable="true">Thumbnail</item>
3232
<item name="attribute" xsi:type="string">thumbnail</item>
3333
</item>
3434
<item name="custom" xsi:type="array">
35-
<item name="title" xsi:type="string">Custom image</item>
35+
<item name="title" xsi:type="string" translatable="true">Custom image</item>
3636
<item name="attribute" xsi:type="string">custom_image</item>
3737
</item>
3838
</argument>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,11 @@
144144
<argument name="options" xsi:type="array">
145145
<item name="option1" xsi:type="array">
146146
<item name="value" xsi:type="string">container1</item>
147-
<item name="label" xsi:type="string">Product Info Column</item>
147+
<item name="label" xsi:type="string" translatable="true">Product Info Column</item>
148148
</item>
149149
<item name="option2" xsi:type="array">
150150
<item name="value" xsi:type="string">container2</item>
151-
<item name="label" xsi:type="string">Block after Info Column</item>
151+
<item name="label" xsi:type="string" translatable="true">Block after Info Column</item>
152152
</item>
153153
</argument>
154154
</arguments>

app/code/Magento/Catalog/i18n/en_US.csv

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ Catalog,Catalog
210210
"An attribute with this code already exists.","An attribute with this code already exists."
211211
"An attribute with the same code (%1) already exists.","An attribute with the same code (%1) already exists."
212212
"The value of Admin must be unique.","The value of Admin must be unique."
213+
"The value of Admin scope can't be empty.","The value of Admin scope can't be empty."
213214
"You duplicated the product.","You duplicated the product."
214215
"This product doesn't exist.","This product doesn't exist."
215216
"Invalid product id. Should be numeric value greater than 0","Invalid product id. Should be numeric value greater than 0"
@@ -622,9 +623,13 @@ OK,OK
622623
"Image Detail","Image Detail"
623624
Adding...,Adding...
624625
Added,Added
626+
"does not implement Storage Interface","does not implement Storage Interface"
625627
"unselect all","unselect all"
626628
Inventory,Inventory
627629
"Catalog Section","Catalog Section"
630+
Small,Small
631+
Main,Main
632+
"Custom image","Custom image"
628633
"Product Fields Auto-Generation","Product Fields Auto-Generation"
629634
"Mask for SKU","Mask for SKU"
630635
"Use {{name}} as Product Name placeholder","Use {{name}} as Product Name placeholder"
@@ -633,6 +638,10 @@ Inventory,Inventory
633638
"Use {{name}} as Product Name or {{sku}} as Product SKU placeholders","Use {{name}} as Product Name or {{sku}} as Product SKU placeholders"
634639
"Mask for Meta Description","Mask for Meta Description"
635640
"Use {{name}} and {{description}} as Product Name and Product Description placeholders","Use {{name}} and {{description}} as Product Name and Product Description placeholders"
641+
"Recently Viewed/Compared Products","Recently Viewed/Compared Products"
642+
"Lifetime of products in Recently Viewed Widget","Lifetime of products in Recently Viewed Widget"
643+
"Lifetime of products in Recently Compared Widget","Lifetime of products in Recently Compared Widget"
644+
"Synchronize widget products with backend storage","Synchronize widget products with backend storage"
636645
Storefront,Storefront
637646
"List Mode","List Mode"
638647
"Products per Page on Grid Allowed Values","Products per Page on Grid Allowed Values"
@@ -666,6 +675,8 @@ Comma-separated.,Comma-separated.
666675
"Use Static URLs for Media Content in WYSIWYG for Catalog","Use Static URLs for Media Content in WYSIWYG for Catalog"
667676
"This applies only to catalog products and categories. Media content will be inserted into the editor as a static URL. Media content is not updated if the system configuration base URL changes.","This applies only to catalog products and categories. Media content will be inserted into the editor as a static URL. Media content is not updated if the system configuration base URL changes."
668677
"Top Level Category","Top Level Category"
678+
"Product Info Column","Product Info Column"
679+
"Block after Info Column","Block after Info Column"
669680
"Product Flat Data","Product Flat Data"
670681
"Reorganize EAV product structure to flat structure","Reorganize EAV product structure to flat structure"
671682
"Category Flat Data","Category Flat Data"
@@ -709,6 +720,22 @@ Template,Template
709720
"If empty, we'll use the category name here.","If empty, we'll use the category name here."
710721
"Category Link Block Template","Category Link Block Template"
711722
"Category Link Inline Template","Category Link Inline Template"
723+
"Recently Viewed Products","Recently Viewed Products"
724+
"List of Products Recently Viewed by Visitor","List of Products Recently Viewed by Visitor"
725+
"UI Component","UI Component"
726+
"Number of Products to display","Number of Products to display"
727+
"Product attributes to show","Product attributes to show"
728+
Image,Image
729+
"Learn More Link","Learn More Link"
730+
"Buttons to show","Buttons to show"
731+
"Add to Wishlist","Add to Wishlist"
732+
"Viewed Products Grid Template","Viewed Products Grid Template"
733+
"Viewed Products List Template","Viewed Products List Template"
734+
"Viewed Products Sidebar Template","Viewed Products Sidebar Template"
735+
"Recently Compared Products","Recently Compared Products"
736+
"List of Products Recently Compared by Visitor","List of Products Recently Compared by Visitor"
737+
"Compared Products Grid Template","Compared Products Grid Template"
738+
"Compared Products List Template","Compared Products List Template"
712739
Set,Set
713740
"Category Information","Category Information"
714741
"Enable Category","Enable Category"
@@ -763,3 +790,8 @@ Overview,Overview
763790
"Skip to the end of the images gallery","Skip to the end of the images gallery"
764791
"Skip to the beginning of the images gallery","Skip to the beginning of the images gallery"
765792
Details,Details
793+
"Recently Compared","Recently Compared"
794+
"Add To Cart","Add To Cart"
795+
"Add To Compare","Add To Compare"
796+
"Learn more","Learn more"
797+
"Recently Viewed","Recently Viewed"

app/code/Magento/Customer/Ui/Component/MassAction/Group/Options.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function jsonSerialize()
8888
foreach ($options as $optionCode) {
8989
$this->options[$optionCode['value']] = [
9090
'type' => 'customer_group_' . $optionCode['value'],
91-
'label' => $optionCode['label'],
91+
'label' => __($optionCode['label']),
9292
];
9393

9494
if ($this->urlPath && $this->paramName) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,8 @@
396396
<item name="urlPath" xsi:type="string">customer/index/massAssignGroup</item>
397397
<item name="paramName" xsi:type="string">group</item>
398398
<item name="confirm" xsi:type="array">
399-
<item name="title" xsi:type="string">Assign a Customer Group</item>
400-
<item name="message" xsi:type="string">Are you sure to assign selected customers to new group?</item>
399+
<item name="title" xsi:type="string" translatable="true">Assign a Customer Group</item>
400+
<item name="message" xsi:type="string" translatable="true">Are you sure to assign selected customers to new group?</item>
401401
</item>
402402
</argument>
403403
</arguments>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
<arguments>
1212
<argument name="servicesConfig" xsi:type="array">
1313
<item name="yahoofinance" xsi:type="array">
14-
<item name="label" xsi:type="string">Yahoo Finance Exchange</item>
14+
<item name="label" xsi:type="string" translatable="true">Yahoo Finance Exchange</item>
1515
<item name="class" xsi:type="string">Magento\Directory\Model\Currency\Import\YahooFinance</item>
1616
</item>
1717
<item name="webservicex" xsi:type="array">
18-
<item name="label" xsi:type="string">Webservicex</item>
18+
<item name="label" xsi:type="string" translatable="true">Webservicex</item>
1919
<item name="class" xsi:type="string">Magento\Directory\Model\Currency\Import\Webservicex</item>
2020
</item>
2121
<item name="fixerio" xsi:type="array">
22-
<item name="label" xsi:type="string">Fixer.io</item>
22+
<item name="label" xsi:type="string" translatable="true">Fixer.io</item>
2323
<item name="class" xsi:type="string">Magento\Directory\Model\Currency\Import\FixerIo</item>
2424
</item>
2525
</argument>
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Framework\Data\Argument\Interpreter;
8+
9+
use Magento\Framework\Phrase\RendererInterface;
10+
use Magento\Framework\Stdlib\BooleanUtils;
11+
12+
/**
13+
* @covers \Magento\Framework\Data\Argument\Interpreter\BaseStringUtils
14+
*/
15+
class BaseStringUtilsTest extends \PHPUnit_Framework_TestCase
16+
{
17+
/**
18+
* @var \Magento\Framework\Data\Argument\Interpreter\BaseStringUtils
19+
*/
20+
private $model;
21+
22+
/**
23+
* @var BooleanUtils|\PHPUnit_Framework_MockObject_MockObject
24+
*/
25+
private $booleanUtils;
26+
27+
/**
28+
* Prepare subject for tests.
29+
*/
30+
protected function setUp()
31+
{
32+
$this->booleanUtils = $this->getMock(BooleanUtils::class);
33+
$this->booleanUtils->expects(
34+
$this->any()
35+
)->method(
36+
'toBoolean'
37+
)->will(
38+
$this->returnValueMap([['true', true], ['false', false]])
39+
);
40+
$this->model = new BaseStringUtils($this->booleanUtils);
41+
/** @var RendererInterface|\PHPUnit_Framework_MockObject_MockObject $translateRenderer */
42+
$translateRenderer = $this->getMockForAbstractClass(RendererInterface::class);
43+
$translateRenderer->expects(self::never())->method('render');
44+
\Magento\Framework\Phrase::setRenderer($translateRenderer);
45+
}
46+
47+
/**
48+
* Check BaseStringUtils::evaluate() will not translate incoming $input['value'].
49+
*
50+
* @param array $input
51+
* @param bool $expected
52+
*
53+
* @dataProvider evaluateDataProvider
54+
*/
55+
public function testEvaluate($input, $expected)
56+
{
57+
$actual = $this->model->evaluate($input);
58+
$this->assertSame($expected, (string)$actual);
59+
}
60+
61+
/**
62+
* Provide test data and expected results for testEvaluate().
63+
*
64+
* @return array
65+
*/
66+
public function evaluateDataProvider()
67+
{
68+
return [
69+
'no value' => [[], ''],
70+
'with value' => [['value' => 'some value'], 'some value'],
71+
'translation required' => [
72+
['value' => 'some value', 'translate' => 'true'],
73+
'some value',
74+
],
75+
'translation not required' => [['value' => 'some value', 'translate' => 'false'], 'some value'],
76+
];
77+
}
78+
79+
/**
80+
* Check BaseStringUtils::evaluate() trows exception in case $input['value'] not a string.
81+
*
82+
* @param array $input
83+
* @dataProvider evaluateExceptionDataProvider
84+
* @expectedException \InvalidArgumentException
85+
* @expectedExceptionMessage String value is expected
86+
*/
87+
public function testEvaluateException($input)
88+
{
89+
$this->model->evaluate($input);
90+
}
91+
92+
/**
93+
* Provide test data for testEvaluateException.
94+
*
95+
* @return array
96+
*/
97+
public function evaluateExceptionDataProvider()
98+
{
99+
return ['not a string' => [['value' => 123]]];
100+
}
101+
}

0 commit comments

Comments
 (0)