Post by Dnk32 » Wed Oct 11, 2017 7:05 pm

Hello guys !

I made a stupid thing , i tried to make "Romanian" default language , but i changed the en-gb folder to ro-ro (Catalog and Administrator) , and then from administrator -> Localisation -> Languages ... from en-gb to ro-ro without adding separately ro-ro and let english there .
Now my problem is next.. i have no more products , customers available , no more customers groups, order statuses , return statuses and many others .
I think that admin panel read the language as "non set" .. "undefined language" and my buttons are like text_home , text_option , text_ ...
I put the public_html backup from yesterday , but nothing changed , i tried to make English language as default from Settings -> Local , but i can't save because there are no "Order status" available and i can't add any order status .. http://ibb.co/g2jYOw this is from Settings-> Option when i try to save English default .
I checked the database , Customers , order status , everything is there and fine .. how can i make the admin panel read english as default again and not undefined language ?

Newbie

Posts

Joined
Sun May 21, 2017 3:31 am

Post by webcorvo » Wed Oct 11, 2017 8:41 pm

hi,
just put again the en-gb language folders
and check the oc_language table

Opencart Developer - For custom work and support contact @ webcorvo@gmail.com


User avatar
Active Member

Posts

Joined
Mon Mar 20, 2017 11:42 pm
Location - Lisbon, Portugal

Post by webcorvo » Fri Oct 20, 2017 11:24 pm

hi Dnk32

Did you have already solved your language problem?

Opencart Developer - For custom work and support contact @ webcorvo@gmail.com


User avatar
Active Member

Posts

Joined
Mon Mar 20, 2017 11:42 pm
Location - Lisbon, Portugal

Post by straightlight » Fri Oct 20, 2017 11:51 pm

I don't know why these types of modifications are even being allowed but when a language code does not exist as a folder, it should definitely be validated from the post.

In admin/controller/localisation/language.php file,

find:

Code: Select all

foreach ($results as $result) {
			$data['languages'][] = array(
				'language_id' => $result['language_id'],
				'name'        => $result['name'] . (($result['code'] == $this->config->get('config_language')) ? $this->language->get('text_default') : null),
				'code'        => $result['code'],
				'sort_order'  => $result['sort_order'],
				'edit'        => $this->url->link('localisation/language/edit', 'user_token=' . $this->session->data['user_token'] . '&language_id=' . $result['language_id'] . $url, true)
			);
		}
replace with:

Code: Select all

$data['language_codes'] = array();

		foreach ($results as $result) {
			$data['languages'][] = array(
				'language_id' => $result['language_id'],
				'name'        => $result['name'] . (($result['code'] == $this->config->get('config_language')) ? $this->language->get('text_default') : null),
				'code'        => $result['code'],
				'sort_order'  => $result['sort_order'],
				'edit'        => $this->url->link('localisation/language/edit', 'user_token=' . $this->session->data['user_token'] . '&language_id=' . $result['language_id'] . $url, true)
			);
			
			$data['language_codes'][] = array('code'		=> html_entity_decode($result['code'], ENT_QUOTES, 'UTF-8'));
		}
Then, find:

Code: Select all

if (utf8_strlen($this->request->post['code']) < 2) {
replace with:

Code: Select all

if (utf8_strlen($this->request->post['code']) < 2 || !in_array($this->request->post['code'], $this->request->post['language_codes'])) {
In admin/language/<your_language_code>/localisation/language.php file,

find:

Code: Select all

$_['error_code']        = 'Language Code must at least 2 characters!';
replace with:

Code: Select all

$_['error_code']        = 'Language Code must at least 2 characters as it must be an existing language code installed in the store!';
In admin/view/template/localisation/language.twig file,

find:

Code: Select all

<td class="text-left">{{ language.code }}</td>
replace with:

Code: Select all

<td class="text-left">
				  {% if language_codes %}
					{% for language_code in language_codes %}
						<input type="hidden" name="language_codes[]" value="{{ language_code.code }}">
					{% endfor %}
				  {% endif %}
				  {{ language.code }}</td>
This will prevent administrators making the same mistake when changing the language code into a non-relevant or non-existing language code that would create corruption of the data relationship in the database.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Nawafinity » Wed Sep 02, 2020 8:15 pm

Hello,
I had the same problem, and I cried for 5 hours until I found a solution.

Open (phpmyadmin) and go to 'settings' table, then search for 'config_admin_language' and set the value to en-gb.

Newbie

Posts

Joined
Sun Jun 21, 2020 8:31 am

Post by tdprado » Tue Jun 01, 2021 9:50 am

Nawafinity - I only cried for 4 hours this morning until I found this post of yours ;D
Thanks for the great information provided

Newbie

Posts

Joined
Fri Jun 19, 2015 7:48 am
Who is online

Users browsing this forum: No registered users and 72 guests