Get Free Audit

How to Extend a List of Languages in Magento 2

Aug 9, 2018

2633 Oleg Semenov

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:

Andrey_Dubina
Partner With Us Let's discuss how to grow your business. Get a Free Quote.
Talk to Andrey


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.

magento custom development

Magento Custom Development

Take your online store to the next level with BelVG Magento Custom Development

Visit the page
Andrey Dubina
Partner With Us Looking for a partner to grow your business? We are the right company to bring your webstore to success. Talk to Andrey

4 Comments

  1. HI,

    I did follow your post and it seems to work, BUT, when I wanna to deploy to production mode, it throws an exception , the message is “es_US argument has invalid value, please run info:language:list for list of available locales “, can you help me? what can I do?

Post a new comment

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