Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 8ad62e4

Browse files
committed
MAGETWO-67048: Cannot add translate attribute into the di.xml
1 parent b28793f commit 8ad62e4

File tree

12 files changed

+256
-45
lines changed

12 files changed

+256
-45
lines changed

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/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/Ui/etc/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@
256256
<item name="array" xsi:type="object">arrayArgumentInterpreterProxy</item>
257257
<item name="boolean" xsi:type="object">Magento\Framework\Data\Argument\Interpreter\Boolean</item>
258258
<item name="number" xsi:type="object">Magento\Framework\Data\Argument\Interpreter\Number</item>
259-
<item name="string" xsi:type="object">Magento\Framework\Data\Argument\Interpreter\StringUtils</item>
259+
<item name="string" xsi:type="object">Magento\Framework\Data\Argument\Interpreter\TranslatableStringUtils</item>
260260
<item name="null" xsi:type="object">Magento\Framework\Data\Argument\Interpreter\NullType</item>
261261
<item name="url" xsi:type="object">Magento\Ui\Config\Argument\Parser\Url</item>
262262
</argument>

app/etc/di.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@
394394
<item name="array" xsi:type="object">layoutArrayArgumentReaderInterpreterProxy</item>
395395
<item name="boolean" xsi:type="object">Magento\Framework\Data\Argument\Interpreter\Boolean</item>
396396
<item name="number" xsi:type="object">Magento\Framework\Data\Argument\Interpreter\Number</item>
397-
<item name="string" xsi:type="object">Magento\Framework\Data\Argument\Interpreter\StringUtils</item>
397+
<item name="string" xsi:type="object">Magento\Framework\Data\Argument\Interpreter\TranslatableStringUtils</item>
398398
<item name="null" xsi:type="object">Magento\Framework\Data\Argument\Interpreter\NullType</item>
399399
<item name="object" xsi:type="object">Magento\Framework\View\Layout\Argument\Interpreter\Passthrough</item>
400400
<item name="url" xsi:type="object">Magento\Framework\View\Layout\Argument\Interpreter\Passthrough</item>
@@ -410,7 +410,7 @@
410410
<item name="array" xsi:type="object">layoutArrayArgumentGeneratorInterpreterProxy</item>
411411
<item name="boolean" xsi:type="object">Magento\Framework\Data\Argument\Interpreter\Boolean</item>
412412
<item name="number" xsi:type="object">Magento\Framework\Data\Argument\Interpreter\Number</item>
413-
<item name="string" xsi:type="object">Magento\Framework\Data\Argument\Interpreter\StringUtils</item>
413+
<item name="string" xsi:type="object">Magento\Framework\Data\Argument\Interpreter\TranslatableStringUtils</item>
414414
<item name="null" xsi:type="object">Magento\Framework\Data\Argument\Interpreter\NullType</item>
415415
<item name="object" xsi:type="object">layoutObjectArgumentInterpreter</item>
416416
<item name="url" xsi:type="object">Magento\Framework\View\Layout\Argument\Interpreter\Url</item>
@@ -455,7 +455,7 @@
455455
</virtualType>
456456
<type name="Magento\Framework\View\Layout\Argument\Interpreter\NamedParams">
457457
<arguments>
458-
<argument name="paramInterpreter" xsi:type="object">Magento\Framework\Data\Argument\Interpreter\StringUtils</argument>
458+
<argument name="paramInterpreter" xsi:type="object">Magento\Framework\Data\Argument\Interpreter\TranslatableStringUtils</argument>
459459
</arguments>
460460
</type>
461461
<virtualType name="containerRenderPool" type="Magento\Framework\View\Layout\ReaderPool">

dev/tests/integration/testsuite/Magento/Framework/Data/Argument/Interpreter/StringUtilsTest.php

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
*/
66
namespace Magento\Framework\Data\Argument\Interpreter;
77

8+
use Magento\Framework\Phrase\RendererInterface;
9+
use Magento\Framework\Stdlib\BooleanUtils;
10+
11+
/**
12+
* @covers StringUtils.
13+
*/
814
class StringUtilsTest extends \PHPUnit_Framework_TestCase
915
{
1016
/**
@@ -13,13 +19,13 @@ class StringUtilsTest extends \PHPUnit_Framework_TestCase
1319
protected $_model;
1420

1521
/**
16-
* @var \PHPUnit_Framework_MockObject_MockObject
22+
* @var BooleanUtils|\PHPUnit_Framework_MockObject_MockObject
1723
*/
1824
protected $_booleanUtils;
1925

2026
protected function setUp()
2127
{
22-
$this->_booleanUtils = $this->getMock(\Magento\Framework\Stdlib\BooleanUtils::class);
28+
$this->_booleanUtils = $this->getMock(BooleanUtils::class);
2329
$this->_booleanUtils->expects(
2430
$this->any()
2531
)->method(
@@ -28,18 +34,15 @@ protected function setUp()
2834
$this->returnValueMap([['true', true], ['false', false]])
2935
);
3036
$this->_model = new StringUtils($this->_booleanUtils);
31-
$translateRenderer = $this->getMockForAbstractClass(\Magento\Framework\Phrase\RendererInterface::class);
32-
$translateRenderer->expects($this->any())->method('render')->will(
33-
$this->returnCallback(
34-
function ($input) {
35-
return end($input) . ' (translated)';
36-
}
37-
)
38-
);
37+
/** @var RendererInterface|\PHPUnit_Framework_MockObject_MockObject $translateRenderer */
38+
$translateRenderer = $this->getMockForAbstractClass(RendererInterface::class);
39+
$translateRenderer->expects(self::never())->method('render');
3940
\Magento\Framework\Phrase::setRenderer($translateRenderer);
4041
}
4142

4243
/**
44+
* Check StringUtils::evaluate() won't translate incoming $input['value'].
45+
*
4346
* @param array $input
4447
* @param bool $expected
4548
*
@@ -51,20 +54,27 @@ public function testEvaluate($input, $expected)
5154
$this->assertSame($expected, (string)$actual);
5255
}
5356

57+
/**
58+
* Provide test data and expected results for testEavaluate().
59+
*
60+
* @return array
61+
*/
5462
public function evaluateDataProvider()
5563
{
5664
return [
5765
'no value' => [[], ''],
5866
'with value' => [['value' => 'some value'], 'some value'],
5967
'translation required' => [
6068
['value' => 'some value', 'translate' => 'true'],
61-
'some value (translated)',
69+
'some value',
6270
],
6371
'translation not required' => [['value' => 'some value', 'translate' => 'false'], 'some value']
6472
];
6573
}
6674

6775
/**
76+
* Check StringUtils::evaluate() trows exception in case $input['value'] not a string.
77+
*
6878
* @param array $input
6979
*
7080
* @dataProvider evaluateExceptionDataProvider
@@ -76,6 +86,11 @@ public function testEvaluateException($input)
7686
$this->_model->evaluate($input);
7787
}
7888

89+
/**
90+
* Provide test data for testEvaluateException.
91+
*
92+
* @return array
93+
*/
7994
public function evaluateExceptionDataProvider()
8095
{
8196
return ['not a string' => [['value' => 123]]];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Framework\Data\Argument\Interpreter;
7+
8+
use Magento\Framework\Phrase\RendererInterface;
9+
use Magento\Framework\Stdlib\BooleanUtils;
10+
11+
/**
12+
* @covers TranslatableStringUtils.
13+
*/
14+
class TranslatableStringUtilsTest extends \PHPUnit_Framework_TestCase
15+
{
16+
/**
17+
* @var \Magento\Framework\Data\Argument\Interpreter\StringUtils
18+
*/
19+
private $model;
20+
21+
/**
22+
* @var BooleanUtils|\PHPUnit_Framework_MockObject_MockObject
23+
*/
24+
protected $booleanUtils;
25+
26+
/**
27+
* Prepare subject for test.
28+
*/
29+
protected function setUp()
30+
{
31+
$this->booleanUtils = $this->getMock(BooleanUtils::class);
32+
$this->booleanUtils->expects(
33+
$this->any()
34+
)->method(
35+
'toBoolean'
36+
)->will(
37+
$this->returnValueMap([['true', true], ['false', false]])
38+
);
39+
40+
$baseStringUtils = new StringUtils($this->booleanUtils);
41+
$this->model = new TranslatableStringUtils($this->booleanUtils, $baseStringUtils);
42+
/** @var RendererInterface|\PHPUnit_Framework_MockObject_MockObject $translateRenderer */
43+
$translateRenderer = $this->getMockForAbstractClass(RendererInterface::class);
44+
$translateRenderer->expects($this->any())->method('render')->will(
45+
$this->returnCallback(
46+
function ($input) {
47+
return end($input) . ' (translated)';
48+
}
49+
)
50+
);
51+
\Magento\Framework\Phrase::setRenderer($translateRenderer);
52+
}
53+
54+
/**
55+
* Check TranslatableStringUtils::evaluate can translate incoming $input['value'].
56+
*
57+
* @param array $input
58+
* @param bool $expected
59+
*
60+
* @dataProvider evaluateDataProvider
61+
*/
62+
public function testEvaluate($input, $expected)
63+
{
64+
$actual = $this->model->evaluate($input);
65+
$this->assertSame($expected, (string)$actual);
66+
}
67+
68+
/**
69+
* Provide test data and expected results for testEvaluate().
70+
*
71+
* @return array
72+
*/
73+
public function evaluateDataProvider()
74+
{
75+
return [
76+
'no value' => [[], ''],
77+
'with value' => [['value' => 'some value'], 'some value'],
78+
'translation required' => [
79+
['value' => 'some value', 'translate' => 'true'],
80+
'some value (translated)',
81+
],
82+
'translation not required' => [['value' => 'some value', 'translate' => 'false'], 'some value']
83+
];
84+
}
85+
86+
/**
87+
* Check TranslatableStringUtils::evaluate() throws exception in case $input['value'] is not a string.
88+
*
89+
* @param array $input
90+
*
91+
* @dataProvider evaluateExceptionDataProvider
92+
* @expectedException \InvalidArgumentException
93+
* @expectedExceptionMessage String value is expected
94+
*/
95+
public function testEvaluateException($input)
96+
{
97+
$this->model->evaluate($input);
98+
}
99+
100+
/**
101+
* Provide test data for testEvaluateException.
102+
*
103+
* @return array
104+
*/
105+
public function evaluateExceptionDataProvider()
106+
{
107+
return ['not a string' => [['value' => 123]]];
108+
}
109+
}

lib/internal/Magento/Framework/App/ObjectManagerFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ protected function createArgumentInterpreter(
225225
$result = new \Magento\Framework\Data\Argument\Interpreter\Composite(
226226
[
227227
'boolean' => new \Magento\Framework\Data\Argument\Interpreter\Boolean($booleanUtils),
228-
'string' => new \Magento\Framework\Data\Argument\Interpreter\StringUtils($booleanUtils, false),
228+
'string' => new \Magento\Framework\Data\Argument\Interpreter\StringUtils($booleanUtils),
229229
'number' => new \Magento\Framework\Data\Argument\Interpreter\Number(),
230230
'null' => new \Magento\Framework\Data\Argument\Interpreter\NullType(),
231231
'object' => new \Magento\Framework\Data\Argument\Interpreter\DataObject($booleanUtils),

0 commit comments

Comments
 (0)