Domanda

Quindi devo impostare una traduzione per le opzioni Mr. e prefisso Mrs. in forma one-page checkout, in cui un cliente riempie il suo nome, indirizzo, ecc.

Tutte le traduzioni Finora ho fatto attraverso i file .csv o nei file di template, ma questo non riesco a trovare. Anche girando sulla linea di traduzione frontend - Non riesco a vedere quale campo di applicazione è per questi 2 elementi. Credo che sia l'Mage_Customer.csv ma ??non funziona da lì. Né dal file translate.csv nella directory di design / frontend.

Sono traduzioni questi elementi opzionali un po 'diverso? Gradirei alcuni suggerimenti su come raggiungere tradurre questa.

È stato utile?

Soluzione

Se si impostano le opzioni tramite l'amministratore config sezione Customer Configuration->Name and Address Options allora si può set-up ogni sito con valori diversi.

In caso contrario, per impostazione predefinita il blocco utilizzato per tradurre apparterrà a Mage_Customer. Vedere template /app/design/frontend/base/default/template/customer/widget/name.phtml.

Dal momento che queste opzioni sono set-up attraverso la sezione di amministrazione non ci sono traduzioni "default". Si potrebbe fare una delle seguenti opzioni. Credo che 1 è il più semplice, 2 è quella che non si dovrebbe fare e 3 è una buona opzione.

  1. Aggiungi al tuo file di translate.csv,
  2. aggiungerli al file di Mage_Customer.csv (si prega di non farlo in quanto tali modifiche andranno perse se si aggiorna),
  3. Creare un modulo personalizzato che si occupa di traduzioni dei clienti e metterli in esso di file di traduzione,

Altri suggerimenti

Se si desidera tradurre prefisso altra lingua si prega di seguire le istruzioni in basso che si traducono opzione prefisso nel altra lingua in frontend.

Nota. Si prega installati language pack prima di queste modifiche

Copia: /app/code/core/Mage/Customer/Model/Address/Abstract.php a /app/code/local/Mage/Customer/Model/Address/Abstract.php

Sostituisci:

public function getName()
    {
        $name = '';
        $config = Mage::getSingleton('eav/config');
        if ($config->getAttribute('customer_address', 'prefix')->getIsVisible() && $this->getPrefix()) {
            $name .= $this->getPrefix() . ' ';
        }
        $name .= $this->getFirstname();
        if ($config->getAttribute('customer_address', 'middlename')->getIsVisible() && $this->getMiddlename()) {
            $name .= ' ' . $this->getMiddlename();
        }
        $name .=  ' ' . $this->getLastname();
        if ($config->getAttribute('customer_address', 'suffix')->getIsVisible() && $this->getSuffix()) {
            $name .= ' ' . $this->getSuffix();
        }
        return $name;
    }

public function getName()
    {
        $name = '';
        $config = Mage::getSingleton('eav/config');
        if ($config->getAttribute('customer_address', 'prefix')->getIsVisible() && $this->getPrefix()) {
            $preFix = $this->getPrefix();
            $name .= Mage::helper('customer')->__($preFix) . ' ';           
        }
        $name .= $this->getFirstname();
        if ($config->getAttribute('customer_address', 'middlename')->getIsVisible() && $this->getMiddlename()) {
            $name .= ' ' . $this->getMiddlename();
        }
        $name .=  ' ' . $this->getLastname();
        if ($config->getAttribute('customer_address', 'suffix')->getIsVisible() && $this->getSuffix()) {
            $name .= ' ' . $this->getSuffix();
        }
        return $name;
    }

Copia: /app/code/core/Mage/Customer/Model/Customer.php a /app/code/local/Mage/Customer/Model/Customer.php

Sostituisci:

public function getName()
    {
        $name = '';
        $config = Mage::getSingleton('eav/config');
        if ($config->getAttribute('customer', 'prefix')->getIsVisible() && $this->getPrefix()) {
            $name .= $this->getPrefix() . ' ';
        }
        $name .= $this->getFirstname();
        if ($config->getAttribute('customer', 'middlename')->getIsVisible() && $this->getMiddlename()) {
            $name .= ' ' . $this->getMiddlename();
        }
        $name .=  ' ' . $this->getLastname();
        if ($config->getAttribute('customer', 'suffix')->getIsVisible() && $this->getSuffix()) {
            $name .= ' ' . $this->getSuffix();
        }
        return $name;
    }

public function getName()
    {
        $name = '';
        $config = Mage::getSingleton('eav/config');
        if ($config->getAttribute('customer', 'prefix')->getIsVisible() && $this->getPrefix()) {
            $preFix = $this->getPrefix();
            $name .= Mage::helper('customer')->__($preFix) . ' ';
        }
        $name .= $this->getFirstname();
        if ($config->getAttribute('customer', 'middlename')->getIsVisible() && $this->getMiddlename()) {
            $name .= ' ' . $this->getMiddlename();
        }
        $name .=  ' ' . $this->getLastname();
        if ($config->getAttribute('customer', 'suffix')->getIsVisible() && $this->getSuffix()) {
            $name .= ' ' . $this->getSuffix();
        }
        return $name;
    }

Copia /app/code/core/Mage/Customer/Block/Address/Renderer/Default.php a /app/code/local/Mage/Customer/Block/Address/Renderer/Default.php

Sostituisci:

public function render(Mage_Customer_Model_Address_Abstract $address, $format=null)
    {
        switch ($this->getType()->getCode()) {
            case 'html':
                $dataFormat = Mage_Customer_Model_Attribute_Data::OUTPUT_FORMAT_HTML;
                break;
            case 'pdf':
                $dataFormat = Mage_Customer_Model_Attribute_Data::OUTPUT_FORMAT_PDF;
                break;
            case 'oneline':
                $dataFormat = Mage_Customer_Model_Attribute_Data::OUTPUT_FORMAT_ONELINE;
                break;
            default:
                $dataFormat = Mage_Customer_Model_Attribute_Data::OUTPUT_FORMAT_TEXT;
                break;
        }

        $formater   = new Varien_Filter_Template();
        $attributes = Mage::helper('customer/address')->getAttributes();

        $data = array();
        foreach ($attributes as $attribute) {
            /* @var $attribute Mage_Customer_Model_Attribute */
            if (!$attribute->getIsVisible()) {
                continue;
            }
            if ($attribute->getAttributeCode() == 'country_id') {
                $data['country'] = $address->getCountryModel()->getName();
            } else if ($attribute->getAttributeCode() == 'region') {
                $data['region'] = Mage::helper('directory')->__($address->getRegion());
            } else {
                $dataModel = Mage_Customer_Model_Attribute_Data::factory($attribute, $address);
                $value     = $dataModel->outputValue($dataFormat);
                if ($attribute->getFrontendInput() == 'multiline') {
                    $values    = $dataModel->outputValue(Mage_Customer_Model_Attribute_Data::OUTPUT_FORMAT_ARRAY);
                    // explode lines
                    foreach ($values as $k => $v) {
                        $key = sprintf('%s%d', $attribute->getAttributeCode(), $k + 1);
                        $data[$key] = $v;
                    }
                }
                $data[$attribute->getAttributeCode()] = $value;
            }
        }

        if ($this->getType()->getHtmlEscape()) {
            foreach ($data as $key => $value) {
                $data[$key] = $this->escapeHtml($value);
            }
        }

        $formater->setVariables($data);

        $format = !is_null($format) ? $format : $this->getFormat($address);

        return $formater->filter($format);
    }

con

public function render(Mage_Customer_Model_Address_Abstract $address, $format=null)
    {
        switch ($this->getType()->getCode()) {
            case 'html':
                $dataFormat = Mage_Customer_Model_Attribute_Data::OUTPUT_FORMAT_HTML;
                break;
            case 'pdf':
                $dataFormat = Mage_Customer_Model_Attribute_Data::OUTPUT_FORMAT_PDF;
                break;
            case 'oneline':
                $dataFormat = Mage_Customer_Model_Attribute_Data::OUTPUT_FORMAT_ONELINE;
                break;
            default:
                $dataFormat = Mage_Customer_Model_Attribute_Data::OUTPUT_FORMAT_TEXT;
                break;
        }

        $formater   = new Varien_Filter_Template();
        $attributes = Mage::helper('customer/address')->getAttributes();

        $data = array();
        foreach ($attributes as $attribute) {
            //echo $attribute->getAttributeCode(); echo '<br />';
            /* @var $attribute Mage_Customer_Model_Attribute */
            if (!$attribute->getIsVisible()) {
                continue;
            }
            if ($attribute->getAttributeCode() == 'prefix') {
                 $prefixopt = $address->getPrefix();
            }
            if ($attribute->getAttributeCode() == 'country_id') {
                $data['country'] = $address->getCountryModel()->getName();
            } else if ($attribute->getAttributeCode() == 'region') {
                $data['region'] = Mage::helper('directory')->__($address->getRegion());
            } else {
                $dataModel = Mage_Customer_Model_Attribute_Data::factory($attribute, $address);
                $value     = $dataModel->outputValue($dataFormat);
                if ($attribute->getFrontendInput() == 'multiline') {
                    $values    = $dataModel->outputValue(Mage_Customer_Model_Attribute_Data::OUTPUT_FORMAT_ARRAY);
                    // explode lines
                    foreach ($values as $k => $v) {
                        $key = sprintf('%s%d', $attribute->getAttributeCode(), $k + 1);
                        $data[$key] = $v;
                    }
                }
                $data[$attribute->getAttributeCode()] = $value;
            }
        }

        $data['prefix'] = Mage::helper('customer')->__($prefixopt);

        if ($this->getType()->getHtmlEscape()) {
            foreach ($data as $key => $value) {
                $data[$key] = $this->escapeHtml($value);
            }
        }

        $formater->setVariables($data);

        $format = !is_null($format) ? $format : $this->getFormat($address);

        return $formater->filter($format);
    }

Assicurati di avere aggiunto le parole di conversione nella CSV traduzione. L'ho fatto con successo questo in Magento 1.9.2.4

So che la sua un vecchio minaccia, ma avevo bisogno la risposta e non riusciva a trovare qui. Ho trovato la risposta me stesso, per le persone che non hanno familiarità con Magento:

Copia System.xml da / app / code / nucleo / Mage / Cliente / etc / a / app / code / locali / Mage / Cliente / etc /

Variazione System.xml l'etichetta del prefisso il valore show_in_store da 0 a 1. È ora possibile vedere l'etichetta in ogni vista negozio e dare valori diversi, così traduzioni.

. NOTA: Prefisso ha un'etichetta per l'attivazione e un'etichetta per le opzioni

È inoltre possibile utilizzare questi valori nelle e-mail transazionali.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a magento.stackexchange
scroll top