Need to translate some default URLs like customer/account/login/
& customer/account/create/
is there any way to translate these URLs with/without using URL rewrite?
3 Answers
- Create a language translation file:
- Go to the Magento root directory.
- Navigate to the following path: app/design/frontend/{Vendor}/{Theme}/i18n/ (if the directory doesn't exist, create it).
- Create a new file with the name en_US.csv (replace en_US with the appropriate language code if you're translating for a different language).
- Open the file and add the following entries:
"customer/account/login/", "Your translated login URL"
"customer/account/create/", "Your translated create account URL"
Replace Your "translated login URL" and "Your translated create
account URL" with the respective translations in your desired language.
Deploy the static content:
Run the following command to deploy the static content:
bin/magento setup:static-content:deploy
Clear the cache:
Run the following command to clear the cache:
bin/magento cache:clean
After following these steps, the default URLs "customer/account/login/" and "customer/account/create/" should be translated according to the entries in your translation file. Make sure to replace {Vendor} and {Theme} in the file path with your actual vendor and theme names.
This might partialy answer to your question :
If you have a limited list of URL to translate, you can use the Magento URL Rewrite feature to do this :
Go to "Marketing > SEO & Search > URL Rewrites", and click on the "Add URL Rewrite" button.
Then enter the following data :
- Create URL Rewrite : Custom
- Request Path : enter you translated URL (
client/compte/connexion
) - ** Target Path** : enter the default URL (
customer/account/login
) - Redirect Type : No
The down side of this method : You will have to edit the templates/methods where those URLs are used in order to use the translated version of the URL instead.
According to my knowledge URL can not translate without re-write, because url contains the frontname folder name controller file name.