Skip to content

Commit 41e3c95

Browse files
author
Your Name
committed
29217: Fixed - Prefix and Suffix Translation
1 parent 68770fc commit 41e3c95

File tree

6 files changed

+12
-9
lines changed

6 files changed

+12
-9
lines changed

app/code/Magento/Customer/Block/Address/Renderer/DefaultRenderer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ public function renderArray($addressAttributes, $format = null)
189189
$data[$key] = $v;
190190
}
191191
}
192+
if(in_array($attributeCode,['prefix','suffix'])) {
193+
$value = __($value);
194+
}
192195
$data[$attributeCode] = $value;
193196
}
194197
}

app/code/Magento/Customer/Helper/View.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function getCustomerName(CustomerInterface $customerData)
4141
$name = '';
4242
$prefixMetadata = $this->_customerMetadataService->getAttributeMetadata('prefix');
4343
if ($prefixMetadata->isVisible() && $customerData->getPrefix()) {
44-
$name .= $customerData->getPrefix() . ' ';
44+
$name .= __($customerData->getPrefix()) . ' ';
4545
}
4646

4747
$name .= $customerData->getFirstname();
@@ -55,7 +55,7 @@ public function getCustomerName(CustomerInterface $customerData)
5555

5656
$suffixMetadata = $this->_customerMetadataService->getAttributeMetadata('suffix');
5757
if ($suffixMetadata->isVisible() && $customerData->getSuffix()) {
58-
$name .= ' ' . $customerData->getSuffix();
58+
$name .= ' ' . __($customerData->getSuffix());
5959
}
6060
return $name;
6161
}

app/code/Magento/Customer/Model/Address/AbstractAddress.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public function getName()
194194
{
195195
$name = '';
196196
if ($this->_eavConfig->getAttribute('customer_address', 'prefix')->getIsVisible() && $this->getPrefix()) {
197-
$name .= $this->getPrefix() . ' ';
197+
$name .= __($this->getPrefix()) . ' ';
198198
}
199199
$name .= $this->getFirstname();
200200
$middleName = $this->_eavConfig->getAttribute('customer_address', 'middlename');
@@ -203,7 +203,7 @@ public function getName()
203203
}
204204
$name .= ' ' . $this->getLastname();
205205
if ($this->_eavConfig->getAttribute('customer_address', 'suffix')->getIsVisible() && $this->getSuffix()) {
206-
$name .= ' ' . $this->getSuffix();
206+
$name .= ' ' . __($this->getSuffix());
207207
}
208208
return $name;
209209
}

app/code/Magento/Customer/Model/Options.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ private function prepareNamePrefixSuffixOptions($options, $isOptional = false)
101101
$result = [];
102102
$options = explode(';', $options);
103103
foreach ($options as $value) {
104-
$result[] = $this->escaper->escapeHtml(trim($value)) ?: ' ';
104+
$result[] = $this->escaper->escapeHtml(trim(__($value))) ?: ' ';
105105
}
106106

107107
if ($isOptional && trim(current($options))) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ $suffix = $block->showSuffix();
4848
title="<?= $block->escapeHtmlAttr($block->getStoreLabel('prefix')) ?>"
4949
class="<?= $block->escapeHtmlAttr($block->getAttributeValidationClass('prefix')) ?>" <?= $block->isPrefixRequired() ? ' data-validate="{required:true}"' : '' ?> >
5050
<?php foreach ($block->getPrefixOptions() as $_option) : ?>
51-
<option value="<?= $block->escapeHtmlAttr($_option) ?>"<?php if ($block->getObject()->getPrefix() == $_option) : ?> selected="selected"<?php endif; ?>>
51+
<option value="<?= $block->escapeHtmlAttr(__($_option)) ?>"<?php if ($block->getObject()->getPrefix() == $_option) : ?> selected="selected"<?php endif; ?>>
5252
<?= $block->escapeHtml(__($_option)) ?>
5353
</option>
5454
<?php endforeach; ?>
@@ -106,7 +106,7 @@ $suffix = $block->showSuffix();
106106
title="<?= $block->escapeHtmlAttr($block->getStoreLabel('suffix')) ?>"
107107
class="<?= $block->escapeHtmlAttr($block->getAttributeValidationClass('suffix')) ?>" <?= $block->isSuffixRequired() ? ' data-validate="{required:true}"' : '' ?>>
108108
<?php foreach ($block->getSuffixOptions() as $_option) : ?>
109-
<option value="<?= $block->escapeHtmlAttr($_option) ?>"<?php if ($block->getObject()->getSuffix() == $_option) : ?> selected="selected"<?php endif; ?>>
109+
<option value="<?= $block->escapeHtmlAttr(__($_option)) ?>"<?php if ($block->getObject()->getSuffix() == $_option) : ?> selected="selected"<?php endif; ?>>
110110
<?= $block->escapeHtml(__($_option)) ?>
111111
</option>
112112
<?php endforeach; ?>

app/code/Magento/Sales/Model/Order/Address.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,15 @@ public function getName()
142142
{
143143
$name = '';
144144
if ($this->getPrefix()) {
145-
$name .= $this->getPrefix() . ' ';
145+
$name .= __($this->getPrefix()) . ' ';
146146
}
147147
$name .= $this->getFirstname();
148148
if ($this->getMiddlename()) {
149149
$name .= ' ' . $this->getMiddlename();
150150
}
151151
$name .= ' ' . $this->getLastname();
152152
if ($this->getSuffix()) {
153-
$name .= ' ' . $this->getSuffix();
153+
$name .= ' ' . __($this->getSuffix());
154154
}
155155
return $name;
156156
}

0 commit comments

Comments
 (0)