Back to Top

Not using en-gb language folder in OC 2.2.x +?

Updated 18 November 2016

Have you ever wondered, even on using the english folder in place of en-gb in Opencart 2.2.x and upper, you get the correct language in the controller? Here’s the reason for this. If you look at the language library’s load function then you will get to know why this is happening.

public function load($filename, &$data = array()) {
	$_ = array();

	$file = DIR_LANGUAGE . 'english/' . $filename . '.php';
	
	if (is_file($file)) {
		require($file);
	}

	$file = DIR_LANGUAGE . $this->default . '/' . $filename . '.php';

	if (is_file($file)) {
		require($file);
	}

	$file = DIR_LANGUAGE . $this->directory . '/' . $filename . '.php';

	if (is_file($file)) {
		require($file);
	}

	$this->data = array_merge($this->data, $_);

	return $this->data;
}

It loads the file existing in the “english” folder by default. After loading the file from the english folder, it loads the default file of currently selected language. And after that, it loads the language file that is mentioned by the developer in the code. So, after loading all the files, the $data array is merged with the $_ array in the language file in which all the languages are stored. Hope, by this, you would also understand the concept of $_ array in the language file.

Searching for an experienced
Opencart Company ?
Find out More
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Back to Top

Message Sent!

If you have more details or questions, you can reply to the received confirmation email.

Back to Home