简体   繁体   English

magento如何翻译

[英]How translate works in magento

I am fairly new to magento and wondering how translation works, I can see there are many csv files under locale/XXXX/ folders which mapping English to various languages, but in actual php/xml/phtml how it been used? 我是magento的新手,想知道翻译的工作原理,我可以看到在locale / XXXX /文件夹下有许多csv文件,它们将英语映射到各种语言,但是在实际的php / xml / phtml中是如何使用的? Could somebody help me out with an example like "Contact Us" in footer. 有人可以在页脚中提供“联系我们”之类的示例来帮助我。

Contact Us link in footer comes from a static block, for that you have to create different store views for different stores and specify translations accordingly. 页脚中的“与我们联系”链接来自一个静态块,为此您必须为不同的商店创建不同的商店视图并相应地指定翻译。

Little more understanding about translations in Magento. 对Magento中的翻译了解得更多。 These are few types of translations in Magento: 这些是Magento中几种翻译类型:

  1. DB Translation (core_translate table) 数据库翻译(core_translate表)

  2. Theme specific translation file (app/design/frontend/default/your-theme/locale) 特定于主题的翻译文件(应用/设计/前端/默认/您的主题/语言环境)

  3. Module Specific Translation Files (app/locale/**/*.csv) 特定于模块的翻译文件(app / locale / ** / *。csv)

  4. Translation of static block/cms pages. 静态块/ cms页面的翻译。

DB Translation 数据库翻译

Translations from the core_translate table are basically merged into the translation array just like the theme translations. 与主题翻译一样,core_translate表中的翻译基本上会合并到翻译数组中。 Existing keys from the module or theme translations are overwritten by database records, new ones are added. 模块记录或主题转换中的现有键将被数据库记录覆盖,并添加新的键。

Theme Specific Translation 主题特定翻译

Have a look at app/design/frontend/default/themexyz/locale/en_US/translate.csv If you apply themexyz theme, your translations will take effect from above mentioned file 看看app / design / frontend / default / themexyz / locale / en_US / translate.csv如果应用它们,则翻译将从上述文件生效

Module Specific Translation 特定模块翻译

Files from app/locale/**/*.csv that are referenced from active modules etc/config.xml files are parsed. 分析来自活动模块etc / config.xml文件中引用的来自app / locale / ** / *。csv的文件。

<!-- Mage/Catalog/etc/config.xml -->
<frontend>
    <translate>
        <modules>
            <Mage_Catalog>
                <files>
                    <default>Mage_Catalog.csv</default>
                </files>
            </Mage_Catalog>
        </modules>
    </translate>
</frontend>

Inside your block/template/model/controller you write something like Mage::helper('module')->__('text to be translated'); 在您的块/模板/模型/控制器内部,您编写类似Mage :: helper('module')-> __('text to translation');的代码。 to get your text translated. 来翻译您的文字。 You specify the translation under app/locale/en_US/Mage_Catalog.csv this way "text to be translated","Translation" 您可以通过以下方式在app / locale / en_US / Mage_Catalog.csv下指定翻译:“要翻译的文字”,“翻译”

Translation of static block/cms pages 静态块/ cms页面的翻译

Follow this link 点击此链接

More information: https://magento.stackexchange.com/questions/6722/how-to-implement-translations-in-design-template-package-csvs-how-does-echo-t 更多信息: https : //magento.stackexchange.com/questions/6722/how-to-implement-translations-in-design-template-package-csvs-how-does-echo-t

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM