How to Extend a List of Languages in Magento 2

How to Extend a List of Languages in Magento 2

Sometimes you may not find the neccesary language while localizing your website. Here is a short step-by-step tutorial to help you with this issue.

Magento 2 is a multilingual system. It used ResourceBundle for working with locales and had all the locales available in the ICU library.

 

How to extend language list in Magento 2

But for some unknown reasons this list is limited. The limitations are located in Magento\Framework\Locale\Config in the _allowedLocales property. Magento 2 uses the getAllowedLocales public function for getting the list of locales.

 

Adding an unavailable language

First of all, create a plugin:

Then enable the plugin in the di.xml file:

After that, we need to run the bin/magento setup:upgrade for applied plugin command in the console.

Here is what we will see as a result:

How to extend language list in Magento 2

That’s it, now you have the necessary language on the list.

 



Post a new comment

top
BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *