If this is your first visit, check our documentation. To post, register or login.
Forums / Addon Language Packs / Default language for admin different than shop

Default language for admin different than shop

Started by jeking on 8 Jul 2014, 9:56 PM · Views: 8,671

Results 1 to 10 of 10
8 Jul 2014, 9:56 PM
#1
jeking avatar

jeking

Totally Zenned

Join Date:
Oct 2005
Location:
Chicago, IL USA
Posts:
1,592
Plugin Contributions:
0

Default language for admin different than shop

My client's site is set for Swedish as the default language. Is it possible to set the admin to default to English?

Jim
Wheaton Website Services

9 Jul 2014, 3:29 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Default language for admin different than shop

Just do not use the admin Swedish language files

Zen-Venom Get Bitten

9 Jul 2014, 3:37 AM
#3
jeking avatar

jeking

Totally Zenned

Join Date:
Oct 2005
Location:
Chicago, IL USA
Posts:
1,592
Plugin Contributions:
0

Re: Default language for admin different than shop

That was the first thing I tried. When I deleted the Swedish admin language files, I got this error:

[08-Jul-2014 16:47:33 America/Chicago] PHP Warning: require(includes/languages/swedish.php): failed to open stream: No such file or directory in /home/miashop/public_html/zencart/XXXXXX/includes/init_includes/init_languages.php on line 35

Jim
Wheaton Website Services

9 Jul 2014, 5:37 AM
#4
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Default language for admin different than shop

admin > localization > Languages > set english to be default(might be sort order)

Zen-Venom Get Bitten

9 Jul 2014, 12:28 PM
#5
jeking avatar

jeking

Totally Zenned

Join Date:
Oct 2005
Location:
Chicago, IL USA
Posts:
1,592
Plugin Contributions:
0

Re: Default language for admin different than shop

English has a sort order of zero, Swedish is one and is the default. If I set English as the default, that changes the store front the English as well.

Jim
Wheaton Website Services

9 Jul 2014, 1:31 PM
#6
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,142
Plugin Contributions:
56

Re: Default language for admin different than shop

You could make a small core file change to /YOUR_ADMIN/includes/init_includes/init_languages.php:

<?php
/**
 * @package admin
 * @copyright Copyright 2003-2012 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version GIT: $Id: Author: DrByte  Fri Jul 6 11:57:44 2012 -0400 Modified in v1.5.1 $
 */
if (!defined('IS_ADMIN_FLAG')) {
  die('Illegal Access');
}
if (!defined ('DEFAULT_LANGUAGE_ADMIN')) define ('DEFAULT_LANGUAGE_ADMIN', 1);  //-Default admin to English
// set the language
  if (!isset($_SESSION['language']) || isset($_GET['language'])) {

    include(DIR_WS_CLASSES . 'language.php');
    $lng = new language();

    if (isset($_GET['language']) && zen_not_null($_GET['language'])) {
      $lng->set_language($_GET['language']);
    } else {
      $lng->get_browser_language();
      $lng->set_language(DEFAULT_LANGUAGE_ADMIN);
    }

    $_SESSION['language'] = (zen_not_null($lng->language['directory']) ? $lng->language['directory'] : 'english');
    $_SESSION['languages_id'] = (zen_not_null($lng->language['id']) ? $lng->language['id'] : 1);
    $_SESSION['languages_code'] = (zen_not_null($lng->language['code']) ? $lng->language['code'] : 'en');
  }

// temporary patch for lang override chicken/egg quirk
  $template_query = $db->Execute("select template_dir from " . TABLE_TEMPLATE_SELECT . " where template_language in (" . (int)$_SESSION['languages_id'] . ', 0' . ") order by template_language DESC");
  $template_dir = $template_query->fields['template_dir'];

// include the language translations
  require(DIR_WS_LANGUAGES . $_SESSION['language'] . '.php');
  $current_page = basename($PHP_SELF);
  if (file_exists(DIR_WS_LANGUAGES . $_SESSION['language'] . '/' . $current_page)) {
    include(DIR_WS_LANGUAGES . $_SESSION['language'] . '/' . $current_page);
  }

  if ($za_dir = @dir(DIR_WS_LANGUAGES . $_SESSION['language'] . '/extra_definitions')) {
    while ($zv_file = $za_dir->read()) {
      if (preg_match('~^[^\._].*\.php$~i', $zv_file) > 0) {
        require(DIR_WS_LANGUAGES . $_SESSION['language'] . '/extra_definitions/' . $zv_file);
      }
    }
    $za_dir->close();
  }
9 Jul 2014, 2:02 PM
#7
jeking avatar

jeking

Totally Zenned

Join Date:
Oct 2005
Location:
Chicago, IL USA
Posts:
1,592
Plugin Contributions:
0

Re: Default language for admin different than shop

Editing the core file was Plan B, if there was not a setting to use first.

I used your edit, changing ('DEFAULT_LANGUAGE_ADMIN', 1) to ('DEFAULT_LANGUAGE_ADMIN', 0) since English is o and Swedish is 1, but when I log in I'm still getting Swedish as the default in the admin. I also tested in FF, Chrome is my default) and got the same result.

I don't see DEFAULT_LANGUAGE_ADMIN defined any where.

Jim
Wheaton Website Services

9 Jul 2014, 2:17 PM
#8
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,142
Plugin Contributions:
56

Re: Default language for admin different than shop

Duh! :blush: Make this change:

if (!defined ('DEFAULT_LANGUAGE_ADMIN')) define ('DEFAULT_LANGUAGE_ADMIN', 'en');  //-Default admin to English

If you're currently logged into your admin, you'll need to logout first to have the change take effect.

P.S. DEFAULT_LANGUAGE_ADMIN is not a currently defined within the Zen Cart codebase.

9 Jul 2014, 3:10 PM
#9
jeking avatar

jeking

Totally Zenned

Join Date:
Oct 2005
Location:
Chicago, IL USA
Posts:
1,592
Plugin Contributions:
0

Re: Default language for admin different than shop

I love simple fixes! That was it, thanks.

Jim
Wheaton Website Services

9 Jul 2014, 5:09 PM
#10
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,142
Plugin Contributions:
56

Re: Default language for admin different than shop

Most excellent! I'm glad it (finally) worked.