magento 翻译修改不生效问题如何解决?

当Magento下单数量超限时,系统提示信息未按预期翻译。问题在于翻译文件locale->zh_HK->translation.csv的修改未生效。原因是系统配置的区域与翻译文件路径中的locale不匹配,应改为与system->configuration->general->general中的locale选项一致,即locale->zh_HK->translation.csv。修正后,翻译文件才能正常应用。
摘要由CSDN通过智能技术生成

我产品页面当我们下单的时候的数量超过Qty的设定数量的时候,系统会提示我们一条信息:


那么,这条信息是从哪里来的呢?

我们打开模版文件


找到代码

<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
这句是用来输出提示信息的,因为我们是点击了够买之后才提示的,所以我估计这个提示信息是从购物车返回的

打到文件 D:\wamp\www\attomato\app\code\core\Mage\Checkout\controllers\CartController.php

找到函数

public function addAction(){}
里面有这样的一段代码

try {
……
}catch (Mage_Core_Exception $e) {
            if ($this->_getSession()->getUseNotice(true)) {
                $this->_getSession()->addNotice($e->getMessage());
            } else {
//                $message=$this->__('Please check the Qty of the %s before add to cart!');
//                $this->_getSession()->addError($message);
                $messages = array_unique(explode("\n", $this->__($e->getMessage())));
                foreach ($messages as $message) {
                    $this->_getSession()->addError($message);
                }
            }

这里的addError就是增加错误提示信息的,用来返回到产品页面中


那么我们要怎么去修改这条提示语句呢?

我们就需要修改翻译文件

找到你的模版的翻译文件,如:locale->zh_HK->translation.csv

增加一条翻译内容

"The requested quantity for ""%s"" is not available.","Please check the Qty for ""%s"" before order it."

注意两个语句中间是有分号隔开的

当修改完这个后,我以为就可以了,刷新了一下页面,发现还是提示原来的信息,也就是说,翻译的东西还没有生效。

那么问题出在哪里呢?

注意看上面的翻译文件路径红色的部份,本来的路径是这样的  locale->en_US->translation.csv

这个zh_HK 和en_US 是什么意思呢:

打开文件D:\wamp\www\attomato\app\code\core\Mage\Core\Model\Locale\Config.php

里面有这么的一段,看完就知道了

protected $_allowedLocales      = array(
        'af_ZA' /*Afrikaans (South Africa)*/,   'ar_DZ' /*Arabic (Algeria)*/,       'ar_EG' /*Arabic (Egypt)*/,
        'ar_KW' /*Arabic (Kuwait)*/,            'ar_MA' /*Arabic (Morocco)*/,       'ar_SA' /*Arabic (Saudi Arabia)*/,
        'az_AZ' /*Azerbaijani (Azerbaijan)*/,   'be_BY' /*Belarusian (Belarus)*/,   'bg_BG' /*Bulgarian (Bulgaria)*/,
        'bn_BD' /*Bengali (Bangladesh)*/,       'bs_BA' /*Bosnian (Bosnia)*/,       'ca_ES' /*Catalan (Catalonia)*/,
        'cs_CZ' /*Czech (Czech Republic)*/,     'cy_GB' /*Welsh (United Kingdom)*/, 'da_DK' /*Danish (Denmark)*/,
        'de_AT' /*German (Austria)*/,           'de_CH' /*German (Switzerland)*/,   'de_DE' /*German (Germany)*/,
        'el_GR' /*Greek (Greece)*/,             'en_AU' /*English (Australian)*/,   'en_CA' /*English (Canadian)*/,
        'en_GB' /*English (United Kingdom)*/,   'en_NZ' /*English (New Zealand)*/,  'en_US' /*English (United States)*/,
        'es_AR' /*Spanish (Argentina)*/,        'es_CO' /*Spanish (Colombia)*/,     'es_PA' /*Spanish (Panama)*/,
        'gl_ES' /*Galician (Galician)*/,        'es_CR' /*Spanish (Costa Rica)*/,   'es_ES' /*Spanish (Spain)*/,
        'es_MX' /*Spanish (Mexico)*/,           'es_EU' /*Basque (Basque)*/,        'es_PE' /*Spanish (Peru)*/,
        'et_EE' /*Estonian (Estonia)*/,         'fa_IR' /*Persian (Iran)*/,         'fi_FI' /*Finnish (Finland)*/,
        'fil_PH' /*Filipino (Philippines)*/,    'fr_CA' /*French (Canada)*/,        'fr_FR' /*French (France)*/,
        'gu_IN' /*Gujarati (India)*/,           'he_IL' /*Hebrew (Israel)*/,        'hi_IN' /*Hindi (India)*/,
        'hr_HR' /*Croatian (Croatia)*/,         'hu_HU' /*Hungarian (Hungary)*/,    'id_ID' /*Indonesian (Indonesia)*/,
        'is_IS' /*Icelandic (Iceland)*/,        'it_CH' /*Italian (Switzerland)*/,  'it_IT' /*Italian (Italy)*/,
        'ja_JP' /*Japanese (Japan)*/,           'ka_GE' /*Georgian (Georgia)*/,     'km_KH' /*Khmer (Cambodia)*/,
        'ko_KR' /*Korean (South Korea)*/,       'lo_LA' /*Lao (Laos)*/,             'lt_LT' /*Lithuanian (Lithuania)*/,
        'lv_LV' /*Latvian (Latvia)*/,           'mk_MK' /*Macedonian (Macedonia)*/, 'mn_MN' /*Mongolian (Mongolia)*/,
        'ms_MY' /*Malaysian (Malaysia)*/,       'nl_NL' /*Dutch (Netherlands)*/,    'nb_NO' /*Norwegian BokmГ_l (Norway)*/,
        'nn_NO' /*Norwegian Nynorsk (Norway)*/, 'pl_PL' /*Polish (Poland)*/,        'pt_BR' /*Portuguese (Brazil)*/,
        'pt_PT' /*Portuguese (Portugal)*/,      'ro_RO' /*Romanian (Romania)*/,     'ru_RU' /*Russian (Russia)*/,
        'sk_SK' /*Slovak (Slovakia)*/,          'sl_SI' /*Slovenian (Slovenia)*/,   'sq_AL' /*Albanian (Albania)*/,
        'sr_RS' /*Serbian (Serbia)*/,           'sv_SE' /*Swedish (Sweden)*/,       'sw_KE' /*Swahili (Kenya)*/,
        'th_TH' /*Thai (Thailand)*/,            'tr_TR' /*Turkish (Turkey)*/,       'uk_UA' /*Ukrainian (Ukraine)*/,
        'vi_VN' /*Vietnamese (Vietnam)*/,       'zh_CN' /*Chinese (China)*/,        'zh_HK' /*Chinese (Hong Kong SAR)*/,
        'zh_TW' /*Chinese (Taiwan)*/,           'es_CL' /*Spanich (Chile)*/,        'lo_LA' /*Laotian*/,
        'es_VE' /*Spanish (Venezuela)*/,        'en_IE' /*English (Ireland)*/,
    );

回到上面的话题,因为之前的翻译路径是这样的: locale-> en_US->translation.csv

而后台system->configuration->general->general中的locale optons设置是的香港的区域


而我们的翻译路径文件是 locale->en_US->translation.csv

两者不对应,所以翻译文件不起效

改回locale->zh_HK->translation.csv后一切OK

另外翻译文件是要在config.xml中定义的

<frontend>
<translate>
            <modules>
                <Mage_Catalog>
                    <files>
                        <default>Mage_Catalog.csv</default>
                    </files>
                </Mage_Catalog>
            </modules>
        </translate>
</frontend>




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值