When you create a multi-language website in Magento 2, first of all, we suggest searching for
language packages provided by other developers. Basically they offer both backend and frontend with hundreds of phrases in different languages. As usual, the language pack provides translated versions for all translatable strings in the code in one CSV-file.
But if you need more clear translation for cms pages, blocks, etc., you can add it on your own. We are here to help you.
Let’s assume, you have two languages on your website like English and Arabic or maybe more. In this article we guide you how to translate into
Arabic language. With other languages you do the same.
1. Add Translation for CMS page and CMS block
You need to use the
"trans" keyword inside the
cms page or
block when you want to translate the text as per the language selected.
{{trans "Text need to translate"}}
Here is an example to add translate for cms block:
2. Translation csv file in Magento 2
Step 1: In folder code, go to app/design/frontend/Sm/market/i18n
and open file ar_SA.csv (If the csv file is not available, you need to download package and upload csv file into the folder code app/design/frontend/Sm/market/i18n
)
Step 2: Open ar_SA.csv file and make all required changes in your translation. File opened in a text editor might look like this:
Step 3: In admin panel, Go to Store >> Configuration >> General and select "Locale" is "Arabic"
Step 4: Run command to flush cache.
php bin/magento c:f
Step 5: Well done! Please refresh the frontend of your store to see result.
How to Request Custom Website?
If you want to upgrade your Magento 2 store or if you need any other special features or extensions, use our Customize service. I hope your company thrives and your sales soar!