back to phpList.org

[How-to] Disable translated Language in Admin panel :: Force englsih


#1

The RFCs and all technical terms of reference related to email messaging are English. When using a tool translated into your language, you must translate the terms from your language into the reference language.
This causes distortions that lead to misunderstandings and operating errors.

Question:
How to make the Admin panel always runs in English and never use the locale language from browser info.

Setup some options in config.php :

$language_module = 'english.inc';
define('LANGUAGE_AUTO_UPDATE', false); // Optional
define('LANGUAGE_SWITCH',0);           // Required, op. must not switch

But that is not enough

Browser language detection have to be tricked
Find howto at the end of this post:


#2

@cmakfr You need to set this config entry to 0

# admin language
# if you want to disable the language switch for the admin interface (and run all in english)
# set this one to 0
define('LANGUAGE_SWITCH',1);

#3

Thank you, this option is interesting
But after set this to 0, cleaned cookies and php session files…
…Admin backend still remain in locale translated language.
I am probably be missing something ?

I had to turn it back to 1 and do the secret-click-sequence-to-make-the-language-drop-down-menu-appear. A very strange behaviour for this feature :wink:


#4

@cmakfr It does appear a bit complicated but it looks like phplist will use the browser provided language, the Accept-Language http header. See

https://resources.phplist.com/system/config/default_system_language

The only way to use a specific language seems to be through the language switch drop-down.


#5

The documentation about default_system_language suggests us that a default language has been stored somewhere at first burst of Admin panel.

I searched where with no success into files and database.

Any help would be appreciated

(edited for a better expression)


#6

found a dirt workaround:

phpList version 3.4.1
Edit the file /admin/languages.php
Lines 61 & 69 add $setlanguage = 'en';
Line 146 add $detectlan = 'en';

Code extract starting line 56

@session_start();

if (isset($_POST['setlanguage']) && !empty($_POST['setlanguage']) && is_array($LANGUAGES[$_POST['setlanguage']])) {
    //# just in case
    $setlanguage = preg_replace('/[^\w_-]+/', '', $_POST['setlanguage']);
//CMAK
    $setlanguage =  'en';
    $_SESSION['adminlanguage'] = array(
        'info'    => $setlanguage,
        'iso'     => $setlanguage,
        'charset' => $LANGUAGES[$setlanguage][1],
        'dir'     => $LANGUAGES[$setlanguage][4],
    );
    SetCookie ( 'preferredLanguage', $setlanguage,time()+31536000);
} elseif (empty($_SESSION['adminlanguage']) && isset($_COOKIE['preferredLanguage'])) {
    $setlanguage = preg_replace('/[^\w_-]+/', '', $_COOKIE['preferredLanguage']);
//CMAK
    $setlanguage =  'en';
    $_SESSION['adminlanguage'] = array(
        'info'    => $setlanguage,
        'iso'     => $setlanguage,
        'charset' => $LANGUAGES[$setlanguage][1],
        'dir'     => $LANGUAGES[$setlanguage][4],
    );
}

Next, the detectlan
Starting line 112

if (!isset($_SESSION['adminlanguage']) || !is_array($_SESSION['adminlanguage'])) {
    if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
        $accept_lan = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
    } else {
	$accept_lan = array($GLOBALS['default_system_language']);
    }
    $detectlan = '';

    /* @@@TODO
     * we need a mapping from Accept-Language to gettext, see below
     *
     * eg nl-be becomes nl_BE
     *
     * currently "nl-be" will become "nl" and not "nl_BE";
     */

    foreach ($accept_lan as $lan) {
        if (!$detectlan) {
            if (preg_match('/^([\w-]+)/', $lan, $regs)) {
                $code = $regs[1];
                if (isset($LANGUAGES[$code])) {
                    $detectlan = $code;
                } elseif (strpos($code, '-') !== false) {
                    list($language, $country) = explode('-', $code);
                    if (isset($LANGUAGES[$language])) {
                        $detectlan = $language;
                    }
                }
            }
	}
    }
    if (!$detectlan) {
        $detectlan = $GLOBALS['default_system_language'];
    }
// CMAK
    $detectlan = 'en';

    $_SESSION['adminlanguage'] = array(
        'info'    => $detectlan,
        'iso'     => $detectlan,
        'charset' => $LANGUAGES[$detectlan][1],
        'dir'     => $LANGUAGES[$detectlan][4],
    );
}