We use cookies to make your experience better. To comply with the new e-Privacy directive, we need to ask for your consent to set the cookies. Learn more.
Setting Up a Multi-Language Magento 2 Store
Step 1: Install and Configure Language Packs
Install Language Packs:
Go to your Magento Admin Panel.
Navigate to "Stores" -> "Configuration" -> "General" -> "Locale Options."
In the "Locale" section, select the language you want to add and save the settings.
Repeat this process for each language you want to support.
Step 2: Create Translations
Create Translations:
Magento allows you to create translations for various parts of your store, such as button labels, product descriptions, and more.
Create CSV files for each language, e.g., en_US.csv for English and fr_FR.csv for French.
Upload these files to the directory app/i18n/[Vendor]/[theme]/i18n/, where [Vendor] is your theme provider and [theme] is your theme name.
Step 3: Configure Stores and Websites
Create Websites:
Go to "Stores" -> "All Stores."
Click "Create Website" and name your new website, e.g., "English Website."
Create websites for each language you plan to support.
Create Stores:
Under "All Stores," click "Create Store."
Select the website you created and give your store a name, e.g., "English Store."
Repeat this process for each language, creating corresponding stores.
Associate Languages:
For each store, navigate to "Stores" -> "Configuration."
In the "General" -> "Locale Options" section, select the appropriate language for that store.
Step 4: Configure Your Web Server (Nginx)
Configure Nginx:
If you're using Nginx as your web server for Magento 2, configure server blocks for each website/language.
Here's an example Nginx configuration for one website:
server {
listen 80;
server_name example.com; # Replace with your domain name
set $MAGE_RUN_TYPE website;
set $MAGE_RUN_CODE en_website_code; # Replace with your website code
location / {
root /path/to/magento/root;
index index.php;
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; # Path to your PHP-FPM socket
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param MAGE_MODE $MAGE_MODE;
fastcgi_param MAGE_RUN_TYPE $MAGE_RUN_TYPE;
fastcgi_param MAGE_RUN_CODE $MAGE_RUN_CODE;
}
}
Create separate server blocks for each website (store) and adjust the server_name, $MAGE_RUN_CODE, and other settings accordingly.
Restart Nginx:
After making changes to the Nginx configuration, restart Nginx to apply the new settings:
sudo systemctl restart nginx
Step 5: Testing
Testing:
After configuring Magento for multiple languages, ensure that all pages, labels, and product descriptions are displayed correctly in the selected language.
Test the language switcher functionality to make sure customers can switch between languages seamlessly.
Your Magento 2 store is now set up to support multiple languages, with each language having its website and store configurations. Customers can easily switch between languages, and your web server is configured to serve the appropriate content based on the selected language.