Skip to content

Commit 44770fe

Browse files
committed
MAGETWO-95819: Customer registration fields not translated
- Added retrieving store labels of attributes in customer widgets
1 parent 679fc61 commit 44770fe

File tree

6 files changed

+60
-6
lines changed

6 files changed

+60
-6
lines changed

app/code/Magento/Customer/Block/Widget/Dob.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function __construct(
6161
}
6262

6363
/**
64-
* @return void
64+
* @inheritdoc
6565
*/
6666
public function _construct()
6767
{
@@ -70,6 +70,8 @@ public function _construct()
7070
}
7171

7272
/**
73+
* Check if dob attribute enabled in system
74+
*
7375
* @return bool
7476
*/
7577
public function isEnabled()
@@ -79,6 +81,8 @@ public function isEnabled()
7981
}
8082

8183
/**
84+
* Check if dob attribute marked as required
85+
*
8286
* @return bool
8387
*/
8488
public function isRequired()
@@ -88,6 +92,8 @@ public function isRequired()
8892
}
8993

9094
/**
95+
* Set date
96+
*
9197
* @param string $date
9298
* @return $this
9399
*/
@@ -135,6 +141,8 @@ protected function applyOutputFilter($value)
135141
}
136142

137143
/**
144+
* Get day
145+
*
138146
* @return string|bool
139147
*/
140148
public function getDay()
@@ -143,6 +151,8 @@ public function getDay()
143151
}
144152

145153
/**
154+
* Get month
155+
*
146156
* @return string|bool
147157
*/
148158
public function getMonth()
@@ -151,6 +161,8 @@ public function getMonth()
151161
}
152162

153163
/**
164+
* Get year
165+
*
154166
* @return string|bool
155167
*/
156168
public function getYear()
@@ -168,6 +180,19 @@ public function getLabel()
168180
return __('Date of Birth');
169181
}
170182

183+
/**
184+
* Retrieve store attribute label
185+
*
186+
* @param string $attributeCode
187+
*
188+
* @return string
189+
*/
190+
public function getStoreLabel($attributeCode)
191+
{
192+
$attribute = $this->_getAttribute($attributeCode);
193+
return $attribute ? __($attribute->getStoreLabel()) : '';
194+
}
195+
171196
/**
172197
* Create correct date field
173198
*

app/code/Magento/Customer/Block/Widget/Gender.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public function _construct()
6464

6565
/**
6666
* Check if gender attribute enabled in system
67+
*
6768
* @return bool
6869
*/
6970
public function isEnabled()
@@ -73,13 +74,27 @@ public function isEnabled()
7374

7475
/**
7576
* Check if gender attribute marked as required
77+
*
7678
* @return bool
7779
*/
7880
public function isRequired()
7981
{
8082
return $this->_getAttribute('gender') ? (bool)$this->_getAttribute('gender')->isRequired() : false;
8183
}
8284

85+
/**
86+
* Retrieve store attribute label
87+
*
88+
* @param string $attributeCode
89+
*
90+
* @return string
91+
*/
92+
public function getStoreLabel($attributeCode)
93+
{
94+
$attribute = $this->_getAttribute($attributeCode);
95+
return $attribute ? __($attribute->getStoreLabel()) : '';
96+
}
97+
8398
/**
8499
* Get current customer from session
85100
*
@@ -92,6 +107,7 @@ public function getCustomer()
92107

93108
/**
94109
* Returns options from gender attribute
110+
*
95111
* @return OptionInterface[]
96112
*/
97113
public function getGenderOptions()

app/code/Magento/Customer/Block/Widget/Taxvat.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,17 @@ public function isRequired()
6363
{
6464
return $this->_getAttribute('taxvat') ? (bool)$this->_getAttribute('taxvat')->isRequired() : false;
6565
}
66+
67+
/**
68+
* Retrieve store attribute label
69+
*
70+
* @param string $attributeCode
71+
*
72+
* @return string
73+
*/
74+
public function getStoreLabel($attributeCode)
75+
{
76+
$attribute = $this->_getAttribute($attributeCode);
77+
return $attribute ? __($attribute->getStoreLabel()) : '';
78+
}
6679
}

app/code/Magento/Customer/view/frontend/templates/widget/dob.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ $fieldCssClass = 'field date field-' . $block->getHtmlId();
2929
$fieldCssClass .= $block->isRequired() ? ' required' : '';
3030
?>
3131
<div class="<?= $block->escapeHtmlAttr($fieldCssClass) ?>">
32-
<label class="label" for="<?= $block->escapeHtmlAttr($block->getHtmlId()) ?>"><span><?= $block->escapeHtml($block->getLabel()) ?></span></label>
32+
<label class="label" for="<?= $block->escapeHtmlAttr($block->getHtmlId()) ?>"><span><?= $block->escapeHtml($block->getStoreLabel('dob')) ?></span></label>
3333
<div class="control customer-dob">
3434
<?= $block->getFieldHtml() ?>
3535
<?php if ($_message = $block->getAdditionalDescription()) : ?>

app/code/Magento/Customer/view/frontend/templates/widget/gender.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
/** @var \Magento\Customer\Block\Widget\Gender $block */
1010
?>
1111
<div class="field gender<?php if ($block->isRequired()) echo ' required' ?>">
12-
<label class="label" for="<?= $block->escapeHtmlAttr($block->getFieldId('gender')) ?>"><span><?= $block->escapeHtml(__('Gender')) ?></span></label>
12+
<label class="label" for="<?= $block->escapeHtmlAttr($block->getFieldId('gender')) ?>"><span><?= $block->escapeHtml($block->getStoreLabel('gender')) ?></span></label>
1313
<div class="control">
14-
<select id="<?= $block->escapeHtmlAttr($block->getFieldId('gender')) ?>" name="<?= $block->escapeHtmlAttr($block->getFieldName('gender')) ?>" title="<?= $block->escapeHtmlAttr(__('Gender')) ?>"<?php if ($block->isRequired()):?> class="validate-select" data-validate="{required:true}"<?php endif; ?>>
14+
<select id="<?= $block->escapeHtmlAttr($block->getFieldId('gender')) ?>" name="<?= $block->escapeHtmlAttr($block->getFieldName('gender')) ?>" title="<?= $block->escapeHtmlAttr($block->getStoreLabel('gender')) ?>"<?php if ($block->isRequired()):?> class="validate-select" data-validate="{required:true}"<?php endif; ?>>
1515
<?php $options = $block->getGenderOptions(); ?>
1616
<?php $value = $block->getGender();?>
1717
<?php foreach ($options as $option):?>

app/code/Magento/Customer/view/frontend/templates/widget/taxvat.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
/** @var \Magento\Customer\Block\Widget\Taxvat $block */
1010
?>
1111
<div class="field taxvat<?php if ($block->isRequired()) echo ' required'; ?>">
12-
<label class="label" for="<?= $block->escapeHtmlAttr($block->getFieldId('taxvat')) ?>"><span><?= $block->escapeHtml(__('Tax/VAT number')) ?></span></label>
12+
<label class="label" for="<?= $block->escapeHtmlAttr($block->getFieldId('taxvat')) ?>"><span><?= $block->escapeHtml($block->getStoreLabel('taxvat')) ?></span></label>
1313
<div class="control">
14-
<input type="text" id="<?= $block->escapeHtmlAttr($block->getFieldId('taxvat')) ?>" name="<?= $block->escapeHtmlAttr($block->getFieldName('taxvat')) ?>" value="<?= $block->escapeHtmlAttr($block->getTaxvat()) ?>" title="<?= $block->escapeHtmlAttr(__('Tax/VAT number')) ?>" class="input-text <?= $block->escapeHtmlAttr($this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('taxvat')) ?>" <?php if ($block->isRequired()) echo ' data-validate="{required:true}"' ?>>
14+
<input type="text" id="<?= $block->escapeHtmlAttr($block->getFieldId('taxvat')) ?>" name="<?= $block->escapeHtmlAttr($block->getFieldName('taxvat')) ?>" value="<?= $block->escapeHtmlAttr($block->getTaxvat()) ?>" title="<?= $block->escapeHtmlAttr($block->getStoreLabel('taxvat')) ?>" class="input-text <?= $block->escapeHtmlAttr($this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('taxvat')) ?>" <?php if ($block->isRequired()) echo ' data-validate="{required:true}"' ?>>
1515
</div>
1616
</div>

0 commit comments

Comments
 (0)