Interface shows the wrong language - cookie problem? Interface shows the wrong language - cookie problem?
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Interface shows the wrong language - cookie problem?

Started by smantscheff, November 06, 2010, 04:53:03 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

smantscheff

After a successful test installation on my private server I just installed Coppermine on the production server.
First I copied the test installation to which I had applied some minor changes. Then I recognized that the interface does not show the configured interface language (formal german) but the standard english.
So I dropped this installation and installed a fresh SVN checkout (revision 8014). Same problem.
But: This problem occured only in Google Chrome, not in IE and not in FF. So I deleted all Chrome cookies, and voilá: the desired language showed up. So there seems to be a cookie handling problem somewhere either in Coppermine or in Chrome or both.

Αndré

Coppermine has a language detection. It uses the browser's language by default. If you want to overwrite that, you have to add the parameter ?lang=german_formal to e.g. index.php.


smantscheff

I had "Automatic language detection" disabled in all my installations. So the expected behaviour was that any language detection automatism was disabled. The implementation is a little bit confusing, especially with a browser like Chrome which does not have a cookie viewing or editing interface.
I also wonder why the "preferred language" cookie seems to have stored standard english. I do not see any language prefererence settings in Chrome. How do you detect the "preferred language" from Chrome?

Αndré

You can find the language processing in include/init.inc.php:
// ********************************************************
// * Language processing --- start
// ********************************************************

require('lang/english.php');                    // Load the default language file: 'english.php'
$CONFIG['lang_config'] = DEFAULT_LANGUAGE;      // Save the gallery-configured setting
$CONFIG['default_lang'] = $CONFIG['lang'];      // Save default language

$enabled_languages_array = array();

$result = cpg_db_query("SELECT lang_id FROM {$CONFIG['TABLE_LANGUAGE']} WHERE enabled='YES'");
while ($row = mysql_fetch_assoc($result)) {
    $enabled_languages_array[] = $row['lang_id'];
}
mysql_free_result($result);

// Process language selection if present in URI or in user profile or try
// autodetection if default charset is utf-8
if ($matches = $superCage->get->getMatched('lang', '/^[a-z0-9_-]+$/')) {
    $USER['lang'] = $matches[0];
}

// Set the user preference to the language submit by URL parameter or by auto-detection
// Only set the preference if a corresponding file language file exists.
if (isset($USER['lang']) && !strstr($USER['lang'], '/') && file_exists('lang/' . $USER['lang'] . '.php')) {
    $CONFIG['lang'] = strtr($USER['lang'], '$/\\:*?"\'<>|`', '____________');
} elseif ($CONFIG['charset'] == 'utf-8' && $CONFIG['language_autodetect'] != 0) {
    include('include/select_lang.inc.php');
    if (file_exists('lang/' . $USER['lang'] . '.php') == TRUE) {
        if (in_array($USER['lang'], $enabled_languages_array)) {
            $CONFIG['lang'] = $USER['lang'];
        }
    }
} else {
    unset($USER['lang']);
}

if (!file_exists("lang/{$CONFIG['lang']}.php")) {
    $CONFIG['lang'] = 'english';
}

// We finally load the chosen language file if it differs from English
if ($CONFIG['lang'] != 'english') {
    require('lang/' . $CONFIG['lang'] . '.php');
}
set_js_var('lang_close', $lang_common['close']);
if (defined('THEME_HAS_MENU_ICONS')) {
    set_js_var('icon_close_path', $THEME_DIR . 'images/icons/close.png');
} else {
    set_js_var('icon_close_path', 'images/icons/close.png');
}

// ********************************************************
// * Language processing --- end
// ********************************************************


It may be that you (as admin) have stored a different language in the cookie, from a time before you changed the default language and disabled language auto detection. Does everything work as expected after the deletion of the cookie? You always can reset the language by adding the lang parameter, e.g.
index.php?lang=xxx

Joachim Müller

Quote from: smantscheff on November 08, 2010, 11:52:30 AMHow do you detect the "preferred language" from Chrome?
We can not support you on the usage of a particular browser, but my guess is that one of the following does the trick (found by googling for "Chrome configuration"): Can't say for sure, as I don't have Chrome available for my OS. Anyway, your question is clearly beyond scope on this forum. Both Αndré as well as I have answered your initial question, so what's the actual issue you have? Leave "auto" on for everyone else, it works just fine.