Pawan Labs Pawan Labs

Magento 2 Translations

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>

Sign in to publish a comment

0 comments

Be the first to comment on this post.

Adobe Certified Expert
Adobe Certified Expert
Adobe Commerce contributor
Green Software for practitioners
mongodbinc
Adobe Certified Professional