How to turn off browser language autodetect in OpenCart

OpenCart has a feature to detect the language of your browser and force that language by default.

Browser Language

Your browser knows your preferred language. Not only that, it is sending this information with every page request you make to a server. So the server also knows your browser language.

68367c3216

How does OpenCart detect the Browser Language?

OpenCart has a small piece of code in catalog/controller/startup/startup.php on line 56 where it tries to pull the list of languages from the header request and compare it to the available languages in the store.

If it finds a match, it will force this language onto the user, ignoring the default language set in OpenCart admin panel.

This is why, when a user visits your store for the first time, they may see your store not in the default language, but in their browser language.

This can be very confusing since most of OpenCart users have never heard of this feature and it is not explained in the documentation.

How to turn of Browser Language Detect feature in OpenCart?

To turn this feature off, simply prevent the code from ever checking the browser language in the first place.

dc7ea97357

Just by replacing the if statement with false, we will skip the language to detect code and continue on, setting the default language as the current language.

If you don't like coding, use our OCmod file that we created for you. You can donload the code from GitHub and install it via Extension Installer.

Not sure where to start?

If you are just starting and need a push, just send us a message.
We will happily point you in the right direction.

Talk to a developer