Home >How to Deploy Specific Language in Magento 2

How to Deploy Specific Language in Magento 2

In Magento 2, the pub/static directory is where static view files are used for uploading and frontpage files such as css, js, images, etc. Typically, when you run “magento setup: static-content: deploy”, the code will be generated from the static files in the module’s view directory into the pub/static directory, but it only generate into the en_US language – which is the default language.

In fact, in Magento 2, there are many languages to use. So how can you generate code from your static files into another specific language? This tutorial will share how to deploy specific language in Magento 2.

First of all, to deploy into a specific language, you need to know what Magento language code you want to deploy. Here is a list of the language codes supported in Magento 2 (withdefault is en_US). To view a list of language codes, type the following command:

magento info:language:list

List of Magento language codes.

After having the list of language codes and selecting the language code you want to use, you continue to runnning the command to deploy. It is possible to deploy one or more languages at the same time (make sure you delete the language file you want to deploy in the pub/static directory before).

You can delete these directories directly or run the following command:

rm -rf []

For example, delete the language in the directory pub/static/frontend/Magento/luma:

rm -rf pub/static/frontend/Magento/luma/

Then run the command to deploy:

magento setup:static-content:deploy []

Example:

magento setup:static-content:deploy vi_VN
magento setup:static-content:deploy en_US en_GB vi_VN

Processing of deploy.

pub/static directory before and after deploying.

Otherwise, you can also deploy each Magento language, for each specific theme. It will save your time to check on a theme, before generating code for all other themes. To deploy language on a specific theme, run the following command:

magento setup:static-content:deploy [] [-t|--theme[=""]]

Example:

magento setup:static-content:deploy ro_RO --theme Magento/luma

pub/static directory before and after deploying.

If you have any problems or need our professional service, please email us support@bsscommerce.com. You can also find the right solution in our best-in-class https://bsscommerce.com/magento-2-extensions.html

< Previous Post
Next Post >
+ posts