Post by Herring » Sat Apr 03, 2010 6:37 pm

Hello,

While there is an easy way to change the language of the storefront, there is no such feature for the admin panel. To change it, one must go through the settings, which is inconvenient. Also, there is only one choice for all users.

With the following patch, each administrator can use the panel in a language of their choice. The admin language will be the same as the storefront language for a given user. To change it, just select another language in the storefront.

The selection is based on the language cookie. Only if the cookie does not exist or does not lead to a valid index in the $languages table, config_admin_language is used as a fallback choice.

Thus, the admin language option in settings can still be used to set the default, fallback language, unless overriden by the cookie.

The patch is a unified diff against the 1.4.6 release. To apply, type
% patch -p0 < admin_lang_autosel.diff
in your web root.

Hope someone finds it useful too

UPDATED : File in next post

Newbie

Posts

Joined
Sat Apr 03, 2010 6:08 pm

Post by Herring » Wed Apr 07, 2010 2:12 am

Bug fix. Please use the version below (I believe I can't edit the above post).

Attachments

Dynamic selection of admin language (2) (OpenCart 1.4.6, diff -u)


Newbie

Posts

Joined
Sat Apr 03, 2010 6:08 pm

Post by bedo02 » Sat Aug 14, 2010 2:54 pm

Hi,

first of all, thank you Herring! good job :)

It is working also with the version 1.4.8.

basically you replace the lines in admin/index.php

Code: Select all

$config->set('config_language_id', $languages[$config->get('config_admin_language')]['language_id']);

$language = new Language($languages[$config->get('config_admin_language')]['directory']);
$language->load($languages[$config->get('config_admin_language')]['filename']);
by

Code: Select all

// Choose admin language automatically from the storefront cookie
if(!empty($_COOKIE['language']) && !empty($languages[$_COOKIE['language']]))
    $language_autosel = $_COOKIE['language'];
else
    $language_autosel = $config->get('config_admin_language');

$config->set('config_language_id', $languages[$language_autosel]['language_id']);
$language = new Language($languages[$language_autosel]['directory']);
$language->load($languages[$language_autosel]['filename']);


what you get is, that the language is being set from the front end not the back end. > depending on the language set on the front end, your admin language is being set. Quite ugly way to, get more independent language profiles for admins... This should be definitely in one of the future releases.

using oc 1.5.6


Newbie

Posts

Joined
Mon Oct 26, 2009 9:43 pm
Who is online

Users browsing this forum: No registered users and 7 guests