Magento 2 Translations
March 24, 2024 at 3:37:00 AM
pawan
Magento 2 support transtaion of store front out of the box, we need to create CSV and need to add translations!
In magento 2.x, Translation file is located in i18n folder. i18n folder can be reside at Theme, Module Or Global level.
Theme:
app/design/frontend/{Package}/{theme}/i18n/en_US.csv
Module:
app/code/Vendor/Module/i18n/en_US.csv
Global:
app/i18n/en_US.csv
In following ways, we can enable translations for text
Tanslation in xml file:
We need to add translate="true" if we want translation for it.
<item name="label" xsi:type="string" translate="true">Contact Us</item>
Tanslation in php file:
<?php echo __('text-to-be-translate'); ?>
Tanslation in CMS Block/Page:
<h1 class="hero">{{trans "text-to-be-translate" }}</h1>
i18n
magento2
translation
0 comments