Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
FieldTranslator.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
14 {
18  private $translationMap = [];
19 
23  public function __construct(array $translationMap)
24  {
25  $this->translationMap = $translationMap;
26  }
27 
34  public function translate(string $fieldName) : string
35  {
36  if (isset($this->translationMap[$fieldName])) {
37  return $this->translationMap[$fieldName];
38  }
39 
40  return $fieldName;
41  }
42 }