Translate Languages for frontend - Magento 2.4.2

Languages Translate

many times we try to translate some words on our frontend manually. but unfortunately, we can not or difficult to edit translate file. today I will show you how to do that in simple steps.


What you need?


  1. SSH Access
  2. Editor

FILES:

  1. Go to
app/design/frontend/package_folder/theme_folder/default/ 
  1. Create a Folder inside the default directory call it “i18n

  2. Create file CSV inside i18n call it as your translate language ex: in my case for Arabic: “ar_SA.csv

  3. open CSV file with your editor:

 app/design/frontend/package_folder/theme_folder/default/i18n/ar_SA.csv 

  1. add any word you want to translate ex: in my case I want to translate “Store:” word to Arabic word “المتجر” … Note: it’s case-sensitive

"Store:","المتجر :",web

Explanation of the code:

"Original_Word","Translate_Word",web

  1. after finish save & close.

  2. Go to

app/design/frontend/package_folder/theme_folder/default/web/template/
  1. Backup or Rename if exist and Create a file call it “translate.html

  2. open translate.html file with your editor

  3. Add

<p data-bind="i18n: 'Store:'"></p>

Explanation of the code:
Note: it’s case-sensitive

<p data-bind="i18n: 'Original_Word'"></p>
  1. after finish save & close.

SSH

  1. Now Open SSH: Go to Magento root folder for ex: cd /var/www/html/
cd /var/www/html/
  1. run command:
rm -rf var/view_preprocessed/*
rm -rf pub/static/frontend/*
php bin/magento c:f
php bin/magento setup:static-content:deploy ar_SA -f -t package_folder/theme_folder/theme_Childfolder
php bin/magento c:f

Thank you and Stay Safe
Happy Coding :wink:

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.